This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[glibc/zack/no-nested-includes] Don’t include sys/types.h 3/n: utmp{,x}.h


https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=8fb0f23ba17c484d62f55ff99e714ef940058156

commit 8fb0f23ba17c484d62f55ff99e714ef940058156
Author: Zack Weinberg <zackw@panix.com>
Date:   Wed May 22 15:37:30 2019 -0400

    Donâ??t include sys/types.h 3/n: utmp{,x}.h
    
    utmp.h and utmpx.h are also set up for system-dependence that is no
    longer necessary.  In fact, I think we might be able to fold their
    respective bits headers into the primary headers and make them not
    system-dependent at all.  The remaining variation is between
    s390*-*-linux* and everything else, and it appears to me that the s390
    versions of the bits headers are actually the headers that everyone
    should be using.  The only difference is that the s390 headers
    unconditionally use 64-bit quantities for lastlog.ll_time,
    utmp{,x}.ut_tv, and utmp{,x}.ut_session, whereas the generic headers
    use either 64- or 32-bit quantities depending on __WORDSIZE_TIME64_COMPAT32.
    I could be wrong, but I donâ??t think it makes sense for programs with
    64-bit and 32-bit time_t to have different ideas of the layout of a
    structures that are copied directly to and from a shared file on disk.
    
    Anyway, I didnâ??t fix that now; it should be its own patch.  What I did
    do, in addition to pruning the headers included by utmp.h, utmpx.h,
    bits/utmp.h, and bits/utmpx.h, is some cleanup of a distinction
    between GNU and non-GNU systems that is no longer relevant.  This
    patch is smaller than it looks, because git doesnâ??t understand what
    actually happened with bits/utmp.h and sysdeps/gnu/bits/utmp.h.  The
    true set of deletions and renames is:
    
      rm bits/utmp.h
      mv sysdeps/gnu/bits/utmp.h bits/utmp.h
      mv sysdeps/gnu/bits/utmpx.h bits/utmpx.h
      mv sysdeps/gnu/utmpx.h login/utmpx.h
    
    I also made the inclusion of utmpx.h and the utmpx routines
    unconditional in login/Makefile.
    
    	* bits/utmp.h: Delete file.
            * sysdeps/gnu/bits/utmp.h: Move to bits/utmp.h.
            Add multiple include guard.
            Donâ??t include paths.h, sys/time.h, or sys/types.h.
            Donâ??t use struct timeval.
            Use __intN_t for consistency with bits/utmpx.h.
            * sysdeps/unix/sysv/linux/s390/bits/utmp.h: Add multiple include guard.
            Donâ??t include paths.h, sys/time.h, sys/types.h, or bits/wordsize.h.
            Donâ??t use struct timeval.
            Use __intN_t for consistency with bits/utmpx.h.
            Use __time64_t unconditionally for lastlog.ll_time.
            Use __int64_t unconditionally for utmp.ut_session.
            Adjust indentation and blank lines to match bits/utmp.h.
    
            * sysdeps/gnu/bits/utmpx.h: Move to bits/utmpx.h.
            Add multiple include guard.
            Donâ??t include paths.h, sys/time.h, bits/types.h, or bits/wordsize.h.
            Donâ??t define _PATH_UTMPX or _PATH_WTMPX.
            Donâ??t use struct timeval.
            Use pid_t for consistency with bits/utmp.h.
            * sysdeps/unix/sysv/linux/s390/bits/utmpx.h: Add multiple include guard.
            Donâ??t define _PATH_UTMPX or _PATH_WTMPX.
            Donâ??t include paths.h, sys/time.h, bits/types.h, or bits/wordsize.h.
            Donâ??t define _PATH_UTMPX or _PATH_WTMPX.
            Donâ??t use struct timeval.
            Use pid_t for consistency with bits/utmp.h.
            Use __int64_t unconditionally for utmpx.ut_session.
    
            * login/utmp.h: Donâ??t include sys/types.h.
            Do include paths.h, bits/types.h, bits/types/pid_t.h, and
            bits/types/struct_timeval.h.
            Move __BEGIN_DECLS to enclose only prototypes.
            * sysdeps/gnu/utmpx.h: Move to login/utmpx.h.
            Donâ??t include sys/time.h.
            Do include bits/types.h and bits/types/struct_timeval.h.
            When __USE_GNU, include paths.h and define _PATH_UTMPX and _PATH_WTMPX.
    
            * login/Makefile (headers): Add utmpx.h and bits/utmpx.h.
            (routines): Add endutxent, getutmp, getutmpx, getutxent,
            getutxid, getutxline, pututxline, setutxent, updwtmpx, and
            utmpxname.  Reorganize.
            * sysdeps/gnu/Makefile: Do not add anything to sysdep_routines
            or sysdep_headers when subdir == login.
    
            * scripts/check-obsolete-constructs.py (HEADER_ALLOWED_INCLUDES): Update.

Diff:
---
 bits/utmp.h                               | 113 +++++++++++++++++++++++----
 {sysdeps/gnu/bits => bits}/utmpx.h        |  35 ++++-----
 include/utmpx.h                           |   1 +
 login/Makefile                            |  15 ++--
 login/utmp.h                              |  13 +--
 {sysdeps/gnu => login}/utmpx.h            |   7 +-
 scripts/check-obsolete-constructs.py      |   6 +-
 sysdeps/gnu/Makefile                      |   7 --
 sysdeps/gnu/bits/utmp.h                   | 126 ------------------------------
 sysdeps/unix/sysv/linux/s390/bits/utmp.h  |  43 +++++-----
 sysdeps/unix/sysv/linux/s390/bits/utmpx.h |  34 +++-----
 11 files changed, 172 insertions(+), 228 deletions(-)

diff --git a/bits/utmp.h b/bits/utmp.h
index 4c36ca1..3d593e0 100644
--- a/bits/utmp.h
+++ b/bits/utmp.h
@@ -1,4 +1,4 @@
-/* The `struct utmp' type, describing entries in the utmp file.  Generic/BSDish
+/* The `struct utmp' type, describing entries in the utmp file.  GNU version.
    Copyright (C) 1993-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -16,34 +16,119 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_UTMP_H
+#define _BITS_UTMP_H 1
+
 #ifndef _UTMP_H
 # error "Never include <bits/utmp.h> directly; use <utmp.h> instead."
 #endif
 
-#include <paths.h>
-#include <time.h>
+#include <bits/wordsize.h>
 
 
-#define	UT_NAMESIZE	8
-#define	UT_LINESIZE	8
-#define	UT_HOSTSIZE	16
+#define UT_LINESIZE	32
+#define UT_NAMESIZE	32
+#define UT_HOSTSIZE	256
 
 
+/* The structure describing an entry in the database of
+   previous logins.  */
 struct lastlog
   {
-    time_t ll_time;
+#if __WORDSIZE_TIME64_COMPAT32
+    __int32_t ll_time;
+#else
+    __time_t ll_time;
+#endif
     char ll_line[UT_LINESIZE];
     char ll_host[UT_HOSTSIZE];
   };
 
-struct utmp
+
+/* The structure describing the status of a terminated process.  This
+   type is used in `struct utmp' below.  */
+struct exit_status
   {
-    char ut_line[UT_LINESIZE];
-    char ut_user[UT_NAMESIZE];
-#define ut_name ut_user
-    char ut_host[UT_HOSTSIZE];
-    long int ut_time;
+    short int e_termination;	/* Process termination status.  */
+    short int e_exit;		/* Process exit status.  */
   };
 
 
-#define _HAVE_UT_HOST 1		/* We have the ut_host field.  */
+/* The structure describing an entry in the user accounting database.  */
+struct utmp
+{
+  short int ut_type;		/* Type of login.  */
+  pid_t ut_pid;			/* Process ID of login process.  */
+  char ut_line[UT_LINESIZE]
+    __attribute_nonstring__;	/* Devicename.  */
+  char ut_id[4];		/* Inittab ID.  */
+  char ut_user[UT_NAMESIZE]
+    __attribute_nonstring__;	/* Username.  */
+  char ut_host[UT_HOSTSIZE]
+    __attribute_nonstring__;	/* Hostname for remote login.  */
+  struct exit_status ut_exit;	/* Exit status of a process marked
+				   as DEAD_PROCESS.  */
+
+/* The ut_session and ut_tv fields must be the same size when compiled
+   32- and 64-bit.  This allows data files and shared memory to be
+   shared between 32- and 64-bit applications.  Even on 64-bit systems,
+   struct timeval is not guaranteed to have both fields be 64 bits.  */
+#if __WORDSIZE_TIME64_COMPAT32
+  __int32_t ut_session;		/* Session ID, used for windowing.  */
+  struct
+  {
+    __int32_t tv_sec;		/* Seconds.  */
+    __int32_t tv_usec;		/* Microseconds.  */
+  } ut_tv;			/* Time entry was made.  */
+#else
+  __int64_t ut_session;		/* Session ID, used for windowing.  */
+  struct
+  {
+    __int64_t tv_sec;		/* Seconds.  */
+    __int64_t tv_usec;		/* Microseconds.  */
+  } ut_tv;			/* Time entry was made.  */
+#endif
+
+  __int32_t ut_addr_v6[4];	/* Internet address of remote host.  */
+  char __glibc_reserved[20];	/* Reserved for future use.  */
+};
+
+/* Backwards compatibility hacks.  */
+#define ut_name		ut_user
+#ifndef _NO_UT_TIME
+/* We have a problem here: `ut_time' is also used otherwise.  Define
+   _NO_UT_TIME if the compiler complains.  */
+# define ut_time	ut_tv.tv_sec
+#endif
+#define ut_xtime	ut_tv.tv_sec
+#define ut_addr		ut_addr_v6[0]
+
+
+/* Values for the `ut_type' field of a `struct utmp'.  */
+#define EMPTY		0	/* No valid user accounting information.  */
+
+#define RUN_LVL		1	/* The system's runlevel.  */
+#define BOOT_TIME	2	/* Time of system boot.  */
+#define NEW_TIME	3	/* Time after system clock changed.  */
+#define OLD_TIME	4	/* Time when system clock changed.  */
+
+#define INIT_PROCESS	5	/* Process spawned by the init process.  */
+#define LOGIN_PROCESS	6	/* Session leader of a logged in user.  */
+#define USER_PROCESS	7	/* Normal process.  */
+#define DEAD_PROCESS	8	/* Terminated process.  */
+
+#define ACCOUNTING	9
+
+/* Old Linux name for the EMPTY type.  */
+#define UT_UNKNOWN	EMPTY
+
+
+/* Tell the user that we have a modern system with UT_HOST, UT_PID,
+   UT_TYPE, UT_ID and UT_TV fields.  */
+#define _HAVE_UT_TYPE	1
+#define _HAVE_UT_PID	1
+#define _HAVE_UT_ID	1
+#define _HAVE_UT_TV	1
+#define _HAVE_UT_HOST	1
+
+#endif /* bits/utmp.h */
diff --git a/sysdeps/gnu/bits/utmpx.h b/bits/utmpx.h
similarity index 82%
rename from sysdeps/gnu/bits/utmpx.h
rename to bits/utmpx.h
index 472a7d5..ac4a532 100644
--- a/sysdeps/gnu/bits/utmpx.h
+++ b/bits/utmpx.h
@@ -16,22 +16,13 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_UTMPX_H
+#define _BITS_UTMPX_H 1
+
 #ifndef _UTMPX_H
 # error "Never include <bits/utmpx.h> directly; use <utmpx.h> instead."
 #endif
 
-#include <bits/types.h>
-#include <sys/time.h>
-#include <bits/wordsize.h>
-
-
-#ifdef __USE_GNU
-# include <paths.h>
-# define _PATH_UTMPX	_PATH_UTMP
-# define _PATH_WTMPX	_PATH_WTMP
-#endif
-
-
 #define __UT_LINESIZE	32
 #define __UT_NAMESIZE	32
 #define __UT_HOSTSIZE	256
@@ -55,7 +46,7 @@ struct __exit_status
 struct utmpx
 {
   short int ut_type;		/* Type of login.  */
-  __pid_t ut_pid;		/* Process ID of login process.  */
+  pid_t ut_pid;			/* Process ID of login process.  */
   char ut_line[__UT_LINESIZE];	/* Devicename.  */
   char ut_id[4];		/* Inittab ID. */
   char ut_user[__UT_NAMESIZE];	/* Username.  */
@@ -63,9 +54,10 @@ struct utmpx
   struct __exit_status ut_exit;	/* Exit status of a process marked
 				   as DEAD_PROCESS.  */
 
-/* The fields ut_session and ut_tv must be the same size when compiled
-   32- and 64-bit.  This allows files and shared memory to be shared
-   between 32- and 64-bit applications.  */
+/* The ut_session and ut_tv fields must be the same size when compiled
+   32- and 64-bit.  This allows data files and shared memory to be
+   shared between 32- and 64-bit applications.  Even on 64-bit systems,
+   struct timeval is not guaranteed to have both fields be 64 bits.  */
 #if __WORDSIZE_TIME64_COMPAT32
   __int32_t ut_session;		/* Session ID, used for windowing.  */
   struct
@@ -74,9 +66,14 @@ struct utmpx
     __int32_t tv_usec;		/* Microseconds.  */
   } ut_tv;			/* Time entry was made.  */
 #else
-  long int ut_session;		/* Session ID, used for windowing.  */
-  struct timeval ut_tv;		/* Time entry was made.  */
+  __int64_t ut_session;		/* Session ID, used for windowing.  */
+  struct
+  {
+    __int64_t tv_sec;		/* Seconds.  */
+    __int64_t tv_usec;		/* Microseconds.  */
+  } ut_tv;			/* Time entry was made.  */
 #endif
+
   __int32_t ut_addr_v6[4];	/* Internet address of remote host.  */
   char __glibc_reserved[20];		/* Reserved for future use.  */
 };
@@ -100,3 +97,5 @@ struct utmpx
 #ifdef __USE_GNU
 # define ACCOUNTING	9	/* System accounting.  */
 #endif
+
+#endif /* bits/utmpx.h */
diff --git a/include/utmpx.h b/include/utmpx.h
new file mode 100644
index 0000000..cfe9b7c
--- /dev/null
+++ b/include/utmpx.h
@@ -0,0 +1 @@
+#include <login/utmpx.h>
diff --git a/login/Makefile b/login/Makefile
index 92535f0..e9bdd1a 100644
--- a/login/Makefile
+++ b/login/Makefile
@@ -23,12 +23,15 @@ subdir	:= login
 
 include ../Makeconfig
 
-headers	:= utmp.h bits/utmp.h lastlog.h pty.h
-
-routines := getlogin getlogin_r setlogin getlogin_r_chk \
-	    getutent getutent_r getutid getutline getutid_r getutline_r \
-	    utmp_file utmpname updwtmp getpt grantpt unlockpt ptsname \
-	    ptsname_r_chk
+headers	:= utmp.h bits/utmp.h utmpx.h bits/utmpx.h lastlog.h pty.h
+
+routines :=								\
+	getlogin getlogin_r getlogin_r_chk setlogin			\
+	getpt grantpt ptsname ptsname_r_chk unlockpt			\
+	getutent getutent_r getutid getutid_r getutline getutline_r	\
+	getutmp updwtmp utmp_file utmpname				\
+	endutxent getutmpx getutxent getutxid getutxline pututxline	\
+	setutxent updwtmpx utmpxname
 
 CFLAGS-grantpt.c += -DLIBEXECDIR='"$(libexecdir)"'
 
diff --git a/login/utmp.h b/login/utmp.h
index 168c159..a689322 100644
--- a/login/utmp.h
+++ b/login/utmp.h
@@ -20,21 +20,24 @@
 
 #include <features.h>
 
-#include <sys/types.h>
-
-
-__BEGIN_DECLS
+/* utmp.h is not standardized; utmpx.h is, and is required to define
+   pid_t and struct timeval.  It makes sense for utmp.h to be
+   consistent.  */
+#include <bits/types.h>
+#include <bits/types/pid_t.h>
+#include <bits/types/struct_timeval.h>
 
 /* Get system dependent values and data structures.  */
 #include <bits/utmp.h>
 
 /* Compatibility names for the strings of the canonical file names.  */
+#include <paths.h>
 #define UTMP_FILE	_PATH_UTMP
 #define UTMP_FILENAME	_PATH_UTMP
 #define WTMP_FILE	_PATH_WTMP
 #define WTMP_FILENAME	_PATH_WTMP
 
-
+__BEGIN_DECLS
 
 /* Make FD be the controlling terminal, stdin, stdout, and stderr;
    then close FD.  Returns 0 on success, nonzero on error.  */
diff --git a/sysdeps/gnu/utmpx.h b/login/utmpx.h
similarity index 96%
rename from sysdeps/gnu/utmpx.h
rename to login/utmpx.h
index 41c122d..c2887b2 100644
--- a/sysdeps/gnu/utmpx.h
+++ b/login/utmpx.h
@@ -19,15 +19,20 @@
 #define	_UTMPX_H	1
 
 #include <features.h>
-#include <sys/time.h>
 
 /* Required according to Unix98.  */
+#include <bits/types.h>
 #include <bits/types/pid_t.h>
+#include <bits/types/struct_timeval.h>
 
 /* Get system dependent values and data structures.  */
 #include <bits/utmpx.h>
 
 #ifdef __USE_GNU
+# include <paths.h>
+# define _PATH_UTMPX	_PATH_UTMP
+# define _PATH_WTMPX	_PATH_WTMP
+
 /* Compatibility names for the strings of the canonical file names.  */
 # define UTMPX_FILE	_PATH_UTMPX
 # define UTMPX_FILENAME	_PATH_UTMPX
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index e545bfa..1548999 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -531,6 +531,7 @@ HEADER_ALLOWED_INCLUDES = {
     "sched.h":                     [ "time.h" ],
     "spawn.h":                     [ "sched.h" ],
     "termios.h":                   [ "sys/ttydefaults.h" ],
+    "utmpx.h":                     [ "paths.h" ],
 
     # POSIX sys/ headers
     # mandated: sys/msg.h -> sys/ipc.h
@@ -585,8 +586,7 @@ HEADER_ALLOWED_INCLUDES = {
     "thread_db.h":                 [ "pthread.h", "stdint.h", "sys/procfs.h",
                                      "sys/types.h" ],
     "ucontext.h":                  [ "sys/ucontext.h" ],
-    "utmp.h":                      [ "sys/types.h" ],
-    "utmpx.h":                     [ "sys/time.h" ],
+    "utmp.h":                      [ "paths.h" ],
     "values.h":                    [ "float.h", "limits.h" ],
     "wait.h":                      [ "sys/wait.h" ],
 
@@ -689,8 +689,6 @@ HEADER_ALLOWED_INCLUDES = {
     "bits/sem.h":                  [ "sys/types.h" ],
     "bits/socket.h":               [ "sys/types.h" ],
     "bits/types/res_state.h":      [ "netinet/in.h", "sys/types.h" ],
-    "bits/utmp.h":                 [ "paths.h", "sys/time.h", "sys/types.h" ],
-    "bits/utmpx.h":                [ "paths.h", "sys/time.h" ],
 }
 
 # As above, but each group of whitelist entries is only used for
diff --git a/sysdeps/gnu/Makefile b/sysdeps/gnu/Makefile
index a03d40e..f49f291 100644
--- a/sysdeps/gnu/Makefile
+++ b/sysdeps/gnu/Makefile
@@ -58,13 +58,6 @@ $(foreach o,$(object-suffixes) $(object-suffixes:=.d),\
 	  $(objpfx)errlist$o): $(objpfx)errlist-compat.h
 endif
 
-ifeq ($(subdir),login)
-sysdep_routines += setutxent getutxent endutxent getutxid getutxline \
-		   pututxline utmpxname updwtmpx getutmpx getutmp
-
-sysdep_headers += utmpx.h bits/utmpx.h
-endif
-
 
 ifeq ($(subdir),inet)
 sysdep_headers += netinet/udp.h netinet/ip_icmp.h
diff --git a/sysdeps/gnu/bits/utmp.h b/sysdeps/gnu/bits/utmp.h
deleted file mode 100644
index 7357034..0000000
--- a/sysdeps/gnu/bits/utmp.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/* The `struct utmp' type, describing entries in the utmp file.  GNU version.
-   Copyright (C) 1993-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#ifndef _UTMP_H
-# error "Never include <bits/utmp.h> directly; use <utmp.h> instead."
-#endif
-
-#include <paths.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <bits/wordsize.h>
-
-
-#define UT_LINESIZE	32
-#define UT_NAMESIZE	32
-#define UT_HOSTSIZE	256
-
-
-/* The structure describing an entry in the database of
-   previous logins.  */
-struct lastlog
-  {
-#if __WORDSIZE_TIME64_COMPAT32
-    int32_t ll_time;
-#else
-    __time_t ll_time;
-#endif
-    char ll_line[UT_LINESIZE];
-    char ll_host[UT_HOSTSIZE];
-  };
-
-
-/* The structure describing the status of a terminated process.  This
-   type is used in `struct utmp' below.  */
-struct exit_status
-  {
-    short int e_termination;	/* Process termination status.  */
-    short int e_exit;		/* Process exit status.  */
-  };
-
-
-/* The structure describing an entry in the user accounting database.  */
-struct utmp
-{
-  short int ut_type;		/* Type of login.  */
-  pid_t ut_pid;			/* Process ID of login process.  */
-  char ut_line[UT_LINESIZE]
-    __attribute_nonstring__;	/* Devicename.  */
-  char ut_id[4];		/* Inittab ID.  */
-  char ut_user[UT_NAMESIZE]
-    __attribute_nonstring__;	/* Username.  */
-  char ut_host[UT_HOSTSIZE]
-    __attribute_nonstring__;	/* Hostname for remote login.  */
-  struct exit_status ut_exit;	/* Exit status of a process marked
-				   as DEAD_PROCESS.  */
-/* The ut_session and ut_tv fields must be the same size when compiled
-   32- and 64-bit.  This allows data files and shared memory to be
-   shared between 32- and 64-bit applications.  */
-#if __WORDSIZE_TIME64_COMPAT32
-  int32_t ut_session;		/* Session ID, used for windowing.  */
-  struct
-  {
-    int32_t tv_sec;		/* Seconds.  */
-    int32_t tv_usec;		/* Microseconds.  */
-  } ut_tv;			/* Time entry was made.  */
-#else
-  long int ut_session;		/* Session ID, used for windowing.  */
-  struct timeval ut_tv;		/* Time entry was made.  */
-#endif
-
-  int32_t ut_addr_v6[4];	/* Internet address of remote host.  */
-  char __glibc_reserved[20];		/* Reserved for future use.  */
-};
-
-/* Backwards compatibility hacks.  */
-#define ut_name		ut_user
-#ifndef _NO_UT_TIME
-/* We have a problem here: `ut_time' is also used otherwise.  Define
-   _NO_UT_TIME if the compiler complains.  */
-# define ut_time	ut_tv.tv_sec
-#endif
-#define ut_xtime	ut_tv.tv_sec
-#define ut_addr		ut_addr_v6[0]
-
-
-/* Values for the `ut_type' field of a `struct utmp'.  */
-#define EMPTY		0	/* No valid user accounting information.  */
-
-#define RUN_LVL		1	/* The system's runlevel.  */
-#define BOOT_TIME	2	/* Time of system boot.  */
-#define NEW_TIME	3	/* Time after system clock changed.  */
-#define OLD_TIME	4	/* Time when system clock changed.  */
-
-#define INIT_PROCESS	5	/* Process spawned by the init process.  */
-#define LOGIN_PROCESS	6	/* Session leader of a logged in user.  */
-#define USER_PROCESS	7	/* Normal process.  */
-#define DEAD_PROCESS	8	/* Terminated process.  */
-
-#define ACCOUNTING	9
-
-/* Old Linux name for the EMPTY type.  */
-#define UT_UNKNOWN	EMPTY
-
-
-/* Tell the user that we have a modern system with UT_HOST, UT_PID,
-   UT_TYPE, UT_ID and UT_TV fields.  */
-#define _HAVE_UT_TYPE	1
-#define _HAVE_UT_PID	1
-#define _HAVE_UT_ID	1
-#define _HAVE_UT_TV	1
-#define _HAVE_UT_HOST	1
diff --git a/sysdeps/unix/sysv/linux/s390/bits/utmp.h b/sysdeps/unix/sysv/linux/s390/bits/utmp.h
index 862115c..553fb30 100644
--- a/sysdeps/unix/sysv/linux/s390/bits/utmp.h
+++ b/sysdeps/unix/sysv/linux/s390/bits/utmp.h
@@ -1,4 +1,4 @@
-/* The `struct utmp' type, describing entries in the utmp file.  GNU version.
+/* The `struct utmp' type, describing entries in the utmp file.  S/390 version.
    Copyright (C) 1993-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -16,15 +16,13 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_UTMP_H
+#define _BITS_UTMP_H 1
+
 #ifndef _UTMP_H
 # error "Never include <bits/utmp.h> directly; use <utmp.h> instead."
 #endif
 
-#include <paths.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <bits/wordsize.h>
-
 
 #define UT_LINESIZE	32
 #define UT_NAMESIZE	32
@@ -35,11 +33,7 @@
    previous logins.  */
 struct lastlog
   {
-#if __WORDSIZE == 32
-    int64_t ll_time;
-#else
-    __time_t ll_time;
-#endif
+    __time64_t ll_time;
     char ll_line[UT_LINESIZE];
     char ll_host[UT_HOSTSIZE];
   };
@@ -60,31 +54,28 @@ struct utmp
   short int ut_type;		/* Type of login.  */
   pid_t ut_pid;			/* Process ID of login process.  */
   char ut_line[UT_LINESIZE]
-     __attribute_nonstring__;	/* Devicename.  */
+    __attribute_nonstring__;	/* Devicename.  */
   char ut_id[4];		/* Inittab ID.  */
   char ut_user[UT_NAMESIZE]
-     __attribute_nonstring__;	/* Username.  */
+    __attribute_nonstring__;	/* Username.  */
   char ut_host[UT_HOSTSIZE]
-     __attribute_nonstring__;	/* Hostname for remote login.  */
+    __attribute_nonstring__;	/* Hostname for remote login.  */
   struct exit_status ut_exit;	/* Exit status of a process marked
 				   as DEAD_PROCESS.  */
+
 /* The ut_session and ut_tv fields must be the same size when compiled
    32- and 64-bit.  This allows data files and shared memory to be
-   shared between 32- and 64-bit applications.  */
-#if __WORDSIZE == 32
-  int64_t ut_session;		/* Session ID, used for windowing.  */
+   shared between 32- and 64-bit applications.  Even on 64-bit systems,
+   struct timeval is not guaranteed to have both fields be 64 bits.  */
+  __int64_t ut_session;		/* Session ID, used for windowing.  */
   struct
   {
-    int64_t tv_sec;		/* Seconds.  */
-    int64_t tv_usec;		/* Microseconds.  */
+    __int64_t tv_sec;		/* Seconds.  */
+    __int64_t tv_usec;		/* Microseconds.  */
   } ut_tv;			/* Time entry was made.  */
-#else
-  long int ut_session;		/* Session ID, used for windowing.  */
-  struct timeval ut_tv;		/* Time entry was made.  */
-#endif
 
-  int32_t ut_addr_v6[4];	/* Internet address of remote host.  */
-  char __glibc_reserved[20];		/* Reserved for future use.  */
+  __int32_t ut_addr_v6[4];	/* Internet address of remote host.  */
+  char __glibc_reserved[20];	/* Reserved for future use.  */
 };
 
 /* Backwards compatibility hacks.  */
@@ -124,3 +115,5 @@ struct utmp
 #define _HAVE_UT_ID	1
 #define _HAVE_UT_TV	1
 #define _HAVE_UT_HOST	1
+
+#endif /* bits/utmp.h */
diff --git a/sysdeps/unix/sysv/linux/s390/bits/utmpx.h b/sysdeps/unix/sysv/linux/s390/bits/utmpx.h
index ea3e860..e498e72 100644
--- a/sysdeps/unix/sysv/linux/s390/bits/utmpx.h
+++ b/sysdeps/unix/sysv/linux/s390/bits/utmpx.h
@@ -1,4 +1,4 @@
-/* Structures and definitions for the user accounting database.  GNU version.
+/* Structures and definitions for the user accounting database.  S/390 version.
    Copyright (C) 1997-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -16,22 +16,13 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_UTMPX_H
+#define _BITS_UTMPX_H 1
+
 #ifndef _UTMPX_H
 # error "Never include <bits/utmpx.h> directly; use <utmpx.h> instead."
 #endif
 
-#include <bits/types.h>
-#include <sys/time.h>
-#include <bits/wordsize.h>
-
-
-#ifdef __USE_GNU
-# include <paths.h>
-# define _PATH_UTMPX	_PATH_UTMP
-# define _PATH_WTMPX	_PATH_WTMP
-#endif
-
-
 #define __UT_LINESIZE	32
 #define __UT_NAMESIZE	32
 #define __UT_HOSTSIZE	256
@@ -55,7 +46,7 @@ struct __exit_status
 struct utmpx
 {
   short int ut_type;		/* Type of login.  */
-  __pid_t ut_pid;		/* Process ID of login process.  */
+  pid_t ut_pid;			/* Process ID of login process.  */
   char ut_line[__UT_LINESIZE];	/* Devicename.  */
   char ut_id[4];		/* Inittab ID. */
   char ut_user[__UT_NAMESIZE];	/* Username.  */
@@ -63,20 +54,17 @@ struct utmpx
   struct __exit_status ut_exit;	/* Exit status of a process marked
 				   as DEAD_PROCESS.  */
 
-/* The fields ut_session and ut_tv must be the same size when compiled
-   32- and 64-bit.  This allows files and shared memory to be shared
-   between 32- and 64-bit applications.  */
-#if __WORDSIZE == 32
+/* The ut_session and ut_tv fields must be the same size when compiled
+   32- and 64-bit.  This allows data files and shared memory to be
+   shared between 32- and 64-bit applications.  Even on 64-bit systems,
+   struct timeval is not guaranteed to have both fields be 64 bits.  */
   __int64_t ut_session;		/* Session ID, used for windowing.  */
   struct
   {
     __int64_t tv_sec;		/* Seconds.  */
     __int64_t tv_usec;		/* Microseconds.  */
   } ut_tv;			/* Time entry was made.  */
-#else
-  long int ut_session;		/* Session ID, used for windowing.  */
-  struct timeval ut_tv;		/* Time entry was made.  */
-#endif
+
   __int32_t ut_addr_v6[4];	/* Internet address of remote host.  */
   char __glibc_reserved[20];		/* Reserved for future use.  */
 };
@@ -100,3 +88,5 @@ struct utmpx
 #ifdef __USE_GNU
 # define ACCOUNTING	9	/* System accounting.  */
 #endif
+
+#endif /* bits/utmpx.h */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]