mirror of
https://https.git.savannah.gnu.org/git/coreutils.git
synced 2026-01-26 15:29:07 +00:00
build: uptime: avoid issues on systems without utmp.h
* src/uptime.c (print_uptime): Following gnulib commit 9041103 HAVE_UTMP_H will always be defined. Therefore key on whether the utmp.ut_type member is present. * boottime.m4 (GNULIB_BOOT_TIME): Assume utmp.h is present.
This commit is contained in:
parent
5699313c76
commit
2984e47c78
@ -27,7 +27,7 @@ AC_DEFUN([GNULIB_BOOT_TIME],
|
||||
[#if HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif]])
|
||||
AC_CHECK_HEADERS_ONCE([utmp.h utmpx.h OS.h])
|
||||
AC_CHECK_HEADERS_ONCE([utmpx.h OS.h])
|
||||
AC_CACHE_CHECK(
|
||||
[whether we can get the system boot time],
|
||||
[gnulib_cv_have_boot_time],
|
||||
@ -43,9 +43,8 @@ AC_DEFUN([GNULIB_BOOT_TIME],
|
||||
#endif
|
||||
#if HAVE_UTMPX_H
|
||||
# include <utmpx.h>
|
||||
#elif HAVE_UTMP_H
|
||||
# include <utmp.h>
|
||||
#endif
|
||||
#include <utmp.h>
|
||||
#if HAVE_OS_H
|
||||
# include <OS.h>
|
||||
#endif
|
||||
|
||||
@ -102,7 +102,7 @@ print_uptime (size_t n, const STRUCT_UTMP *this)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAVE_UTMPX_H || HAVE_UTMP_H
|
||||
#if HAVE_STRUCT_UTMP_UT_TYPE || HAVE_STRUCT_UTMPX_UT_TYPE
|
||||
/* Loop through all the utmp entries we just read and count up the valid
|
||||
ones, also in the process possibly gleaning boottime. */
|
||||
while (n--)
|
||||
@ -179,7 +179,7 @@ uptime (char const *filename, int options)
|
||||
size_t n_users;
|
||||
STRUCT_UTMP *utmp_buf = NULL;
|
||||
|
||||
#if HAVE_UTMPX_H || HAVE_UTMP_H
|
||||
#if HAVE_STRUCT_UTMP_UT_TYPE || HAVE_STRUCT_UTMPX_UT_TYPE
|
||||
if (read_utmp (filename, &n_users, &utmp_buf, options) != 0)
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (filename));
|
||||
#endif
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user