]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[time] Add Linux time source using gettimeofday()
authorMichael Brown <mcb30@ipxe.org>
Fri, 4 May 2012 16:53:23 +0000 (17:53 +0100)
committerMichael Brown <mcb30@ipxe.org>
Fri, 4 May 2012 16:54:31 +0000 (17:54 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/config/defaults/linux.h
src/include/ipxe/linux/linux_time.h [new file with mode: 0644]
src/include/ipxe/time.h
src/include/linux_api.h
src/interface/linux/linux_time.c [new file with mode: 0644]

index 58c73c381a43ae4a83ed9a6407e01731e2c26307..50897560d6dab58f7aca79c568cf39a1fd327479 100644 (file)
@@ -15,7 +15,7 @@
 #define SMBIOS_LINUX
 #define SANBOOT_NULL
 #define ENTROPY_LINUX
-#define TIME_NULL
+#define TIME_LINUX
 
 #define DRIVERS_LINUX
 
diff --git a/src/include/ipxe/linux/linux_time.h b/src/include/ipxe/linux/linux_time.h
new file mode 100644 (file)
index 0000000..93a2577
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef _IPXE_LINUX_TIME_H
+#define _IPXE_LINUX_TIME_H
+
+/** @file
+ *
+ * Linux time source
+ *
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#ifdef TIME_LINUX
+#define TIME_PREFIX_linux
+#else
+#define TIME_PREFIX_linux __linux_
+#endif
+
+#endif /* _IPXE_LINUX_TIME_H */
index c74959f8e9de201e323e4aca0369c028df7ec10e..673fe098aca09e8bdad72acc676ba308350d2562 100644 (file)
@@ -44,6 +44,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
 
 /* Include all architecture-independent time API headers */
 #include <ipxe/null_time.h>
+#include <ipxe/linux/linux_time.h>
 
 /* Include all architecture-dependent time API headers */
 #include <bits/time.h>
index 066cdd305eeec77c2707e0df6e490762c9ea4aae..94dc991f05615bb679260fb5c8bec0d1b204a9c5 100644 (file)
@@ -37,7 +37,6 @@ FILE_LICENCE(GPL2_OR_LATER);
 #include <linux/types.h>
 #include <linux/posix_types.h>
 typedef __kernel_pid_t pid_t;
-typedef __kernel_time_t time_t;
 typedef __kernel_suseconds_t suseconds_t;
 typedef __kernel_loff_t loff_t;
 #include <linux/time.h>
diff --git a/src/interface/linux/linux_time.c b/src/interface/linux/linux_time.c
new file mode 100644 (file)
index 0000000..6d722aa
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+/** @file
+ *
+ * Linux time source
+ *
+ */
+
+#include <stdint.h>
+#include <errno.h>
+#include <linux_api.h>
+#include <ipxe/time.h>
+
+/**
+ * Get current time in seconds
+ *
+ * @ret time           Time, in seconds
+ */
+static time_t linux_now ( void ) {
+       struct timeval now;
+
+       linux_gettimeofday ( &now, NULL );
+       return now.tv_sec;
+}
+
+PROVIDE_TIME ( linux, time_now, linux_now );