1*1b191cb5SApple OSS Distributions #include <stdlib.h> 2*1b191cb5SApple OSS Distributions #include <time.h> 3*1b191cb5SApple OSS Distributions #include <sys/time.h> 4*1b191cb5SApple OSS Distributions #include <sys/types.h> 5*1b191cb5SApple OSS Distributions #include <sys/sysctl.h> 6*1b191cb5SApple OSS Distributions #include <mach/mach_time.h> 7*1b191cb5SApple OSS Distributions 8*1b191cb5SApple OSS Distributions #include <darwintest.h> 9*1b191cb5SApple OSS Distributions 10*1b191cb5SApple OSS Distributions T_GLOBAL_META(T_META_RUN_CONCURRENTLY(true)); 11*1b191cb5SApple OSS Distributions 12*1b191cb5SApple OSS Distributions T_DECL(mach_boottime_usec, "mach_boottime_usec()", 13*1b191cb5SApple OSS Distributions T_META_ALL_VALID_ARCHS(true), T_META_LTEPHASE(LTE_POSTINIT)) 14*1b191cb5SApple OSS Distributions { 15*1b191cb5SApple OSS Distributions uint64_t bt_usec = mach_boottime_usec(); 16*1b191cb5SApple OSS Distributions 17*1b191cb5SApple OSS Distributions struct timeval bt_tv; 18*1b191cb5SApple OSS Distributions size_t len = sizeof(bt_tv); 19*1b191cb5SApple OSS Distributions T_ASSERT_POSIX_SUCCESS(sysctlbyname("kern.boottime", &bt_tv, &len, NULL, 0), NULL); 20*1b191cb5SApple OSS Distributions 21*1b191cb5SApple OSS Distributions T_EXPECT_EQ((uint64_t)bt_tv.tv_sec * USEC_PER_SEC + (uint64_t)bt_tv.tv_usec, bt_usec, NULL); 22*1b191cb5SApple OSS Distributions } 23