+2023-08-01 Bruno Haible <bruno@clisp.org>
+
+ readutmp: Small changes to reduce the code size on the coreutils side.
+ * m4/readutmp.m4 (gl_READUTMP): Test also for the ut_host field in
+ 'struct utmpx' and 'struct utmp'.
+ * lib/readutmp.h (HAVE_STRUCT_XTMP_UT_HOST): New macro.
+ (UT_USER_SIZE): Define also as a macro. Set to -1 if
+ READUTMP_USE_SYSTEMD.
+ (UT_LINE_SIZE, UT_HOST_SIZE): New constants and macros.
+
2023-08-01 Bruno Haible <bruno@clisp.org>
readutmp: For year-2038 safety on Linux/{x86,arm}, use systemd APIs.
|| HAVE_STRUCT_UTMPX_UT_PID)
# endif
+# if READUTMP_USE_SYSTEMD
+# define HAVE_STRUCT_XTMP_UT_HOST 1
+# else
+# define HAVE_STRUCT_XTMP_UT_HOST \
+ (HAVE_STRUCT_UTMP_UT_HOST \
+ || HAVE_STRUCT_UTMPX_UT_HOST)
+# endif
+
/* Type of entry returned by read_utmp(). */
typedef struct UTMP_STRUCT_NAME STRUCT_UTMP;
-/* Size of the UT_USER (ut) member. */
-# if !READUTMP_USE_SYSTEMD
+/* Size of the UT_USER (ut) member, or -1 if unbounded. */
+# if READUTMP_USE_SYSTEMD
+enum { UT_USER_SIZE = -1 };
+# else
enum { UT_USER_SIZE = sizeof UT_USER ((STRUCT_UTMP *) 0) };
+# define UT_USER_SIZE UT_USER_SIZE
+# endif
+
+/* Size of the ut->ut_line member, or -1 if unbounded. */
+# if READUTMP_USE_SYSTEMD
+enum { UT_LINE_SIZE = -1 };
+# else
+enum { UT_LINE_SIZE = sizeof (((STRUCT_UTMP *) 0)->ut_line) };
+# define UT_LINE_SIZE UT_LINE_SIZE
+# endif
+
+/* Size of the ut->ut_host member, or -1 if unbounded. */
+# if READUTMP_USE_SYSTEMD
+enum { UT_HOST_SIZE = -1 };
+# else
+enum { UT_HOST_SIZE = sizeof (((STRUCT_UTMP *) 0)->ut_host) };
+# define UT_HOST_SIZE UT_HOST_SIZE
# endif
/* Definition of UTMP_FILE and WTMP_FILE. */
-# readutmp.m4 serial 21
+# readutmp.m4 serial 22
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,
AC_CHECK_MEMBERS([struct utmp.ut_type],,,[$utmp_includes])
AC_CHECK_MEMBERS([struct utmpx.ut_pid],,,[$utmp_includes])
AC_CHECK_MEMBERS([struct utmp.ut_pid],,,[$utmp_includes])
+ AC_CHECK_MEMBERS([struct utmpx.ut_host],,,[$utmp_includes])
+ AC_CHECK_MEMBERS([struct utmp.ut_host],,,[$utmp_includes])
AC_CHECK_MEMBERS([struct utmpx.ut_id],,,[$utmp_includes])
AC_CHECK_MEMBERS([struct utmp.ut_id],,,[$utmp_includes])
AC_CHECK_MEMBERS([struct utmpx.ut_exit],,,[$utmp_includes])