This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch zack/more-obsolete-typedefs created. glibc-2.29.9000-85-g751991c
- From: zack at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 21 Feb 2019 15:23:23 -0000
- Subject: GNU C Library master sources branch zack/more-obsolete-typedefs created. glibc-2.29.9000-85-g751991c
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, zack/more-obsolete-typedefs has been created
at 751991c2c98744028fd33e3dc3c8189e5a2ec632 (commit)
- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=751991c2c98744028fd33e3dc3c8189e5a2ec632
commit 751991c2c98744028fd33e3dc3c8189e5a2ec632
Author: Zack Weinberg <zackw@panix.com>
Date: Tue Feb 19 08:45:22 2019 -0500
Define register_t using bits/typesizes.h macros.
Currently register_t is, unlike all other types in sys/types.h,
defined using a GCC extension (__attribute__((mode(word)))), falling
back to â??intâ?? if the extension is unavailable. This is a potential
ABI compatibility hazard for people using non-GNU compilers with
glibc. Itâ??s also unnecessary; the bits/typesizes.h mechanism can
handle all of the existing variation in the definition.
Tested using build-many-glibcs. The c++-types test confirms that the
physical type of register_t does not change on any supported platform.
* posix/sys/types.h: Typedef register_t as __register_t.
* posix/bits/types.h: Typedef __register_t using __REGISTER_T_TYPE.
* bits/typesizes.h
* sysdeps/mach/hurd/bits/typesizes.h
* sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
* sysdeps/unix/sysv/linux/generic/bits/typesizes.h
* sysdeps/unix/sysv/linux/s390/bits/typesizes.h
* sysdeps/unix/sysv/linux/sparc/bits/typesizes.h:
Define __REGISTER_T_TYPE as __SWORD_TYPE.
* sysdeps/unix/sysv/linux/x86/bits/typesizes.h:
Define __REGISTER_T_TYPE as __SWORD_TYPE for o32 and n64.
Define __REGISTER_T_TYPE as __SQUAD_TYPE for n32.
* scripts/check-obsolete-constructs.py
(ObsoletePublicDefinitionsAllowed): Remove special handling
for register_t.
(ObsoletePrivateDefinitionsAllowed): Understand __STD_TYPE as
introducing a typedef.
diff --git a/bits/typesizes.h b/bits/typesizes.h
index 41c8924..4541013 100644
--- a/bits/typesizes.h
+++ b/bits/typesizes.h
@@ -60,6 +60,7 @@
#define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE
#define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE
#define __CPU_MASK_TYPE __ULONGWORD_TYPE
+#define __REGISTER_T_TYPE __SWORD_TYPE
#ifdef __LP64__
/* Tell the libc code that off_t and off64_t are actually the same type
diff --git a/posix/bits/types.h b/posix/bits/types.h
index 0de6c59..4521d9d 100644
--- a/posix/bits/types.h
+++ b/posix/bits/types.h
@@ -219,6 +219,9 @@ typedef int __sig_atomic_t;
__STD_TYPE __TIME64_T_TYPE __time64_t; /* Seconds since the Epoch. */
#endif
+/* BSD: Size of a general-purpose integer register. */
+__STD_TYPE __REGISTER_T_TYPE __register_t;
+
#undef __STD_TYPE
#endif /* bits/types.h */
diff --git a/posix/sys/types.h b/posix/sys/types.h
index 29a7e9e..7327904 100644
--- a/posix/sys/types.h
+++ b/posix/sys/types.h
@@ -162,11 +162,8 @@ typedef __uint16_t u_int16_t;
typedef __uint32_t u_int32_t;
typedef __uint64_t u_int64_t;
-#if __GNUC_PREREQ (2, 7)
-typedef int register_t __attribute__ ((__mode__ (__word__)));
-#else
-typedef int register_t;
-#endif
+/* Type of a general-purpose integer register (BSD). */
+typedef __register_t register_t;
/* Some code from BIND tests this macro to see if the types above are
defined. */
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index 7133c67..5d822df 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -226,8 +226,6 @@ class ObsoletePublicDefinitionsAllowed(ConstructChecker):
typedef unsigned long int ulong;
typedef unsigned short int ushort;
typedef unsigned int uint;
- typedef int register_t;
- typedef int register_t __attribute__ ((__mode__ (__word__)));
"""
def __init__(self, reporter):
super().__init__(reporter)
@@ -264,15 +262,12 @@ class ObsoletePublicDefinitionsAllowed(ConstructChecker):
if not self.typedef_tokens: return
if self.typedef_tokens[-1].kind == 'IDENT':
m = OBSOLETE_TYPE_RE_.match(self.typedef_tokens[-1].text)
- if m:
- if self._permissible_public_definition(m):
- self.typedef_tokens.clear()
- elif self.typedef_tokens[-1].kind == 'PUNCTUATOR':
- if self._is_register_t_with_attribute():
+ if self._permissible_public_definition(m):
self.typedef_tokens.clear()
self._reset()
def _permissible_public_definition(self, m):
+ if not m: return False
if m.group(1) == '__': return False
name = m.group(2)
tk = self.typedef_tokens
@@ -288,9 +283,6 @@ class ObsoletePublicDefinitionsAllowed(ConstructChecker):
and name[5:-2] == defn[6:-2]):
return True
- if name == 'register_t' and defn == 'int':
- return True
-
return False
if (name == 'ulong' and ntok == 5
@@ -312,23 +304,6 @@ class ObsoletePublicDefinitionsAllowed(ConstructChecker):
return False
- def _is_register_t_with_attribute(self):
- tk = self.typedef_tokens
- ntok = len(tk)
- return (
- ntok == 12
- and tk[ 1].kind == 'IDENT' and tk[ 1].text == 'int'
- and tk[ 2].kind == 'IDENT' and tk[ 2].text == 'register_t'
- and tk[ 3].kind == 'IDENT' and tk[ 3].text == '__attribute__'
- and tk[ 4].kind == 'PUNCTUATOR' and tk[ 4].text == '('
- and tk[ 5].kind == 'PUNCTUATOR' and tk[ 5].text == '('
- and tk[ 6].kind == 'IDENT' and tk[ 6].text == '__mode__'
- and tk[ 7].kind == 'PUNCTUATOR' and tk[ 7].text == '('
- and tk[ 8].kind == 'IDENT' and tk[ 8].text == '__word__'
- and tk[ 9].kind == 'PUNCTUATOR' and tk[ 9].text == ')'
- and tk[10].kind == 'PUNCTUATOR' and tk[10].text == ')'
- and tk[11].kind == 'PUNCTUATOR' and tk[11].text == ')')
-
def ObsoleteTypedefChecker(reporter, fname):
"""Factory: produce an instance of the appropriate
obsolete-typedef checker for FNAME."""
diff --git a/sysdeps/mach/hurd/bits/typesizes.h b/sysdeps/mach/hurd/bits/typesizes.h
index 6bd9b43..94b0afc 100644
--- a/sysdeps/mach/hurd/bits/typesizes.h
+++ b/sysdeps/mach/hurd/bits/typesizes.h
@@ -60,6 +60,7 @@
#define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE
#define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE
#define __CPU_MASK_TYPE __ULONGWORD_TYPE
+#define __REGISTER_T_TYPE __SWORD_TYPE
/* Number of descriptors that can fit in an `fd_set'. */
#define __FD_SETSIZE 256
diff --git a/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h b/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
index cde275d..0485dd1 100644
--- a/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
@@ -60,6 +60,7 @@
#define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE
#define __CPU_MASK_TYPE __ULONGWORD_TYPE
#define __FSWORD_T_TYPE __S32_TYPE
+#define __REGISTER_T_TYPE __SWORD_TYPE
/* Tell the libc code that off_t and off64_t are actually the same type
for all ABI purposes, even if possibly expressed as different base types
diff --git a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h
index 3ef1281..c738ff5 100644
--- a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h
@@ -61,6 +61,7 @@
#define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE
#define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE
#define __CPU_MASK_TYPE __ULONGWORD_TYPE
+#define __REGISTER_T_TYPE __SWORD_TYPE
#ifdef __LP64__
/* Tell the libc code that off_t and off64_t are actually the same type
diff --git a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
index e421057..c578237 100644
--- a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
@@ -66,6 +66,7 @@
#define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE
#define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE
#define __CPU_MASK_TYPE __ULONGWORD_TYPE
+#define __REGISTER_T_TYPE __SWORD_TYPE
#ifdef __s390x__
/* Tell the libc code that off_t and off64_t are actually the same type
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
index 115cc19..0db18f4 100644
--- a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
@@ -60,6 +60,7 @@
#define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE
#define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE
#define __CPU_MASK_TYPE __ULONGWORD_TYPE
+#define __REGISTER_T_TYPE __SWORD_TYPE
#if defined __arch64__ || defined __sparcv9
/* Tell the libc code that off_t and off64_t are actually the same type
diff --git a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h
index 18d2c63..0a71e30 100644
--- a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h
@@ -30,9 +30,11 @@
#if defined __x86_64__ && defined __ILP32__
# define __SYSCALL_SLONG_TYPE __SQUAD_TYPE
# define __SYSCALL_ULONG_TYPE __UQUAD_TYPE
+# define __REGISTER_T_TYPE __SQUAD_TYPE
#else
# define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE
# define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE
+# define __REGISTER_T_TYPE __SWORD_TYPE
#endif
#define __DEV_T_TYPE __UQUAD_TYPE
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=b2479f3deca76826d855850aafd824d31cc28d66
commit b2479f3deca76826d855850aafd824d31cc28d66
Author: Zack Weinberg <zackw@panix.com>
Date: Mon Feb 18 21:00:34 2019 -0500
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 POSIX. The
u_intXX_t types are superseded by C99â??s uintXX_t types. 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.
* 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 --git a/NEWS b/NEWS
index 0a3b6c7..d951cf0 100644
--- a/NEWS
+++ b/NEWS
@@ -22,6 +22,14 @@ Deprecated and removed features, and other changes affecting compatibility:
definitions in libc will be used automatically, which have been available
since glibc 2.17.
+* 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.
+
Changes to build and runtime requirements:
* GCC 6.2 or later is required to build the GNU C Library.
diff --git a/posix/sys/types.h b/posix/sys/types.h
index 0e37b1c..29a7e9e 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;
@@ -170,8 +172,6 @@ typedef int 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 47dc51e..7133c67 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -170,6 +170,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)
@@ -225,6 +226,8 @@ class ObsoletePublicDefinitionsAllowed(ConstructChecker):
typedef unsigned long int ulong;
typedef unsigned short int ushort;
typedef unsigned int uint;
+ typedef int register_t;
+ typedef int register_t __attribute__ ((__mode__ (__word__)));
"""
def __init__(self, reporter):
super().__init__(reporter)
@@ -264,15 +267,18 @@ class ObsoletePublicDefinitionsAllowed(ConstructChecker):
if m:
if self._permissible_public_definition(m):
self.typedef_tokens.clear()
+ elif self.typedef_tokens[-1].kind == 'PUNCTUATOR':
+ if self._is_register_t_with_attribute():
+ self.typedef_tokens.clear()
self._reset()
def _permissible_public_definition(self, m):
if m.group(1) == '__': return False
name = m.group(2)
- toks = self.typedef_tokens
- ntok = len(toks)
- if ntok == 3 and toks[1].kind == 'IDENT':
- defn = toks[1].text
+ tk = self.typedef_tokens
+ ntok = len(tk)
+ if ntok == 3 and tk[1].kind == 'IDENT':
+ defn = tk[1].text
n = OBSOLETE_TYPE_RE_.match(defn)
if n and n.group(1) == '__' and n.group(2) == name:
return True
@@ -282,27 +288,47 @@ class ObsoletePublicDefinitionsAllowed(ConstructChecker):
and name[5:-2] == defn[6:-2]):
return True
+ if name == 'register_t' and defn == 'int':
+ return True
+
return False
if (name == 'ulong' and ntok == 5
- and toks[1].kind == 'IDENT' and toks[1].text == 'unsigned'
- and toks[2].kind == 'IDENT' and toks[2].text == 'long'
- and toks[3].kind == 'IDENT' and toks[3].text == 'int'):
+ and tk[1].kind == 'IDENT' and tk[1].text == 'unsigned'
+ and tk[2].kind == 'IDENT' and tk[2].text == 'long'
+ and tk[3].kind == 'IDENT' and tk[3].text == 'int'):
return True
if (name == 'ushort' and ntok == 5
- and toks[1].kind == 'IDENT' and toks[1].text == 'unsigned'
- and toks[2].kind == 'IDENT' and toks[2].text == 'short'
- and toks[3].kind == 'IDENT' and toks[3].text == 'int'):
+ and tk[1].kind == 'IDENT' and tk[1].text == 'unsigned'
+ and tk[2].kind == 'IDENT' and tk[2].text == 'short'
+ and tk[3].kind == 'IDENT' and tk[3].text == 'int'):
return True
if (name == 'uint' and ntok == 4
- and toks[1].kind == 'IDENT' and toks[1].text == 'unsigned'
- and toks[2].kind == 'IDENT' and toks[2].text == 'int'):
+ and tk[1].kind == 'IDENT' and tk[1].text == 'unsigned'
+ and tk[2].kind == 'IDENT' and tk[2].text == 'int'):
return True
return False
+ def _is_register_t_with_attribute(self):
+ tk = self.typedef_tokens
+ ntok = len(tk)
+ return (
+ ntok == 12
+ and tk[ 1].kind == 'IDENT' and tk[ 1].text == 'int'
+ and tk[ 2].kind == 'IDENT' and tk[ 2].text == 'register_t'
+ and tk[ 3].kind == 'IDENT' and tk[ 3].text == '__attribute__'
+ and tk[ 4].kind == 'PUNCTUATOR' and tk[ 4].text == '('
+ and tk[ 5].kind == 'PUNCTUATOR' and tk[ 5].text == '('
+ and tk[ 6].kind == 'IDENT' and tk[ 6].text == '__mode__'
+ and tk[ 7].kind == 'PUNCTUATOR' and tk[ 7].text == '('
+ and tk[ 8].kind == 'IDENT' and tk[ 8].text == '__word__'
+ and tk[ 9].kind == 'PUNCTUATOR' and tk[ 9].text == ')'
+ and tk[10].kind == 'PUNCTUATOR' and tk[10].text == ')'
+ and tk[11].kind == 'PUNCTUATOR' and tk[11].text == ')')
+
def ObsoleteTypedefChecker(reporter, fname):
"""Factory: produce an instance of the appropriate
obsolete-typedef checker for FNAME."""
-----------------------------------------------------------------------
hooks/post-receive
--
GNU C Library master sources