]> git.ipfire.org Git - thirdparty/util-linux.git/blame - sys-utils/hwclock.h
flock: initialize timevals [-Werror=maybe-uninitialized]
[thirdparty/util-linux.git] / sys-utils / hwclock.h
CommitLineData
9abd5e4b
KZ
1/*
2 * SPDX-License-Identifier: GPL-2.0-or-later
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 */
9abb2685
KZ
9#ifndef HWCLOCK_CLOCK_H
10#define HWCLOCK_CLOCK_H
11
7eda085c 12#include <stdio.h>
66ee8158 13#include <stdlib.h>
7eda085c 14#include <string.h>
f2ff0adf 15#include <sys/time.h>
7eda085c
KZ
16#include <time.h>
17
b940bae3 18#include "c.h"
ff4e18bd 19#include "debug.h"
6097b12d 20#include "nls.h"
ff4e18bd
WP
21
22#define HWCLOCK_DEBUG_INIT (1 << 0)
23#define HWCLOCK_DEBUG_RANDOM_SLEEP (1 << 1)
24#define HWCLOCK_DEBUG_DELTA_VS_TARGET (1 << 2)
25#define HWCLOCK_DEBUG_ALL 0xFFFF
26
27UL_DEBUG_DECLARE_MASK(hwclock);
28#define DBG(m, x) __UL_DBG(hwclock, HWCLOCK_DEBUG_, m, x)
29#define ON_DBG(m, x) __UL_DBG_CALL(hwclock, HWCLOCK_DEBUG_, m, x)
b940bae3 30
336f7c5f
SK
31struct hwclock_control {
32 char *date_opt;
336f7c5f 33 char *adj_file_name;
df4f1a66 34 double rtc_delay; /* --delay <seconds> */
039a0cec 35#if defined(__linux__) && defined(__alpha__)
f7599b4f 36 char *epoch_option;
039a0cec 37#endif
336f7c5f
SK
38#ifdef __linux__
39 char *rtc_dev_name;
40#endif
6097b12d 41 char *param_get_option;
b22b78b1 42 char *param_set_option;
336f7c5f 43 unsigned int
336f7c5f 44 hwaudit_on:1,
336f7c5f 45 adjust:1,
336f7c5f
SK
46 show:1,
47 hctosys:1,
48 utc:1,
49 systohc:1,
039a0cec 50#if defined(__linux__) && defined(__alpha__)
336f7c5f
SK
51 getepoch:1,
52 setepoch:1,
53#endif
54 noadjfile:1,
55 local_opt:1,
336f7c5f
SK
56 directisa:1,
57 testing:1,
58 systz:1,
59 predict:1,
60 get:1,
61 set:1,
62 update:1,
ff4e18bd 63 universal:1, /* will store hw_clock_is_utc() return value */
76cf1753
RV
64 vl_read:1,
65 vl_clear:1,
ff4e18bd 66 verbose:1;
336f7c5f
SK
67};
68
7eda085c
KZ
69struct clock_ops {
70 char *interface_name;
ef71b8f1 71 int (*get_permissions) (void);
336f7c5f
SK
72 int (*read_hardware_clock) (const struct hwclock_control *ctl, struct tm * tm);
73 int (*set_hardware_clock) (const struct hwclock_control *ctl, const struct tm * tm);
74 int (*synchronize_to_clock_tick) (const struct hwclock_control *ctl);
df4f1a66 75 const char *(*get_device_path) (void);
7eda085c
KZ
76};
77
e08dddbc
TW
78extern const struct clock_ops *probe_for_cmos_clock(void);
79extern const struct clock_ops *probe_for_rtc_clock(const struct hwclock_control *ctl);
7eda085c 80
7eda085c 81/* hwclock.c */
982a4a5d 82extern double time_diff(struct timeval subtrahend, struct timeval subtractor);
7eda085c
KZ
83
84/* rtc.c */
039a0cec 85#if defined(__linux__) && defined(__alpha__)
af68bd01 86extern int get_epoch_rtc(const struct hwclock_control *ctl, unsigned long *epoch);
336f7c5f 87extern int set_epoch_rtc(const struct hwclock_control *ctl);
039a0cec 88#endif
88058a71 89
6097b12d
BK
90struct hwclock_param {
91 int id;
92 const char *name;
93 const char *help;
94};
95
63d81834 96extern const struct hwclock_param *get_hwclock_params(void);
511a5126
KZ
97extern int get_param_rtc(const struct hwclock_control *ctl,
98 const char *name, uint64_t *id, uint64_t *value);
99extern int set_param_rtc(const struct hwclock_control *ctl, const char *name);
6097b12d 100
76cf1753
RV
101extern int rtc_vl_read(const struct hwclock_control *ctl);
102extern int rtc_vl_clear(const struct hwclock_control *ctl);
103
39ff5b34
RM
104extern void __attribute__((__noreturn__))
105hwclock_exit(const struct hwclock_control *ctl, int status);
9abb2685 106
8e1b131e
KZ
107extern int parse_date(struct timespec *, char const *, struct timespec const *);
108
ef71b8f1 109#endif /* HWCLOCK_CLOCK_H */