summaryrefslogtreecommitdiff
path: root/src/filelock.c
diff options
context:
space:
mode:
authorKarl Heuer <kwzh@gnu.org>1999-03-01 03:50:34 +0000
committerKarl Heuer <kwzh@gnu.org>1999-03-01 03:50:34 +0000
commitf805a125e14bc40a5f86ae3bbcf6eb6d72f4b917 (patch)
tree2873f8e76180651f6a3b4adeaf5e6738299e3b15 /src/filelock.c
parent06d74a651259f7ca0d984f707abd1e658ff029d6 (diff)
downloademacs-f805a125e14bc40a5f86ae3bbcf6eb6d72f4b917.tar.gz
(get_boot_time): Support FreeBSD way to read boot-time.
Diffstat (limited to 'src/filelock.c')
-rw-r--r--src/filelock.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/filelock.c b/src/filelock.c
index cfcf30f85ed..9ee09b4d072 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -39,6 +39,12 @@ Boston, MA 02111-1307, USA. */
#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 @@ get_boot_time ()
/* 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);