iPXE
time.h
Go to the documentation of this file.
1 #ifndef _IPXE_TIME_H
2 #define _IPXE_TIME_H
3 
4 /** @file
5  *
6  * Time source
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <sys/time.h>
13 #include <ipxe/api.h>
14 #include <config/time.h>
15 
16 /**
17  * Calculate static inline time API function name
18  *
19  * @v _prefix Subsystem prefix
20  * @v _api_func API function
21  * @ret _subsys_func Subsystem API function
22  */
23 #define TIME_INLINE( _subsys, _api_func ) \
24  SINGLE_API_INLINE ( TIME_PREFIX_ ## _subsys, _api_func )
25 
26 /**
27  * Provide a time API implementation
28  *
29  * @v _prefix Subsystem prefix
30  * @v _api_func API function
31  * @v _func Implementing function
32  */
33 #define PROVIDE_TIME( _subsys, _api_func, _func ) \
34  PROVIDE_SINGLE_API ( TIME_PREFIX_ ## _subsys, _api_func, _func )
35 
36 /**
37  * Provide a static inline time API implementation
38  *
39  * @v _prefix Subsystem prefix
40  * @v _api_func API function
41  */
42 #define PROVIDE_TIME_INLINE( _subsys, _api_func ) \
43  PROVIDE_SINGLE_API_INLINE ( TIME_PREFIX_ ## _subsys, _api_func )
44 
45 /* Include all architecture-independent time API headers */
46 #include <ipxe/null_time.h>
47 #include <ipxe/efi/efi_time.h>
48 #include <ipxe/linux/linux_time.h>
49 
50 /* Include all architecture-dependent time API headers */
51 #include <bits/time.h>
52 
53 extern signed long time_offset;
54 
55 /**
56  * Get current time in seconds (ignoring system clock offset)
57  *
58  * @ret time Time, in seconds
59  */
60 time_t time_now ( void );
61 
62 /**
63  * Adjust system clock
64  *
65  * @v delta Clock adjustment, in seconds
66  */
67 static inline __attribute__ (( always_inline )) void
68 time_adjust ( signed long delta ) {
69 
70  time_offset += delta;
71 }
72 
73 #endif /* _IPXE_TIME_H */
signed long time_offset
Current system clock offset.
Definition: time.c:47
iPXE internal APIs
Date and time.
x86-specific time API implementations
EFI time source.
time_t time_now(void)
Get current time in seconds (ignoring system clock offset)
Nonexistent time source.
Linux time source.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static __attribute__((always_inline)) void time_adjust(signed long delta)
Adjust system clock.
Definition: time.h:67
Time API configuration.
int64_t time_t
Seconds since the Epoch.
Definition: time.h:18