iPXE
time.h
Go to the documentation of this file.
00001 #ifndef _IPXE_TIME_H
00002 #define _IPXE_TIME_H
00003 
00004 /** @file
00005  *
00006  * Time source
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <sys/time.h>
00013 #include <ipxe/api.h>
00014 #include <config/time.h>
00015 
00016 /**
00017  * Calculate static inline time API function name
00018  *
00019  * @v _prefix           Subsystem prefix
00020  * @v _api_func         API function
00021  * @ret _subsys_func    Subsystem API function
00022  */
00023 #define TIME_INLINE( _subsys, _api_func ) \
00024         SINGLE_API_INLINE ( TIME_PREFIX_ ## _subsys, _api_func )
00025 
00026 /**
00027  * Provide a time API implementation
00028  *
00029  * @v _prefix           Subsystem prefix
00030  * @v _api_func         API function
00031  * @v _func             Implementing function
00032  */
00033 #define PROVIDE_TIME( _subsys, _api_func, _func ) \
00034         PROVIDE_SINGLE_API ( TIME_PREFIX_ ## _subsys, _api_func, _func )
00035 
00036 /**
00037  * Provide a static inline time API implementation
00038  *
00039  * @v _prefix           Subsystem prefix
00040  * @v _api_func         API function
00041  */
00042 #define PROVIDE_TIME_INLINE( _subsys, _api_func ) \
00043         PROVIDE_SINGLE_API_INLINE ( TIME_PREFIX_ ## _subsys, _api_func )
00044 
00045 /* Include all architecture-independent time API headers */
00046 #include <ipxe/null_time.h>
00047 #include <ipxe/efi/efi_time.h>
00048 #include <ipxe/linux/linux_time.h>
00049 
00050 /* Include all architecture-dependent time API headers */
00051 #include <bits/time.h>
00052 
00053 extern signed long time_offset;
00054 
00055 /**
00056  * Get current time in seconds (ignoring system clock offset)
00057  *
00058  * @ret time            Time, in seconds
00059  */
00060 time_t time_now ( void );
00061 
00062 /**
00063  * Adjust system clock
00064  *
00065  * @v delta             Clock adjustment, in seconds
00066  */
00067 static inline __attribute__ (( always_inline )) void
00068 time_adjust ( signed long delta ) {
00069 
00070         time_offset += delta;
00071 }
00072 
00073 #endif /* _IPXE_TIME_H */