changeset 24424:520e8f39c1f8

(get_boot_time): Support FreeBSD way to read boot-time.
author Karl Heuer <kwzh@gnu.org>
date Mon, 01 Mar 1999 03:50:34 +0000
parents 230bace6a57a
children 61c6b3be1d51
files src/filelock.c
diffstat 1 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/filelock.c	Mon Mar 01 03:50:00 1999 +0000
+++ b/src/filelock.c	Mon Mar 01 03:50:34 1999 +0000
@@ -39,6 +39,12 @@
 #include <unistd.h>
 #endif
 
+#ifdef __FreeBSD__
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#endif /* __FreeBSD__ */
+
 #include "lisp.h"
 #include "buffer.h"
 #include "charset.h"
@@ -142,6 +148,23 @@
       /* Otherwise, try again to read the uptime.  */
       time_before = after;
     }
+#if defined (CTL_KERN) && defined (KERN_BOOTTIME)
+  {
+    int mib[2];
+    size_t size;
+    struct timeval boottime_val;
+
+    mib[0] = CTL_KERN;
+    mib[1] = KERN_BOOTTIME;
+    size = sizeof (boottime_val);
+
+    if (sysctl (mib, 2, &boottime_val, &size, NULL, 0) >= 0)
+      {
+	boot_time = boottime_val.tv_sec;
+	return boot_time;
+      }
+  }
+#endif /* defined (CTL_KERN) && defined (KERN_BOOTTIME) */
 
   /* Try to get boot time from the current wtmp file.  */
   get_boot_time_1 (WTMP_FILE);