]> Savannah Git Hosting - gnulib.git/commitdiff
readutmp: Small changes to reduce the code size on the coreutils side.
authorBruno Haible <bruno@clisp.org>
Tue, 1 Aug 2023 22:56:25 +0000 (00:56 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 1 Aug 2023 22:56:25 +0000 (00:56 +0200)
* 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.

ChangeLog
lib/readutmp.h
m4/readutmp.m4

index 16bf75a66df2896bb12961fc559f29a257a98ff6..e7fd56e6099f1a00457c2ac2e121907060839440 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+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.
index e03e0b0a323c056ce6ecbd6bfe1c8b3b89c162cd..06d2a69daf48bffaf7a17c24628741d4040bc384 100644 (file)
@@ -252,12 +252,39 @@ struct gl_utmp
       || 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.  */
index 2dfd3fe8d055149ab4b88fb0675c69fc242d251b..a4b1cb46426bdf9a8492b9f43ca035b17d947e45 100644 (file)
@@ -1,4 +1,4 @@
-# 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,
@@ -78,6 +78,8 @@ AC_INCLUDES_DEFAULT
     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])