(root)/
util-linux-2.39/
sys-utils/
hwclock.h
       1  #ifndef HWCLOCK_CLOCK_H
       2  #define HWCLOCK_CLOCK_H
       3  
       4  #include <stdio.h>
       5  #include <stdlib.h>
       6  #include <string.h>
       7  #include <sys/time.h>
       8  #include <time.h>
       9  
      10  #include "c.h"
      11  #include "debug.h"
      12  #include "nls.h"
      13  
      14  #define HWCLOCK_DEBUG_INIT		(1 << 0)
      15  #define HWCLOCK_DEBUG_RANDOM_SLEEP	(1 << 1)
      16  #define HWCLOCK_DEBUG_DELTA_VS_TARGET	(1 << 2)
      17  #define HWCLOCK_DEBUG_ALL		0xFFFF
      18  
      19  UL_DEBUG_DECLARE_MASK(hwclock);
      20  #define DBG(m, x)	__UL_DBG(hwclock, HWCLOCK_DEBUG_, m, x)
      21  #define ON_DBG(m, x)	__UL_DBG_CALL(hwclock, HWCLOCK_DEBUG_, m, x)
      22  
      23  struct hwclock_control {
      24  	char *date_opt;
      25  	char *adj_file_name;
      26  	double rtc_delay;	/* --delay <seconds> */
      27  #if defined(__linux__) && defined(__alpha__)
      28  	char *epoch_option;
      29  #endif
      30  #ifdef __linux__
      31  	char *rtc_dev_name;
      32  #endif
      33  	char *param_get_option;
      34  	char *param_set_option;
      35  	unsigned int
      36  		hwaudit_on:1,
      37  		adjust:1,
      38  		show:1,
      39  		hctosys:1,
      40  		utc:1,
      41  		systohc:1,
      42  #if defined(__linux__) && defined(__alpha__)
      43  		getepoch:1,
      44  		setepoch:1,
      45  #endif
      46  		noadjfile:1,
      47  		local_opt:1,
      48  		directisa:1,
      49  		testing:1,
      50  		systz:1,
      51  		predict:1,
      52  		get:1,
      53  		set:1,
      54  		update:1,
      55  		universal:1,	/* will store hw_clock_is_utc() return value */
      56  		verbose:1;
      57  };
      58  
      59  struct clock_ops {
      60  	char *interface_name;
      61  	int (*get_permissions) (void);
      62  	int (*read_hardware_clock) (const struct hwclock_control *ctl, struct tm * tm);
      63  	int (*set_hardware_clock) (const struct hwclock_control *ctl, const struct tm * tm);
      64  	int (*synchronize_to_clock_tick) (const struct hwclock_control *ctl);
      65  	const char *(*get_device_path) (void);
      66  };
      67  
      68  extern const struct clock_ops *probe_for_cmos_clock(void);
      69  extern const struct clock_ops *probe_for_rtc_clock(const struct hwclock_control *ctl);
      70  
      71  /* hwclock.c */
      72  extern double time_diff(struct timeval subtrahend, struct timeval subtractor);
      73  
      74  /* rtc.c */
      75  #if defined(__linux__) && defined(__alpha__)
      76  extern int get_epoch_rtc(const struct hwclock_control *ctl, unsigned long *epoch);
      77  extern int set_epoch_rtc(const struct hwclock_control *ctl);
      78  #endif
      79  
      80  struct hwclock_param {
      81  	int id;
      82  	const char *name;
      83  	const char *help;
      84  };
      85  
      86  extern const struct hwclock_param *get_hwclock_params(void);
      87  extern int get_param_rtc(const struct hwclock_control *ctl,
      88  			const char *name, uint64_t *id, uint64_t *value);
      89  extern int set_param_rtc(const struct hwclock_control *ctl, const char *name);
      90  
      91  extern void __attribute__((__noreturn__))
      92  hwclock_exit(const struct hwclock_control *ctl, int status);
      93  
      94  extern int parse_date(struct timespec *, char const *, struct timespec const *);
      95  
      96  #endif				/* HWCLOCK_CLOCK_H */