Loading...
sys/settimeofday.c Libc-763.13 Libc-1725.0.11
--- Libc/Libc-763.13/sys/settimeofday.c
+++ Libc/Libc-1725.0.11/sys/settimeofday.c
@@ -21,9 +21,18 @@
  * @APPLE_LICENSE_HEADER_END@
  */
 
-#include <sys/time.h>
+#include <TargetConditionals.h>
+#if !TARGET_OS_DRIVERKIT
 #include <notify.h>
 #include <notify_keys.h>
+#else
+#define notify_post(...)
+#endif
+#include <errno.h>
+#include <sys/time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "_simple.h"
 
 #ifndef kNotifyClockSet
 #define kNotifyClockSet "com.apple.system.clock_set"
@@ -38,7 +47,20 @@
 settimeofday(const struct timeval *tp, const struct timezone *tzp)
 {
 	int ret = __settimeofday(tp, tzp);
-	if (ret == 0) notify_post(kNotifyClockSet);
+	int serror = 0;
+	if (ret == 0) {
+		notify_post(kNotifyClockSet);
+	} else {
+		serror = errno;
+	}
 
+	if (tp) {
+		char *msg = NULL;
+		asprintf(&msg, "settimeofday({%#lx,%#x}) == %d", tp->tv_sec, tp->tv_usec, ret);
+		_simple_asl_log(ASL_LEVEL_NOTICE, "com.apple.settimeofday", msg);
+		free(msg);
+	}
+
+	errno = serror;
 	return ret;
 }