diff options
| author | Karl Heuer | 1999-03-01 03:50:34 +0000 |
|---|---|---|
| committer | Karl Heuer | 1999-03-01 03:50:34 +0000 |
| commit | f805a125e14bc40a5f86ae3bbcf6eb6d72f4b917 (patch) | |
| tree | 2873f8e76180651f6a3b4adeaf5e6738299e3b15 | |
| parent | 06d74a651259f7ca0d984f707abd1e658ff029d6 (diff) | |
| download | emacs-f805a125e14bc40a5f86ae3bbcf6eb6d72f4b917.tar.gz emacs-f805a125e14bc40a5f86ae3bbcf6eb6d72f4b917.zip | |
(get_boot_time): Support FreeBSD way to read boot-time.
| -rw-r--r-- | src/filelock.c | 23 |
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); |