aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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. */
39#include <unistd.h> 39#include <unistd.h>
40#endif 40#endif
41 41
42#ifdef __FreeBSD__
43#include <sys/time.h>
44#include <sys/types.h>
45#include <sys/sysctl.h>
46#endif /* __FreeBSD__ */
47
42#include "lisp.h" 48#include "lisp.h"
43#include "buffer.h" 49#include "buffer.h"
44#include "charset.h" 50#include "charset.h"
@@ -142,6 +148,23 @@ get_boot_time ()
142 /* Otherwise, try again to read the uptime. */ 148 /* Otherwise, try again to read the uptime. */
143 time_before = after; 149 time_before = after;
144 } 150 }
151#if defined (CTL_KERN) && defined (KERN_BOOTTIME)
152 {
153 int mib[2];
154 size_t size;
155 struct timeval boottime_val;
156
157 mib[0] = CTL_KERN;
158 mib[1] = KERN_BOOTTIME;
159 size = sizeof (boottime_val);
160
161 if (sysctl (mib, 2, &boottime_val, &size, NULL, 0) >= 0)
162 {
163 boot_time = boottime_val.tv_sec;
164 return boot_time;
165 }
166 }
167#endif /* defined (CTL_KERN) && defined (KERN_BOOTTIME) */
145 168
146 /* Try to get boot time from the current wtmp file. */ 169 /* Try to get boot time from the current wtmp file. */
147 get_boot_time_1 (WTMP_FILE); 170 get_boot_time_1 (WTMP_FILE);