]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Define register_t using bits/typesizes.h macros.
authorZack Weinberg <zackw@panix.com>
Tue, 19 Feb 2019 13:45:22 +0000 (08:45 -0500)
committerZack Weinberg <zackw@panix.com>
Wed, 8 Jan 2020 17:52:49 +0000 (12:52 -0500)
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.  In most
cases, defining __REGISTER_T_TYPE as __SWORD_TYPE is sufficient.
Special handling is necessary for MIPS n32 and x86-64 x32, where
__SWORD_TYPE is ‘int’ and the appropriate type for register_t is
‘long long’.  Unfortunately, this means we need to create a new
bits/typesizes.h variant for linux/mips.  This variant is based
on the top-level bits/typesizes.h, not linux/generic/bits/typesizes.h,
to match the existing MIPS ABIs.

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/mips/bits/typesizes.h:
        New file (copied from bits/typesizes.h).
        Define __REGISTER_T_TYPE as __SWORD_TYPE for o32 and n64 ABIs.
        Define __REGISTER_T_TYPE as __SQUAD_TYPE for n32.
        * sysdeps/unix/sysv/linux/x86/bits/typesizes.h:
        Define __REGISTER_T_TYPE as __SWORD_TYPE for o32 and 64-bit ABIs.
        Define __REGISTER_T_TYPE as __SQUAD_TYPE for x32.

bits/typesizes.h
posix/bits/types.h
posix/sys/types.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/mips/bits/typesizes.h [new file with mode: 0644]
sysdeps/unix/sysv/linux/s390/bits/typesizes.h
sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
sysdeps/unix/sysv/linux/x86/bits/typesizes.h

index 014c9aab2136c03fc87213217eb523d5bb825601..f5c8161fc9e36ae9d463788a08719d02b3e3dc4e 100644 (file)
@@ -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
index adba926b45470fdc96ee922047213f1c8b210eeb..78c47ffa063520ead99470cf715de343e6f53560 100644 (file)
@@ -222,6 +222,9 @@ typedef int __sig_atomic_t;
 __STD_TYPE __TIME64_T_TYPE __time64_t;
 #endif
 
+/* BSD: Size of a general-purpose integer register.  */
+__STD_TYPE __REGISTER_T_TYPE __register_t;
+
 #undef __STD_TYPE
 
 #endif /* bits/types.h */
index c9241e40b4d71ed09ae8c1995da449014afd4fbe..1838bdd851f7949fc69c13ca26956a2395383a77 100644 (file)
@@ -160,11 +160,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.  */
index b429379d7d32e4939af8ea3a5c12979fda9108ea..f950bbf5d8336352967464ac06e74b70957be750 100644 (file)
@@ -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
index 30356ba6d61d6767c715c503d0b87158224ffd97..44e5381822fe4fc0f5e95a7008055f998d373638 100644 (file)
@@ -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
index a916dea0473429f7dc35cb45864a07f3e62ed15c..47b91568dd60bc02dddc89bd3219f10bc7f5af1d 100644 (file)
@@ -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/mips/bits/typesizes.h b/sysdeps/unix/sysv/linux/mips/bits/typesizes.h
new file mode 100644 (file)
index 0000000..1132670
--- /dev/null
@@ -0,0 +1,89 @@
+/* bits/typesizes.h -- underlying types for *_t.  For the MIPS Linux ABI.
+   Copyright (C) 2011-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 _BITS_TYPES_H
+# error "Never include <bits/typesizes.h> directly; use <sys/types.h> instead."
+#endif
+
+#ifndef        _BITS_TYPESIZES_H
+#define        _BITS_TYPESIZES_H       1
+
+/* See <bits/types.h> for the meaning of these macros.  This file exists so
+   that <bits/types.h> need not vary across different GNU platforms.  */
+
+#define __DEV_T_TYPE           __UQUAD_TYPE
+#define __UID_T_TYPE           __U32_TYPE
+#define __GID_T_TYPE           __U32_TYPE
+#define __INO_T_TYPE           __ULONGWORD_TYPE
+#define __INO64_T_TYPE         __UQUAD_TYPE
+#define __MODE_T_TYPE          __U32_TYPE
+#define __NLINK_T_TYPE         __UWORD_TYPE
+#define __OFF_T_TYPE           __SLONGWORD_TYPE
+#define __OFF64_T_TYPE         __SQUAD_TYPE
+#define __PID_T_TYPE           __S32_TYPE
+#define __RLIM_T_TYPE          __ULONGWORD_TYPE
+#define __RLIM64_T_TYPE                __UQUAD_TYPE
+#define        __BLKCNT_T_TYPE         __SLONGWORD_TYPE
+#define        __BLKCNT64_T_TYPE       __SQUAD_TYPE
+#define        __FSBLKCNT_T_TYPE       __ULONGWORD_TYPE
+#define        __FSBLKCNT64_T_TYPE     __UQUAD_TYPE
+#define        __FSFILCNT_T_TYPE       __ULONGWORD_TYPE
+#define        __FSFILCNT64_T_TYPE     __UQUAD_TYPE
+#define        __FSWORD_T_TYPE         __SWORD_TYPE
+#define        __ID_T_TYPE             __U32_TYPE
+#define __CLOCK_T_TYPE         __SLONGWORD_TYPE
+#define __TIME_T_TYPE          __SLONGWORD_TYPE
+#define __USECONDS_T_TYPE      __U32_TYPE
+#define __SUSECONDS_T_TYPE     __SLONGWORD_TYPE
+#define __DADDR_T_TYPE         __S32_TYPE
+#define __KEY_T_TYPE           __S32_TYPE
+#define __CLOCKID_T_TYPE       __S32_TYPE
+#define __TIMER_T_TYPE         void *
+#define __BLKSIZE_T_TYPE       __SLONGWORD_TYPE
+#define __FSID_T_TYPE          struct { int __val[2]; }
+#define __SSIZE_T_TYPE         __SWORD_TYPE
+#define __SYSCALL_SLONG_TYPE   __SLONGWORD_TYPE
+#define __SYSCALL_ULONG_TYPE   __ULONGWORD_TYPE
+#define __CPU_MASK_TYPE        __ULONGWORD_TYPE
+
+#if defined _ABIN32 && _MIPS_SIM == _ABIN32
+#define __REGISTER_T_TYPE      __SQUAD_TYPE
+#else
+#define __REGISTER_T_TYPE      __SWORD_TYPE
+#endif
+
+#ifdef __LP64__
+/* 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
+   for C type-checking purposes.  */
+# define __OFF_T_MATCHES_OFF64_T       1
+
+/* Same for ino_t and ino64_t.  */
+# define __INO_T_MATCHES_INO64_T       1
+
+/* And for __rlim_t and __rlim64_t.  */
+# define __RLIM_T_MATCHES_RLIM64_T     1
+#else
+# define __RLIM_T_MATCHES_RLIM64_T     0
+#endif
+
+/* Number of descriptors that can fit in an `fd_set'.  */
+#define        __FD_SETSIZE            1024
+
+
+#endif /* bits/typesizes.h */
index 45f70184eaf342641e022f376c5a1bd48deff699..91c601d0fe454d99a4629b27fb81f0e8a505db9c 100644 (file)
@@ -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
index 1f3bbc800281a27409301c3912c0c28ce46d4775..d19742d932261e684537a8789447af3c9b849786 100644 (file)
@@ -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
index d08414559718ff90c55eab4525b25a89dc7d6ecc..67ebbb2e17c862094a9640856a464a5f8c41fd4f 100644 (file)
 #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