summaryrefslogtreecommitdiffstats
path: root/src/include/ipxe/time.h
diff options
context:
space:
mode:
authorMichael Brown2012-03-19 17:59:53 +0100
committerMichael Brown2012-03-19 23:13:27 +0100
commit846bde90e6b1001480016fa46a957a9e726af68a (patch)
treecf3dfaaef4c90864c11c707482fde92f49b4abf7 /src/include/ipxe/time.h
parent[test] Add self-tests for mktime() (diff)
downloadipxe-846bde90e6b1001480016fa46a957a9e726af68a.tar.gz
ipxe-846bde90e6b1001480016fa46a957a9e726af68a.tar.xz
ipxe-846bde90e6b1001480016fa46a957a9e726af68a.zip
[time] Define an API for getting the current time
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe/time.h')
-rw-r--r--src/include/ipxe/time.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/include/ipxe/time.h b/src/include/ipxe/time.h
new file mode 100644
index 000000000..c74959f8e
--- /dev/null
+++ b/src/include/ipxe/time.h
@@ -0,0 +1,58 @@
+#ifndef _IPXE_TIME_H
+#define _IPXE_TIME_H
+
+/** @file
+ *
+ * Time source
+ *
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <sys/time.h>
+#include <ipxe/api.h>
+#include <config/time.h>
+
+/**
+ * Calculate static inline time API function name
+ *
+ * @v _prefix Subsystem prefix
+ * @v _api_func API function
+ * @ret _subsys_func Subsystem API function
+ */
+#define TIME_INLINE( _subsys, _api_func ) \
+ SINGLE_API_INLINE ( TIME_PREFIX_ ## _subsys, _api_func )
+
+/**
+ * Provide a time API implementation
+ *
+ * @v _prefix Subsystem prefix
+ * @v _api_func API function
+ * @v _func Implementing function
+ */
+#define PROVIDE_TIME( _subsys, _api_func, _func ) \
+ PROVIDE_SINGLE_API ( TIME_PREFIX_ ## _subsys, _api_func, _func )
+
+/**
+ * Provide a static inline time API implementation
+ *
+ * @v _prefix Subsystem prefix
+ * @v _api_func API function
+ */
+#define PROVIDE_TIME_INLINE( _subsys, _api_func ) \
+ PROVIDE_SINGLE_API_INLINE ( TIME_PREFIX_ ## _subsys, _api_func )
+
+/* Include all architecture-independent time API headers */
+#include <ipxe/null_time.h>
+
+/* Include all architecture-dependent time API headers */
+#include <bits/time.h>
+
+/**
+ * Get current time in seconds
+ *
+ * @ret time Time, in seconds
+ */
+time_t time_now ( void );
+
+#endif /* _IPXE_TIME_H */