From: Karl Heuer Date: Mon, 1 Mar 1999 03:50:34 +0000 (+0000) Subject: (get_boot_time): Support FreeBSD way to read boot-time. X-Git-Tag: emacs-20.4~525 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f805a125e14bc40a5f86ae3bbcf6eb6d72f4b917;p=emacs.git (get_boot_time): Support FreeBSD way to read boot-time. --- 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 #endif +#ifdef __FreeBSD__ +#include +#include +#include +#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);