readutmp: Revisit portability.
authorBruno Haible <bruno@clisp.org>
Mon, 31 Jul 2023 18:33:48 +0000 (20:33 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 31 Jul 2023 18:34:41 +0000 (20:34 +0200)
* m4/readutmp.m4 (gl_READUTMP): Don't test for struct utmp.ut_exit.ut_*,
since no platform has these.
* lib/readutmp.h (UT_EXIT_E_TERMINATION): Don't test
HAVE_STRUCT_UTMP_UT_EXIT_UT_TERMINATION.
(UT_EXIT_E_EXIT): Don't test HAVE_STRUCT_UTMP_UT_EXIT_UT_EXIT.
* doc/posix-headers/utmpx.texi: Update platforms list. Mention
portability problems of specific 'struct utmpx' fields.
* doc/glibc-headers/utmp.texi: Update platforms list. Mention
portability problems of specific 'struct utmp' fields.

ChangeLog
doc/glibc-headers/utmp.texi
doc/posix-headers/utmpx.texi
lib/readutmp.h
m4/readutmp.m4

index a26958d8b8f28ac60d055c1a284a1d7a18097de5..dcd2cc58f2d5c69c1d5628446ef15e08fd1f31cb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2023-07-31  Bruno Haible  <bruno@clisp.org>
+
+       readutmp: Revisit portability.
+       * m4/readutmp.m4 (gl_READUTMP): Don't test for struct utmp.ut_exit.ut_*,
+       since no platform has these.
+       * lib/readutmp.h (UT_EXIT_E_TERMINATION): Don't test
+       HAVE_STRUCT_UTMP_UT_EXIT_UT_TERMINATION.
+       (UT_EXIT_E_EXIT): Don't test HAVE_STRUCT_UTMP_UT_EXIT_UT_EXIT.
+       * doc/posix-headers/utmpx.texi: Update platforms list. Mention
+       portability problems of specific 'struct utmpx' fields.
+       * doc/glibc-headers/utmp.texi: Update platforms list. Mention
+       portability problems of specific 'struct utmp' fields.
+
 2023-07-31  Bruno Haible  <bruno@clisp.org>
 
        readutmp: Make argument names consistent.
index 1e9d3757cb66479c0421ce11b44feb19d5f56e4a..f45037ae7491c29e108dcd0f81858f6f5ef04288 100644 (file)
@@ -23,7 +23,7 @@ Portability problems fixed by Gnulib:
 @itemize
 @item
 This header file is missing on some platforms:
-FreeBSD 13.0, mingw, MSVC 14.
+FreeBSD 13.2, mingw, MSVC 14.
 @item
 @code{<sys/types.h>} is a prerequisite of @code{<utmp.h>} on some platforms:
 FreeBSD 8.0, OpenBSD 7.2.
@@ -32,6 +32,26 @@ FreeBSD 8.0, OpenBSD 7.2.
 Portability problems not fixed by Gnulib:
 @itemize
 @item
+While some platforms have the @code{struct utmp} field @code{ut_user},
+older platforms have the field @code{ut_name}.
+@item
+The @code{struct utmp} fields @code{ut_id}, @code{ut_pid}, @code{ut_type}
+do not exist on some platforms:
+macOS, old FreeBSD, NetBSD, OpenBSD, Minix.
+@item
+The @code{struct utmp} field @code{ut_host} does not exist on some platforms:
+IRIX, Solaris.
+@item
+The @code{struct utmp} field @code{ut_exit} does not exist on some platforms:
+macOS, old FreeBSD, NetBSD, OpenBSD, Minix, Cygwin.
+@item
+The @code{struct utmp} field @code{ut_session} does not exist on some platforms:
+macOS, old FreeBSD, NetBSD, OpenBSD, Minix, AIX, HP-UX, IRIX, Solaris, Cygwin.
+@item
+The @code{struct utmp} field @code{ut_addr} or @code{ut_addr_v6} does not exist
+on some platforms:
+macOS, old FreeBSD, NetBSD, OpenBSD, Minix, AIX, IRIX, Solaris.
+@item
 On some platforms, this API does not support timestamps past the
 year 2038:
 glibc 2.38 on 32-bit platforms like x86 and ARM where @code{time_t}
index fd3d4d6ab7f610ad682b80c0abd6ba08a4785f4b..40efca3b6403e627b3f0865466f1559739759911 100644 (file)
@@ -13,7 +13,21 @@ Portability problems not fixed by Gnulib:
 @itemize
 @item
 This header file is missing on some platforms:
-FreeBSD 6.0, OpenBSD 6.7, Minix 3.1.8, mingw, MSVC 14, Android 9.0.
+FreeBSD 8.4, OpenBSD 7.2, Minix 3.1.8, mingw, MSVC 14, Android 13.0.
+@item
+While some platforms have the @code{struct utmpx} field @code{ut_user},
+older platforms have the field @code{ut_name}.
+@item
+The @code{struct utmpx} field @code{ut_exit} does not exist on some platforms:
+macOS, FreeBSD, AIX, Cygwin.
+@item
+The @code{struct utmpx} field @code{ut_session} does not exist
+on some platforms:
+macOS, FreeBSD, AIX, HP-UX, Cygwin.
+@item
+The @code{struct utmpx} field @code{ut_addr} or @code{ut_addr_v6} or
+@code{ut_ss} does not exist on some platforms:
+macOS, FreeBSD, AIX, IRIX, Solaris.
 @item
 On some platforms, this API does not support timestamps past the
 year 2038:
index 0ddd724c22fd311a995f1c6d8eb4c67ff9f41a3f..271dd4921a2b11bf39dfa32fc54e96d829566b35 100644 (file)
 
 # if HAVE_UTMPX_H
 
+/* <utmpx.h> defines 'struct utmpx' with the following fields:
+
+     Field        Type                       Platforms
+     ----------   ------                     ---------
+   ⎡ ut_user      char[]                     glibc, musl, macOS, FreeBSD, AIX, HP-UX, IRIX, Solaris, Cygwin
+   ⎣ ut_name      char[]                     NetBSD, Minix
+     ut_id        char[]                     glibc, musl, macOS, FreeBSD, NetBSD, Minix, AIX, HP-UX, IRIX, Solaris, Cygwin
+     ut_line      char[]                     glibc, musl, macOS, FreeBSD, NetBSD, Minix, AIX, HP-UX, IRIX, Solaris, Cygwin
+     ut_pid       pid_t                      glibc, musl, macOS, FreeBSD, NetBSD, Minix, AIX, HP-UX, IRIX, Solaris, Cygwin
+     ut_type      short                      glibc, musl, macOS, FreeBSD, NetBSD, Minix, AIX, HP-UX, IRIX, Solaris, Cygwin
+   ⎡ ut_tv        struct                     glibc, musl, macOS, FreeBSD, NetBSD, Minix, AIX, HP-UX, IRIX, Solaris, Cygwin
+   ⎢              { tv_sec; tv_usec; }
+   ⎣ ut_time      time_t                     Cygwin
+     ut_host      char[]                     glibc, musl, macOS, FreeBSD, NetBSD, Minix, AIX, HP-UX, IRIX, Solaris, Cygwin
+     ut_exit      struct                     glibc, musl, NetBSD, Minix, HP-UX, IRIX, Solaris
+                  { e_termination; e_exit; }
+     ut_session   [long] int                 glibc, musl, NetBSD, Minix, IRIX, Solaris
+   ⎡ ut_addr      [long] int                 HP-UX, Cygwin
+   ⎢ ut_addr_v6   [u]int[4]                  glibc, musl
+   ⎣ ut_ss        struct sockaddr_storage    NetBSD, Minix
+ */
+
 #  if HAVE_UTMP_H
     /* HPUX 10.20 needs utmp.h, for the definition of e.g., UTMP_FILE.  */
 #   include <utmp.h>
@@ -63,7 +85,7 @@
 #  if HAVE_STRUCT_UTMPX_UT_EXIT_E_TERMINATION
 #   define UT_EXIT_E_TERMINATION(UT) ((UT)->ut_exit.e_termination)
 #  else
-#   if HAVE_STRUCT_UTMPX_UT_EXIT_UT_TERMINATION
+#   if HAVE_STRUCT_UTMPX_UT_EXIT_UT_TERMINATION /* OSF/1 */
 #    define UT_EXIT_E_TERMINATION(UT) ((UT)->ut_exit.ut_termination)
 #   else
 #    define UT_EXIT_E_TERMINATION(UT) 0
@@ -73,7 +95,7 @@
 #  if HAVE_STRUCT_UTMPX_UT_EXIT_E_EXIT
 #   define UT_EXIT_E_EXIT(UT) ((UT)->ut_exit.e_exit)
 #  else
-#   if HAVE_STRUCT_UTMPX_UT_EXIT_UT_EXIT
+#   if HAVE_STRUCT_UTMPX_UT_EXIT_UT_EXIT /* OSF/1 */
 #    define UT_EXIT_E_EXIT(UT) ((UT)->ut_exit.ut_exit)
 #   else
 #    define UT_EXIT_E_EXIT(UT) 0
 
 # elif HAVE_UTMP_H
 
+/* <utmp.h> defines 'struct utmp' with the following fields:
+
+     Field        Type                       Platforms
+     ----------   ------                     ---------
+   ⎡ ut_user      char[]                     glibc, musl, AIX, HP-UX, IRIX, Solaris, Cygwin, Android
+   ⎣ ut_name      char[]                     macOS, old FreeBSD, NetBSD, OpenBSD, Minix
+     ut_id        char[]                     glibc, musl, AIX, HP-UX, IRIX, Solaris, Cygwin, Android
+     ut_line      char[]                     glibc, musl, macOS, old FreeBSD, NetBSD, OpenBSD, Minix, AIX, HP-UX, IRIX, Solaris, Cygwin, Android
+     ut_pid       pid_t                      glibc, musl, AIX, HP-UX, IRIX, Solaris, Cygwin, Android
+     ut_type      short                      glibc, musl, AIX, HP-UX, IRIX, Solaris, Cygwin, Android
+   ⎡ ut_tv        struct                     glibc, musl, Android
+   ⎢              { tv_sec; tv_usec; }
+   ⎣ ut_time      time_t                     macOS, old FreeBSD, NetBSD, OpenBSD, Minix, AIX, HP-UX, IRIX, Solaris, Cygwin
+     ut_host      char[]                     glibc, musl, macOS, old FreeBSD, NetBSD, OpenBSD, Minix, AIX, HP-UX, Cygwin, Android
+     ut_exit      struct                     glibc, musl, AIX, HP-UX, IRIX, Solaris, Android
+                  { e_termination; e_exit; }
+     ut_session   [long] int                 glibc, musl, Android
+   ⎡ ut_addr      [long] int                 HP-UX, Cygwin
+   ⎣ ut_addr_v6   [u]int[4]                  glibc, musl, Android
+ */
+
 #  include <utmp.h>
 #  if !HAVE_DECL_GETUTENT
     struct utmp *getutent (void);
 #  if HAVE_STRUCT_UTMP_UT_EXIT_E_TERMINATION
 #   define UT_EXIT_E_TERMINATION(UT) ((UT)->ut_exit.e_termination)
 #  else
-#   if HAVE_STRUCT_UTMP_UT_EXIT_UT_TERMINATION
-#    define UT_EXIT_E_TERMINATION(UT) ((UT)->ut_exit.ut_termination)
-#   else
-#    define UT_EXIT_E_TERMINATION(UT) 0
-#   endif
+#   define UT_EXIT_E_TERMINATION(UT) 0
 #  endif
 
 #  if HAVE_STRUCT_UTMP_UT_EXIT_E_EXIT
 #   define UT_EXIT_E_EXIT(UT) ((UT)->ut_exit.e_exit)
 #  else
-#   if HAVE_STRUCT_UTMP_UT_EXIT_UT_EXIT
-#    define UT_EXIT_E_EXIT(UT) ((UT)->ut_exit.ut_exit)
-#   else
-#    define UT_EXIT_E_EXIT(UT) 0
-#   endif
+#   define UT_EXIT_E_EXIT(UT) 0
 #  endif
 
 # else
index 82254d21e8cc0bd33b9b5ee63459e2b940bb9018..44fcc6151b318efb9b8744562d954f789cc3f654 100644 (file)
@@ -1,4 +1,4 @@
-# readutmp.m4 serial 20
+# readutmp.m4 serial 21
 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,
@@ -48,12 +48,10 @@ AC_INCLUDES_DEFAULT
     AC_CHECK_MEMBERS([struct utmp.ut_exit],,,[$utmp_includes])
 
     AC_CHECK_MEMBERS([struct utmpx.ut_exit.ut_exit],,,[$utmp_includes])
-    AC_CHECK_MEMBERS([struct utmp.ut_exit.ut_exit],,,[$utmp_includes])
     AC_CHECK_MEMBERS([struct utmpx.ut_exit.e_exit],,,[$utmp_includes])
     AC_CHECK_MEMBERS([struct utmp.ut_exit.e_exit],,,[$utmp_includes])
 
     AC_CHECK_MEMBERS([struct utmpx.ut_exit.ut_termination],,,[$utmp_includes])
-    AC_CHECK_MEMBERS([struct utmp.ut_exit.ut_termination],,,[$utmp_includes])
     AC_CHECK_MEMBERS([struct utmpx.ut_exit.e_termination],,,[$utmp_includes])
     AC_CHECK_MEMBERS([struct utmp.ut_exit.e_termination],,,[$utmp_includes])
   fi