}
# endif
+# if HAVE_DECL_SYSINFO /* not available in Android API < 9 */
/* The sysinfo call returns the uptime with a resolution of 1 sec only. */
struct sysinfo info;
if (sysinfo (&info) >= 0)
p_uptime->tv_nsec = 0;
return 0;
}
+# endif
return -1;
}
# include <time.h>
#endif
-#if HAVE_SYS_SYSCTL_H && !defined __minix
+#if HAVE_SYS_SYSCTL_H && !(defined __GLIBC__ && defined __linux__) && !defined __minix
# if HAVE_SYS_PARAM_H
# include <sys/param.h>
# endif
# define UT_USER(UT) ((UT)->ut_user)
#endif
-#if !HAVE_UTMPX_H && HAVE_UTMP_H && defined UTMP_NAME_FUNCTION && !HAVE_DECL_GETUTENT
-struct utmp *getutent (void);
+#if !HAVE_UTMPX_H && HAVE_UTMP_H && defined UTMP_NAME_FUNCTION
+# if !HAVE_DECL_ENDUTENT /* Android */
+void endutent (void);
+# endif
#endif
#if defined __linux__ || HAVE_UTMPX_H || HAVE_UTMP_H || defined __CYGWIN__ || defined _WIN32
# include <sys/param.h>
#endif
-#if HAVE_SYS_SYSCTL_H && ! defined __GLIBC__
+#if HAVE_SYS_SYSCTL_H && !(defined __GLIBC__ && defined __linux__)
# include <sys/sysctl.h>
#endif
/* Finally, as fallback, use the APIs that don't distinguish between
NPROC_CURRENT and NPROC_ALL. */
-#if HAVE_SYSCTL && ! defined __GLIBC__ && defined HW_NCPU
+#if HAVE_SYSCTL && !(defined __GLIBC__ && defined __linux__) && defined HW_NCPU
{ /* This works on macOS, FreeBSD, NetBSD, OpenBSD.
macOS 10.14 does not allow mib to be const. */
int nprocs;
# define WTMP_FILE "/etc/wtmp"
#endif
+/* In early versions of Android, <utmp.h> did not define BOOT_TIME, only
+ USER_PROCESS. We need to use the value that is defined in newer versions
+ of Android. */
+#if defined __ANDROID__ && !defined BOOT_TIME
+# define BOOT_TIME 2
+#endif
+
/* Some platforms, such as OpenBSD, don't have an ut_type field and don't have
the BOOT_TIME and USER_PROCESS macros. But we want to support them in
'struct gl_utmp'. */
-# readutmp.m4 serial 28
+# readutmp.m4 serial 30
dnl Copyright (C) 2002-2023 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
if test $ac_cv_header_utmp_h = yes || test $ac_cv_header_utmpx_h = yes; then
dnl Prerequisites of lib/readutmp.h and lib/readutmp.c.
AC_CHECK_FUNCS_ONCE([utmpname utmpxname])
- AC_CHECK_DECLS([getutent],,,[[
+ AC_CHECK_DECLS([endutent],,,[[
/* <sys/types.h> is a prerequisite of <utmp.h> on FreeBSD 8.0, OpenBSD 4.6. */
#include <sys/types.h>
#ifdef HAVE_UTMP_H
AC_CHECK_MEMBERS([struct utmp.ut_exit.e_termination],,,[$utmp_includes])
fi
+ AC_CHECK_DECLS([sysinfo],,,[[
+ #include <sys/sysinfo.h>
+ ]])
+
AC_CHECK_HEADERS_ONCE([sys/param.h])
dnl <sys/sysctl.h> requires <sys/param.h> on OpenBSD 4.0.
AC_CHECK_HEADERS([sys/sysctl.h],,,
-# stdint.m4 serial 61
+# stdint.m4 serial 62
dnl Copyright (C) 2001-2023 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
uintmax_t j = UINTMAX_MAX;
/* Check that SIZE_MAX has the correct type, if possible. */
-#if 201112 <= __STDC_VERSION__
+/* ISO C 11 mandates _Generic, but GCC versions < 4.9 lack it. */
+#if 201112 <= __STDC_VERSION__ \
+ && (!defined __GNUC__ || 4 < __GNUC__ + (9 <= __GNUC_MINOR__) \
+ || defined __clang__)
int k = _Generic (SIZE_MAX, size_t: 0);
#elif (2 <= __GNUC__ || 4 <= __clang_major__ || defined __IBM__TYPEOF__ \
|| (0x5110 <= __SUNPRO_C && !__STDC__))