xref: /haiku/src/system/libroot/os/time.cpp (revision e0ef64750f3169cd634bb2f7a001e22488b05231)
1 /*
2  * Copyright 2002-2009, Axel Dörfler, axeld@pinc-software.de.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include <errno.h>
8 #include <stdio.h>
9 #include <string.h>
10 #include <syslog.h>
11 
12 #include <FindDirectory.h>
13 #include <OS.h>
14 
15 #include <commpage_defs.h>
16 #include <libroot_private.h>
17 #include <real_time_data.h>
18 #include <syscalls.h>
19 
20 
21 static struct real_time_data* sRealTimeData;
22 
23 
24 void
25 __init_time(void)
26 {
27 	sRealTimeData = (struct real_time_data*)
28 		USER_COMMPAGE_TABLE[COMMPAGE_ENTRY_REAL_TIME_DATA];
29 
30 	__arch_init_time(sRealTimeData, false);
31 }
32 
33 
34 //	#pragma mark - public API
35 
36 
37 uint32
38 real_time_clock(void)
39 {
40 	return (__arch_get_system_time_offset(sRealTimeData) + system_time())
41 		/ 1000000;
42 }
43 
44 
45 bigtime_t
46 real_time_clock_usecs(void)
47 {
48 	return __arch_get_system_time_offset(sRealTimeData) + system_time();
49 }
50 
51 
52 void
53 set_real_time_clock(uint32 secs)
54 {
55 	_kern_set_real_time_clock(secs);
56 }
57 
58 
59 status_t
60 set_timezone(const char* /*timezone*/)
61 {
62 	/* There's nothing we can do here, since we no longer support named
63 	 * timezones.
64 	 *
65 	 * TODO: should we keep this around for compatibility or get rid of it?
66 	 */
67 	return B_OK;
68 }
69 
70 
71 bigtime_t
72 set_alarm(bigtime_t when, uint32 mode)
73 {
74 	return _kern_set_alarm(when, mode);
75 }
76