/* * Copyright 2002-2004, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ #include #include #include #include #include #include static struct real_time_data sRealTimeDefaults = { 0, 100000 }; static struct real_time_data *sRealTimeData; void __init_time(void) { area_id dataArea; area_info info; dataArea = find_area("real time data userland"); if (dataArea < 0 || get_area_info(dataArea, &info) < B_OK) { syslog(LOG_ERR, "error finding real time data area: %s\n", strerror(dataArea)); sRealTimeData = &sRealTimeDefaults; } else sRealTimeData = (struct real_time_data *)info.address; __arch_init_time(sRealTimeData); } uint32 real_time_clock(void) { return (sRealTimeData->system_time_offset + system_time()) / 1000000; } bigtime_t real_time_clock_usecs(void) { return sRealTimeData->system_time_offset + system_time(); } void set_real_time_clock(uint32 secs) { _kern_set_real_time_clock(secs); } status_t set_timezone(char *timezone) { // ToDo: set_timezone() status_t err; struct tm *tm; time_t t; time(&t); tm = localtime(&t); if ((err = _kern_set_tzspecs(tm->tm_gmtoff, tm->tm_isdst))