/* * clock_set_calendar_microtime: * * Sets the current calendar value by * recalculating the epoch and offset * from the system clock. * * Also adjusts the boottime to keep the * value consistent, writes the new * calendar value to the platform clock, * and sends calendar change notifications. */ void clock_set_calendar_microtime( clock_sec_t secs, clock_usec_t microsecs) { clock_sec_t sys; clock_usec_t microsys; clock_sec_t newsecs; spl_t s; newsecs = (microsecs < 500*USEC_PER_SEC)? secs: secs + 1; s = splclock(); clock_lock(); commpage_disable_timestamp(); /* * Calculate the new calendar epoch based on * the new value and the system clock. */ clock_get_system_microtime(&sys, µsys); TIME_SUB(secs, sys, microsecs, microsys, USEC_PER_SEC); /* * Adjust the boottime based on the delta. */ clock_boottime += secs - clock_calend.epoch; /* * Set the new calendar epoch. */ clock_calend.epoch = secs; nanoseconds_to_absolutetime((uint64_t)microsecs * NSEC_PER_USEC, &clock_calend.offset); /* * Cancel any adjustment in progress. */ calend_adjtotal = clock_calend.adjdelta = 0; clock_unlock(); /* * Set the new value for the platform clock. */ PESetGMTTimeOfDay(newsecs); splx(s); /* * Send host notifications. */ host_notify_calendar_change(); #if CONFIG_DTRACE clock_track_calend_nowait(); #endif }
uint32_t IntervalChecker::getmillisec(void) const { clock_sec_t s; clock_usec_t m; clock_get_system_microtime(&s, &m); uint32_t interval = static_cast<int>(s - secs_) * 1000 + static_cast<int>(m - microsecs_) / 1000; return interval; }
inline void NDAS_clock_get_system_value(uint32_t *time) { #ifdef __KPI_SOCKET__ // BUG BUG BUG!!! uint32_t microsecs; #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ <= 1050 clock_get_system_microtime(time, µsecs); #else clock_get_system_microtime((clock_sec_t *)time, µsecs); #endif #else mach_timespec_t time_t; time_t = clock_get_system_value(); *time = time_t.tv_sec; #endif }
__private_extern__ struct timeval devtimer_current_time(void) { struct timeval tv; clock_sec_t sec; clock_usec_t usec; clock_get_system_microtime(&sec, &usec); tv.tv_sec = sec; tv.tv_usec = usec; return (tv); }
static uint32_t jiffies() { #if defined(MAC_OS_X_VERSION_10_6) clock_sec_t seconds; clock_usec_t microsecs; #else uint32_t seconds; uint32_t microsecs; #endif clock_get_system_microtime(&seconds, µsecs); return seconds * 100 + microsecs / 10000; // 10 ms }
bool WMIHIKeyboard::start(IOService *provider) { if(!provider || !super::start( provider )) { IOLog("%s: Failed to load..\n", this->getName()); return false; } Device = (WMIHIKeyboardDevice *) provider; clock_get_system_microtime(&lastEventSecs,&lastEventMicrosecs); return true; }
void IOPlatformExpert:: PMLog(const char *who, unsigned long event, unsigned long param1, unsigned long param2) { clock_sec_t nows; clock_usec_t nowus; clock_get_system_microtime(&nows, &nowus); nowus += (nows % 1000) * 1000000; kprintf("pm%u %p %.30s %d %lx %lx\n", nowus, current_thread(), who, // Identity (int) event, (long) param1, (long) param2); // Args }
/* * clock_initialize_calendar: * * Set the calendar and related clocks * from the platform clock at boot or * wake event. * * Also sends host notifications. */ void clock_initialize_calendar(void) { clock_sec_t sys, secs = PEGetGMTTimeOfDay(); clock_usec_t microsys, microsecs = 0; spl_t s; s = splclock(); clock_lock(); commpage_disable_timestamp(); if ((long)secs >= (long)clock_boottime) { /* * Initialize the boot time based on the platform clock. */ if (clock_boottime == 0) clock_boottime = secs; /* * Calculate the new calendar epoch based on * the platform clock and the system clock. */ clock_get_system_microtime(&sys, µsys); TIME_SUB(secs, sys, microsecs, microsys, USEC_PER_SEC); /* * Set the new calendar epoch. */ clock_calend.epoch = secs; nanoseconds_to_absolutetime((uint64_t)microsecs * NSEC_PER_USEC, &clock_calend.offset); /* * Cancel any adjustment in progress. */ calend_adjtotal = clock_calend.adjdelta = 0; } clock_unlock(); splx(s); /* * Send host notifications. */ host_notify_calendar_change(); #if CONFIG_DTRACE clock_track_calend_nowait(); #endif }
void xf86getsecs(long * secs, long * usecs) { /*struct timeval tv; microtime(&tv); *secs = tv.tv_sec; *usecs= tv.tv_usec; */ clock_sec_t d_secs = 0; clock_usec_t d_usecs = 0; clock_get_system_microtime(&d_secs, &d_usecs); *secs = d_secs; *usecs = d_usecs; return; }
/* * Receive hotkey event (only down) and send keyboard down and up event * Limits the rate of event send to HID stack, otherwise the system slow down and the sound/sun bezel lags. */ IOReturn WMIHIKeyboard::message( UInt32 type, IOService * provider, void * argument) { if (type == kIOACPIMessageDeviceNotification) { clock_sec_t secs, deltaSecs; clock_usec_t microsecs, deltaMicrosecs; clock_get_system_microtime(&secs,µsecs); deltaSecs = secs - lastEventSecs; if (deltaSecs < 2) { deltaMicrosecs = microsecs + (1000000 * deltaSecs) - lastEventMicrosecs; if (deltaMicrosecs < 125000) // rate limiter to 125 ms return kIOReturnSuccess; } lastEventSecs = secs; lastEventMicrosecs = microsecs; { UInt32 code = *((UInt32 *) argument); AbsoluteTime now; uint64_t* pnow = reinterpret_cast<uint64_t*>(&now); clock_get_uptime(pnow); dispatchKeyboardEvent( code, /*direction*/ true, /*timeStamp*/ now ); clock_get_uptime(pnow); dispatchKeyboardEvent( code, /*direction*/ false, /*timeStamp*/ now ); } } return kIOReturnSuccess; }
void IntervalChecker::begin(void) { clock_get_system_microtime(&secs_, µsecs_); }