blob: dd5c6e5f02e1fba560f444b6523992a8ea302ff3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#include <sys/types.h>
#include <sys/sysctl.h>
#include <sys/time.h>
#include <time.h>
int main() {
#if defined(CTL_KERN) && defined(KERN_BOOTTIME)
/* FreeBSD specific: fetch sysctl "kern.boottime". */
struct timeval res = { 0, 0 };
int req[2] = { CTL_KERN, KERN_BOOTTIME };
size_t res_len = sizeof res;
if (sysctl(req, 2, &res, &res_len, 0, 0) >= 0 && res.tv_sec > 0)
return 0;
#else
return -1;
#endif
}
|