+#if !defined(BUILDING_VARIANT)
+semaphore_t clock_sem = MACH_PORT_NULL;
+mach_port_t clock_port = MACH_PORT_NULL;
+
+void _init_clock_port(void);
+
+void _init_clock_port(void) {
+ kern_return_t kr;
+ mach_port_t host = mach_host_self();
+
+ /* Get the clock service port for nanosleep */
+ kr = host_get_clock_service(host, SYSTEM_CLOCK, &clock_port);
+ if (kr != KERN_SUCCESS) {
+ abort();
+ }
+
+ kr = semaphore_create(mach_task_self(), &clock_sem, SYNC_POLICY_FIFO, 0);
+ if (kr != KERN_SUCCESS) {
+ abort();
+ }
+ mach_port_deallocate(mach_task_self(), host);
+}
+#else