1 /* Determine the time when the machine last booted.
2 Copyright (C) 2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published
6 by the Free Software Foundation, either version 3 of the License,
7 or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17 /* Written by Bruno Haible <bruno@clisp.org>. */
18
19 #ifndef _BOOT_TIME_H
20 #define _BOOT_TIME_H
21
22 #include <time.h>
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28
29 /* Store the approximate time when the machine last booted in *P_BOOT_TIME,
30 and return 0. If it cannot be determined, return -1.
31
32 This function is not multithread-safe, since on many platforms it
33 invokes the functions setutxent, getutxent, endutxent. These
34 functions are needed because they may lock FILE (so that we don't
35 read garbage when a concurrent process writes to FILE), but their
36 drawback is that they have a common global state. */
37 extern int get_boot_time (struct timespec *p_boot_time);
38
39
40 #ifdef __cplusplus
41 }
42 #endif
43
44 #endif /* _BOOT_TIME_H */