]> git.ipfire.org Git - thirdparty/util-linux.git/blob - sys-utils/hwclock.h
Merge branch 'travis-test' of https://github.com/rudimeier/util-linux
[thirdparty/util-linux.git] / sys-utils / hwclock.h
1 #ifndef HWCLOCK_CLOCK_H
2 #define HWCLOCK_CLOCK_H
3
4 #include <errno.h>
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8 #include <sys/time.h>
9 #include <time.h>
10
11 #include "c.h"
12
13 enum {
14 RTC_BUSYWAIT_OK = 0,
15 RTC_BUSYWAIT_FAILED,
16 RTC_BUSYWAIT_TIMEOUT
17 };
18
19 struct hwclock_control {
20 char *date_opt;
21 char *adj_file_name;
22 #if defined(__linux__) && defined(__alpha__)
23 unsigned long epoch_option;
24 #endif
25 #ifdef __linux__
26 char *rtc_dev_name;
27 #endif
28 unsigned int debug;
29 unsigned int
30 hwaudit_on:1,
31 adjust:1,
32 show:1,
33 hctosys:1,
34 utc:1,
35 systohc:1,
36 #if defined(__linux__) && defined(__alpha__)
37 getepoch:1,
38 setepoch:1,
39 #endif
40 noadjfile:1,
41 local_opt:1,
42 directisa:1,
43 testing:1,
44 systz:1,
45 predict:1,
46 get:1,
47 set:1,
48 update:1,
49 universal:1; /* will store hw_clock_is_utc() return value */
50 };
51
52 struct clock_ops {
53 char *interface_name;
54 int (*get_permissions) (void);
55 int (*read_hardware_clock) (const struct hwclock_control *ctl, struct tm * tm);
56 int (*set_hardware_clock) (const struct hwclock_control *ctl, const struct tm * tm);
57 int (*synchronize_to_clock_tick) (const struct hwclock_control *ctl);
58 };
59
60 extern struct clock_ops *probe_for_cmos_clock(void);
61 extern struct clock_ops *probe_for_rtc_clock(const struct hwclock_control *ctl);
62
63 typedef int bool;
64
65 /* hwclock.c */
66 extern int debug;
67 extern unsigned long epoch_option;
68 extern double time_diff(struct timeval subtrahend, struct timeval subtractor);
69
70 /* rtc.c */
71 #if defined(__linux__) && defined(__alpha__)
72 extern int get_epoch_rtc(const struct hwclock_control *ctl, unsigned long *epoch);
73 extern int set_epoch_rtc(const struct hwclock_control *ctl);
74 #endif
75
76 extern void hwclock_exit(const struct hwclock_control *ctl, int status);
77
78 #endif /* HWCLOCK_CLOCK_H */