- EMACS_GET_TIME (time_before);
-
- /* Try calculating the last boot time
- from the uptime as obtained from /proc/uptime. */
-
- while ((fd = open ("/proc/uptime", O_RDONLY)) >= 0)
- {
- char buf[100];
- int res;
- double upsecs;
- time_t uptime;
-
- read (fd, buf, sizeof buf);
- close (fd);
-
- res = sscanf (buf, "%lf", &upsecs);
-
- /* If the current time did not tick while we were getting the
- uptime, we have a valid result. */
- EMACS_GET_TIME (after);
- if (res == 1 && EMACS_SECS (after) == EMACS_SECS (time_before))
- {
- boot_time = EMACS_SECS (time_before) - (time_t) upsecs;
- return boot_time;
- }
-
- /* Otherwise, try again to read the uptime. */
- time_before = after;
- }