public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/zack/no-nested-includes] sys/types.h: Don’t define u_intN_t or register_t unless __USE_MISC.
@ 2019-06-26 15:48 Zack Weinberg
  0 siblings, 0 replies; 4+ messages in thread
From: Zack Weinberg @ 2019-06-26 15:48 UTC (permalink / raw)
  To: glibc-cvs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 4455 bytes --]

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

commit cba69352b20e3e5b9f1b8f3d4ca12ace01ad860a
Author: Zack Weinberg <zackw@panix.com>
Date:   Mon Feb 18 21:00:34 2019 -0500

    sys/types.h: Don’t define u_intN_t or register_t unless __USE_MISC.
    
    sys/types.h unconditionally defines u_int8_t, u_int16_t, u_int32_t,
    u_int64_t, and register_t.  These are not part of any standard.  The
    u_intXX_t types are superseded by C99’s uintXX_t types (defined in
    stdint.h).  I’m not aware of a standardized exact equivalent of
    register_t, but also I’ve never seen anyone use it for anything.
    I could be persuaded to leave that one alone.
    
    sys/types.h also unconditionally defines int8_t, int16_t, int32_t, and
    int64_t, which are the same as the C99 exact-width signed types in
    stdint.h.  POSIX doesn’t require these to appear in sys/types.h, so in
    principle they ought to be brought under __USE_MISC also.  But, when I
    tried that it broke about two dozen files just in our own source tree,
    and POSIX doesn’t *forbid* sys/types.h to define these types, so I
    think we should leave them alone.
    
    	* posix/sys/types.h (u_int8_t, u_int16_t, u_int32_t, u_int64_t)
            (register_t): Move under #ifdef __USE_MISC.
            Consolidate adjacent #ifdef __USE_MISC blocks.
            * scripts/check_obsolete_constructs.py: Add register_t to the
            set of obsolete typedefs that our headers should not use
            (but sys/types.h may still define).

Diff:
---
 NEWS                                 |  8 ++++++++
 posix/sys/types.h                    | 16 ++++++++--------
 scripts/check-obsolete-constructs.py |  1 +
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/NEWS b/NEWS
index 8a2fece..edf7739 100644
--- a/NEWS
+++ b/NEWS
@@ -45,6 +45,14 @@ Deprecated and removed features, and other changes affecting compatibility:
 * The obsolete and never-implemented XSI STREAMS header files <stropts.h>
   and <sys/stropts.h> have been removed.
 
+* The typedefs u_int8_t, u_int16_t, u_int32_t, u_int64_t, and register_t
+  are no longer defined by <sys/types.h> in strict conformance modes.
+  These types were historically provided by <sys/types.h> on BSD systems,
+  but are not part of the POSIX specification for that header.  Applications
+  requiring fixed-width unsigned integer types should use the similarly
+  named uint8_t, uint16_t, etc. from <stdint.h>.  There is no standardized
+  replacement for register_t.
+
 * Support for the "inet6" option in /etc/resolv.conf and the RES_USE_INET6
   resolver flag (deprecated in glibc 2.25) have been removed.
 
diff --git a/posix/sys/types.h b/posix/sys/types.h
index 1bbd896..7327904 100644
--- a/posix/sys/types.h
+++ b/posix/sys/types.h
@@ -143,18 +143,20 @@ typedef __suseconds_t suseconds_t;
 #define	__need_size_t
 #include <stddef.h>
 
+/* POSIX does not require intN_t to be defined in this header, so
+   technically this ought to be under __USE_MISC, but it doesn't
+   forbid them to be defined here either, and much existing code
+   expects them to be defined here.  */
+#include <bits/stdint-intn.h>
+
 #ifdef __USE_MISC
 /* Old compatibility names for C types.  */
 typedef unsigned long int ulong;
 typedef unsigned short int ushort;
 typedef unsigned int uint;
-#endif
-
-/* These size-specific names are used by some of the inet code.  */
 
-#include <bits/stdint-intn.h>
-
-/* These were defined by ISO C without the first `_'.  */
+/* These size-specific names are used by some of the inet code.
+   They were defined by ISO C without the first `_'.  */
 typedef __uint8_t u_int8_t;
 typedef __uint16_t u_int16_t;
 typedef __uint32_t u_int32_t;
@@ -167,8 +169,6 @@ typedef __register_t register_t;
    defined.  */
 #define __BIT_TYPES_DEFINED__	1
 
-
-#ifdef	__USE_MISC
 /* In BSD <sys/types.h> is expected to define BYTE_ORDER.  */
 # include <endian.h>
 
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index 89d21de..4dc5276 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -254,6 +254,7 @@ class NoCheck(ConstructChecker):
 OBSOLETE_TYPE_RE_ = re.compile(r"""\A
   (__)?
   (   quad_t
+    | register_t
     | u(?: short | int | long
          | _(?: char | short | int(?:[0-9]+_t)? | long | quad_t )))
 \Z""", re.VERBOSE)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [glibc/zack/no-nested-includes] sys/types.h: Don’t define u_intN_t or register_t unless __USE_MISC.
@ 2020-01-08 19:19 Zack Weinberg
  0 siblings, 0 replies; 4+ messages in thread
From: Zack Weinberg @ 2020-01-08 19:19 UTC (permalink / raw)
  To: glibc-cvs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 4457 bytes --]

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=40782c2685760fc7fe9d82738e3091bfa5216c1c

commit 40782c2685760fc7fe9d82738e3091bfa5216c1c
Author: Zack Weinberg <zackw@panix.com>
Date:   Mon Feb 18 21:00:34 2019 -0500

    sys/types.h: Don’t define u_intN_t or register_t unless __USE_MISC.
    
    sys/types.h unconditionally defines u_int8_t, u_int16_t, u_int32_t,
    u_int64_t, and register_t.  These are not part of any standard.  The
    u_intXX_t types are superseded by C99’s uintXX_t types (defined in
    stdint.h).  I’m not aware of a standardized exact equivalent of
    register_t, but also I’ve never seen anyone use it for anything.
    I could be persuaded to leave that one alone.
    
    sys/types.h also unconditionally defines int8_t, int16_t, int32_t, and
    int64_t, which are the same as the C99 exact-width signed types in
    stdint.h.  POSIX doesn’t require these to appear in sys/types.h, so in
    principle they ought to be brought under __USE_MISC also.  But, when I
    tried that it broke about two dozen files just in our own source tree,
    and POSIX doesn’t *forbid* sys/types.h to define these types, so I
    think we should leave them alone.
    
    	* posix/sys/types.h (u_int8_t, u_int16_t, u_int32_t, u_int64_t)
            (register_t): Move under #ifdef __USE_MISC.
            Consolidate adjacent #ifdef __USE_MISC blocks.
            * scripts/check_obsolete_constructs.py: Add register_t to the
            set of obsolete typedefs that our headers should not use
            (but sys/types.h may still define).

Diff:
---
 NEWS                                 |  8 ++++++++
 posix/sys/types.h                    | 16 ++++++++--------
 scripts/check-obsolete-constructs.py |  1 +
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/NEWS b/NEWS
index b85989e..599db8f 100644
--- a/NEWS
+++ b/NEWS
@@ -187,6 +187,14 @@ Deprecated and removed features, and other changes affecting compatibility:
 * The obsolete and never-implemented XSI STREAMS header files <stropts.h>
   and <sys/stropts.h> have been removed.
 
+* The typedefs u_int8_t, u_int16_t, u_int32_t, u_int64_t, and register_t
+  are no longer defined by <sys/types.h> in strict conformance modes.
+  These types were historically provided by <sys/types.h> on BSD systems,
+  but are not part of the POSIX specification for that header.  Applications
+  requiring fixed-width unsigned integer types should use the similarly
+  named uint8_t, uint16_t, etc. from <stdint.h>.  There is no standardized
+  replacement for register_t.
+
 * Support for the "inet6" option in /etc/resolv.conf and the RES_USE_INET6
   resolver flag (deprecated in glibc 2.25) have been removed.
 
diff --git a/posix/sys/types.h b/posix/sys/types.h
index 1838bdd..65a8cfb 100644
--- a/posix/sys/types.h
+++ b/posix/sys/types.h
@@ -143,18 +143,20 @@ typedef __suseconds_t suseconds_t;
 #define	__need_size_t
 #include <stddef.h>
 
+/* POSIX does not require intN_t to be defined in this header, so
+   technically this ought to be under __USE_MISC, but it doesn't
+   forbid them to be defined here either, and much existing code
+   expects them to be defined here.  */
+#include <bits/stdint-intn.h>
+
 #ifdef __USE_MISC
 /* Old compatibility names for C types.  */
 typedef unsigned long int ulong;
 typedef unsigned short int ushort;
 typedef unsigned int uint;
-#endif
-
-/* These size-specific names are used by some of the inet code.  */
 
-#include <bits/stdint-intn.h>
-
-/* These were defined by ISO C without the first `_'.  */
+/* These size-specific names are used by some of the inet code.
+   They were defined by ISO C without the first `_'.  */
 typedef __uint8_t u_int8_t;
 typedef __uint16_t u_int16_t;
 typedef __uint32_t u_int32_t;
@@ -167,8 +169,6 @@ typedef __register_t register_t;
    defined.  */
 #define __BIT_TYPES_DEFINED__	1
 
-
-#ifdef	__USE_MISC
 /* In BSD <sys/types.h> is expected to define BYTE_ORDER.  */
 # include <endian.h>
 
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index 5037de4..cdeacd8 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -254,6 +254,7 @@ class NoCheck(ConstructChecker):
 OBSOLETE_TYPE_RE_ = re.compile(r"""\A
   (__)?
   (   quad_t
+    | register_t
     | u(?: short | int | long
          | _(?: char | short | int(?:[0-9]+_t)? | long | quad_t )))
 \Z""", re.VERBOSE)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [glibc/zack/no-nested-includes] sys/types.h: Don’t define u_intN_t or register_t unless __USE_MISC.
@ 2019-06-18 15:32 Zack Weinberg
  0 siblings, 0 replies; 4+ messages in thread
From: Zack Weinberg @ 2019-06-18 15:32 UTC (permalink / raw)
  To: glibc-cvs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 4455 bytes --]

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

commit abee01996d6d83082445348065a2d6add26bd63f
Author: Zack Weinberg <zackw@panix.com>
Date:   Mon Feb 18 21:00:34 2019 -0500

    sys/types.h: Don’t define u_intN_t or register_t unless __USE_MISC.
    
    sys/types.h unconditionally defines u_int8_t, u_int16_t, u_int32_t,
    u_int64_t, and register_t.  These are not part of any standard.  The
    u_intXX_t types are superseded by C99’s uintXX_t types (defined in
    stdint.h).  I’m not aware of a standardized exact equivalent of
    register_t, but also I’ve never seen anyone use it for anything.
    I could be persuaded to leave that one alone.
    
    sys/types.h also unconditionally defines int8_t, int16_t, int32_t, and
    int64_t, which are the same as the C99 exact-width signed types in
    stdint.h.  POSIX doesn’t require these to appear in sys/types.h, so in
    principle they ought to be brought under __USE_MISC also.  But, when I
    tried that it broke about two dozen files just in our own source tree,
    and POSIX doesn’t *forbid* sys/types.h to define these types, so I
    think we should leave them alone.
    
    	* posix/sys/types.h (u_int8_t, u_int16_t, u_int32_t, u_int64_t)
            (register_t): Move under #ifdef __USE_MISC.
            Consolidate adjacent #ifdef __USE_MISC blocks.
            * scripts/check_obsolete_constructs.py: Add register_t to the
            set of obsolete typedefs that our headers should not use
            (but sys/types.h may still define).

Diff:
---
 NEWS                                 |  8 ++++++++
 posix/sys/types.h                    | 16 ++++++++--------
 scripts/check-obsolete-constructs.py |  1 +
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/NEWS b/NEWS
index 8a2fece..edf7739 100644
--- a/NEWS
+++ b/NEWS
@@ -45,6 +45,14 @@ Deprecated and removed features, and other changes affecting compatibility:
 * The obsolete and never-implemented XSI STREAMS header files <stropts.h>
   and <sys/stropts.h> have been removed.
 
+* The typedefs u_int8_t, u_int16_t, u_int32_t, u_int64_t, and register_t
+  are no longer defined by <sys/types.h> in strict conformance modes.
+  These types were historically provided by <sys/types.h> on BSD systems,
+  but are not part of the POSIX specification for that header.  Applications
+  requiring fixed-width unsigned integer types should use the similarly
+  named uint8_t, uint16_t, etc. from <stdint.h>.  There is no standardized
+  replacement for register_t.
+
 * Support for the "inet6" option in /etc/resolv.conf and the RES_USE_INET6
   resolver flag (deprecated in glibc 2.25) have been removed.
 
diff --git a/posix/sys/types.h b/posix/sys/types.h
index 1bbd896..7327904 100644
--- a/posix/sys/types.h
+++ b/posix/sys/types.h
@@ -143,18 +143,20 @@ typedef __suseconds_t suseconds_t;
 #define	__need_size_t
 #include <stddef.h>
 
+/* POSIX does not require intN_t to be defined in this header, so
+   technically this ought to be under __USE_MISC, but it doesn't
+   forbid them to be defined here either, and much existing code
+   expects them to be defined here.  */
+#include <bits/stdint-intn.h>
+
 #ifdef __USE_MISC
 /* Old compatibility names for C types.  */
 typedef unsigned long int ulong;
 typedef unsigned short int ushort;
 typedef unsigned int uint;
-#endif
-
-/* These size-specific names are used by some of the inet code.  */
 
-#include <bits/stdint-intn.h>
-
-/* These were defined by ISO C without the first `_'.  */
+/* These size-specific names are used by some of the inet code.
+   They were defined by ISO C without the first `_'.  */
 typedef __uint8_t u_int8_t;
 typedef __uint16_t u_int16_t;
 typedef __uint32_t u_int32_t;
@@ -167,8 +169,6 @@ typedef __register_t register_t;
    defined.  */
 #define __BIT_TYPES_DEFINED__	1
 
-
-#ifdef	__USE_MISC
 /* In BSD <sys/types.h> is expected to define BYTE_ORDER.  */
 # include <endian.h>
 
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index 89d21de..4dc5276 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -254,6 +254,7 @@ class NoCheck(ConstructChecker):
 OBSOLETE_TYPE_RE_ = re.compile(r"""\A
   (__)?
   (   quad_t
+    | register_t
     | u(?: short | int | long
          | _(?: char | short | int(?:[0-9]+_t)? | long | quad_t )))
 \Z""", re.VERBOSE)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [glibc/zack/no-nested-includes] sys/types.h: Don’t define u_intN_t or register_t unless __USE_MISC.
@ 2019-05-26 16:35 Zack Weinberg
  0 siblings, 0 replies; 4+ messages in thread
From: Zack Weinberg @ 2019-05-26 16:35 UTC (permalink / raw)
  To: glibc-cvs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 4455 bytes --]

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

commit ad4d473af1f3e62421488c6dc55b4a48376450b9
Author: Zack Weinberg <zackw@panix.com>
Date:   Mon Feb 18 21:00:34 2019 -0500

    sys/types.h: Don’t define u_intN_t or register_t unless __USE_MISC.
    
    sys/types.h unconditionally defines u_int8_t, u_int16_t, u_int32_t,
    u_int64_t, and register_t.  These are not part of any standard.  The
    u_intXX_t types are superseded by C99’s uintXX_t types (defined in
    stdint.h).  I’m not aware of a standardized exact equivalent of
    register_t, but also I’ve never seen anyone use it for anything.
    I could be persuaded to leave that one alone.
    
    sys/types.h also unconditionally defines int8_t, int16_t, int32_t, and
    int64_t, which are the same as the C99 exact-width signed types in
    stdint.h.  POSIX doesn’t require these to appear in sys/types.h, so in
    principle they ought to be brought under __USE_MISC also.  But, when I
    tried that it broke about two dozen files just in our own source tree,
    and POSIX doesn’t *forbid* sys/types.h to define these types, so I
    think we should leave them alone.
    
    	* posix/sys/types.h (u_int8_t, u_int16_t, u_int32_t, u_int64_t)
            (register_t): Move under #ifdef __USE_MISC.
            Consolidate adjacent #ifdef __USE_MISC blocks.
            * scripts/check_obsolete_constructs.py: Add register_t to the
            set of obsolete typedefs that our headers should not use
            (but sys/types.h may still define).

Diff:
---
 NEWS                                 |  8 ++++++++
 posix/sys/types.h                    | 16 ++++++++--------
 scripts/check-obsolete-constructs.py |  1 +
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/NEWS b/NEWS
index c885b96..5bc422d 100644
--- a/NEWS
+++ b/NEWS
@@ -45,6 +45,14 @@ Deprecated and removed features, and other changes affecting compatibility:
 * The obsolete and never-implemented XSI STREAMS header files <stropts.h>
   and <sys/stropts.h> have been removed.
 
+* The typedefs u_int8_t, u_int16_t, u_int32_t, u_int64_t, and register_t
+  are no longer defined by <sys/types.h> in strict conformance modes.
+  These types were historically provided by <sys/types.h> on BSD systems,
+  but are not part of the POSIX specification for that header.  Applications
+  requiring fixed-width unsigned integer types should use the similarly
+  named uint8_t, uint16_t, etc. from <stdint.h>.  There is no standardized
+  replacement for register_t.
+
 * Support for the "inet6" option in /etc/resolv.conf and the RES_USE_INET6
   resolver flag (deprecated in glibc 2.25) have been removed.
 
diff --git a/posix/sys/types.h b/posix/sys/types.h
index 1bbd896..7327904 100644
--- a/posix/sys/types.h
+++ b/posix/sys/types.h
@@ -143,18 +143,20 @@ typedef __suseconds_t suseconds_t;
 #define	__need_size_t
 #include <stddef.h>
 
+/* POSIX does not require intN_t to be defined in this header, so
+   technically this ought to be under __USE_MISC, but it doesn't
+   forbid them to be defined here either, and much existing code
+   expects them to be defined here.  */
+#include <bits/stdint-intn.h>
+
 #ifdef __USE_MISC
 /* Old compatibility names for C types.  */
 typedef unsigned long int ulong;
 typedef unsigned short int ushort;
 typedef unsigned int uint;
-#endif
-
-/* These size-specific names are used by some of the inet code.  */
 
-#include <bits/stdint-intn.h>
-
-/* These were defined by ISO C without the first `_'.  */
+/* These size-specific names are used by some of the inet code.
+   They were defined by ISO C without the first `_'.  */
 typedef __uint8_t u_int8_t;
 typedef __uint16_t u_int16_t;
 typedef __uint32_t u_int32_t;
@@ -167,8 +169,6 @@ typedef __register_t register_t;
    defined.  */
 #define __BIT_TYPES_DEFINED__	1
 
-
-#ifdef	__USE_MISC
 /* In BSD <sys/types.h> is expected to define BYTE_ORDER.  */
 # include <endian.h>
 
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index 89d21de..4dc5276 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -254,6 +254,7 @@ class NoCheck(ConstructChecker):
 OBSOLETE_TYPE_RE_ = re.compile(r"""\A
   (__)?
   (   quad_t
+    | register_t
     | u(?: short | int | long
          | _(?: char | short | int(?:[0-9]+_t)? | long | quad_t )))
 \Z""", re.VERBOSE)


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-01-08 19:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-26 15:48 [glibc/zack/no-nested-includes] sys/types.h: Don’t define u_intN_t or register_t unless __USE_MISC Zack Weinberg
  -- strict thread matches above, loose matches on Subject: below --
2020-01-08 19:19 Zack Weinberg
2019-06-18 15:32 Zack Weinberg
2019-05-26 16:35 Zack Weinberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).