Message ID | 1469515124-28190-1-git-send-email-ynorov@caviumnetworks.com |
---|---|
State | New |
Headers | show |
Ping? On Tue, Jul 26, 2016 at 09:38:44AM +0300, Yury Norov wrote: > From: Andrew Pinski <apinski@cavium.com> > > __WORDSIZE_TIME64_COMPAT32 and __WORDSIZE32_SIZE_ULONG should be defined to 0 > but it's not defined at all for many targets. > > __WORDSIZE32_PTRDIFF_LONG is introduced for aarch64/ilp32, and defined > for all other ports as well. > > This patch is the part of aarch64/ilp32 work but it can be applied > separately as it fixes inconsistency in GLIBC. > > v2: > - added __WORDSIZE_TIME64_COMPAT32; > - added documentation; > - removed newlines at the end of files. > v3: > - __WORDSIZE32_* are meaningless with __WORDSIZE == 64 and left undefined > in that case. > > * sysdeps/aarch64/bits/wordsize.h : New file > (__WORDSIZE32_SIZE_ULONG): Define. > (__WORDSIZE32_PTRDIFF_LONG): New define. > * sysdeps/mips/bits/wordsize.h: Likewise. > * sysdeps/powerpc/powerpc32/bits/wordsize.h: Likewise. > * sysdeps/powerpc/powerpc64/bits/wordsize.h: Likewise. > * sysdeps/s390/s390-32/bits/wordsize.h: Likewise. > * sysdeps/s390/s390-64/bits/wordsize.h: Likewise. > * sysdeps/sparc/sparc32/bits/wordsize.h: Likewise. > * sysdeps/sparc/sparc64/bits/wordsize.h: Likewise. > * sysdeps/tile/tilegx/bits/wordsize.h: Likewise. > * sysdeps/tile/tilepro/bits/wordsize.h: Likewise. > * sysdeps/unix/sysv/linux/alpha/bits/wordsize.h: Likewise. > * sysdeps/unix/sysv/linux/powerpc/bits/wordsize.h: Likewise. > * sysdeps/unix/sysv/linux/sparc/bits/wordsize.h: Likewise. > * sysdeps/wordsize-32/bits/wordsize.h: Likewise. > * sysdeps/wordsize-64/bits/wordsize.h: Likewise. > * sysdeps/x86/bits/wordsize.h: Likewise. > * sysdeps/generic/stdint.h: Use #if instead of #ifdef for that macros. > * sysdeps/gnu/bits/utmp.h: Likewise. > * sysdeps/gnu/bits/utmpx.h: Likewise. > * bits/wordsize.h: Add documentation. > > Signed-off-by: Andrew Pinski <apinski@cavium.com> > Signed-off-by: Yury Norov <ynorov@caviumnetworks.com> > --- > bits/wordsize.h | 10 +++++++++ > sysdeps/aarch64/bits/wordsize.h | 28 +++++++++++++++++++++++++ > sysdeps/generic/stdint.h | 11 +++++++--- > sysdeps/gnu/bits/utmp.h | 4 ++-- > sysdeps/gnu/bits/utmpx.h | 2 +- > sysdeps/mips/bits/wordsize.h | 4 ++++ > sysdeps/powerpc/powerpc32/bits/wordsize.h | 3 +++ > sysdeps/powerpc/powerpc64/bits/wordsize.h | 3 +++ > sysdeps/s390/s390-32/bits/wordsize.h | 5 ++++- > sysdeps/s390/s390-64/bits/wordsize.h | 5 ++++- > sysdeps/sparc/sparc32/bits/wordsize.h | 3 +++ > sysdeps/sparc/sparc64/bits/wordsize.h | 3 +++ > sysdeps/tile/tilegx/bits/wordsize.h | 3 +++ > sysdeps/tile/tilepro/bits/wordsize.h | 4 ++++ > sysdeps/unix/sysv/linux/alpha/bits/wordsize.h | 2 ++ > sysdeps/unix/sysv/linux/powerpc/bits/wordsize.h | 3 +++ > sysdeps/unix/sysv/linux/sparc/bits/wordsize.h | 4 ++++ > sysdeps/wordsize-32/bits/wordsize.h | 4 ++++ > sysdeps/wordsize-64/bits/wordsize.h | 2 ++ > sysdeps/x86/bits/wordsize.h | 4 ++++ > 20 files changed, 99 insertions(+), 8 deletions(-) > create mode 100644 sysdeps/aarch64/bits/wordsize.h > > diff --git a/bits/wordsize.h b/bits/wordsize.h > index 9ef0e85..29fa8ff 100644 > --- a/bits/wordsize.h > +++ b/bits/wordsize.h > @@ -1 +1,11 @@ > #error "This file must be written based on the data type sizes of the target" > + > +#define __WORDSIZE /* Bits ber word (size of CPU register. */ > +#define __WORDSIZE32_SIZE_ULONG /* Set to 1 if port is working in 32-bit mode > + on 64-bit CPU to define SIZE_MAX correctly. > + Keep undefined for 64-bit ports. */ > +#define __WORDSIZE32_PTRDIFF_LONG /* Likewize for PTRDIFF_MIN and PTRDIFF_MAX. */ > +#define __WORDSIZE_TIME64_COMPAT32 /* Set to 1 to force time types to be 32-bit > + in struct lastlog and struct utmp{,x} > + if your 64-bit port should be compatible to > + 32-bit old ports. */ > diff --git a/sysdeps/aarch64/bits/wordsize.h b/sysdeps/aarch64/bits/wordsize.h > new file mode 100644 > index 0000000..eadbb48 > --- /dev/null > +++ b/sysdeps/aarch64/bits/wordsize.h > @@ -0,0 +1,28 @@ > +/* Determine the wordsize from the preprocessor defines. > + > + Copyright (C) 2016 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/>. */ > + > +#ifdef __LP64__ > +# define __WORDSIZE 64 > +#else > +# define __WORDSIZE 32 > +# define __WORDSIZE32_SIZE_ULONG 1 > +# define __WORDSIZE32_PTRDIFF_LONG 1 > +#endif > + > +#define __WORDSIZE_TIME64_COMPAT32 0 > diff --git a/sysdeps/generic/stdint.h b/sysdeps/generic/stdint.h > index 4427627..3d26d0b 100644 > --- a/sysdeps/generic/stdint.h > +++ b/sysdeps/generic/stdint.h > @@ -248,8 +248,13 @@ typedef unsigned long long int uintmax_t; > # define PTRDIFF_MIN (-9223372036854775807L-1) > # define PTRDIFF_MAX (9223372036854775807L) > # else > -# define PTRDIFF_MIN (-2147483647-1) > -# define PTRDIFF_MAX (2147483647) > +# if __WORDSIZE32_PTRDIFF_LONG > +# define PTRDIFF_MIN (-2147483647L-1) > +# define PTRDIFF_MAX (2147483647L) > +# else > +# define PTRDIFF_MIN (-2147483647-1) > +# define PTRDIFF_MAX (2147483647) > +# endif > # endif > > /* Limits of `sig_atomic_t'. */ > @@ -260,7 +265,7 @@ typedef unsigned long long int uintmax_t; > # if __WORDSIZE == 64 > # define SIZE_MAX (18446744073709551615UL) > # else > -# ifdef __WORDSIZE32_SIZE_ULONG > +# if __WORDSIZE32_SIZE_ULONG > # define SIZE_MAX (4294967295UL) > # else > # define SIZE_MAX (4294967295U) > diff --git a/sysdeps/gnu/bits/utmp.h b/sysdeps/gnu/bits/utmp.h > index 2a1ffcb..bce1a7b 100644 > --- a/sysdeps/gnu/bits/utmp.h > +++ b/sysdeps/gnu/bits/utmp.h > @@ -35,7 +35,7 @@ > previous logins. */ > struct lastlog > { > -#ifdef __WORDSIZE_TIME64_COMPAT32 > +#if __WORDSIZE_TIME64_COMPAT32 > int32_t ll_time; > #else > __time_t ll_time; > @@ -68,7 +68,7 @@ struct utmp > /* 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. */ > -#ifdef __WORDSIZE_TIME64_COMPAT32 > +#if __WORDSIZE_TIME64_COMPAT32 > int32_t ut_session; /* Session ID, used for windowing. */ > struct > { > diff --git a/sysdeps/gnu/bits/utmpx.h b/sysdeps/gnu/bits/utmpx.h > index b41548b..a438660 100644 > --- a/sysdeps/gnu/bits/utmpx.h > +++ b/sysdeps/gnu/bits/utmpx.h > @@ -66,7 +66,7 @@ struct utmpx > /* 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. */ > -#ifdef __WORDSIZE_TIME64_COMPAT32 > +#if __WORDSIZE_TIME64_COMPAT32 > __int32_t ut_session; /* Session ID, used for windowing. */ > struct > { > diff --git a/sysdeps/mips/bits/wordsize.h b/sysdeps/mips/bits/wordsize.h > index bc90435..2f4756e 100644 > --- a/sysdeps/mips/bits/wordsize.h > +++ b/sysdeps/mips/bits/wordsize.h > @@ -20,4 +20,8 @@ > #define __WORDSIZE _MIPS_SZPTR > #if _MIPS_SIM == _ABI64 > # define __WORDSIZE_TIME64_COMPAT32 1 > +#else > +# define __WORDSIZE32_SIZE_ULONG 0 > +# define __WORDSIZE32_PTRDIFF_LONG 0 > +# define __WORDSIZE_TIME64_COMPAT32 0 > #endif > diff --git a/sysdeps/powerpc/powerpc32/bits/wordsize.h b/sysdeps/powerpc/powerpc32/bits/wordsize.h > index f31ac9a..04ca9de 100644 > --- a/sysdeps/powerpc/powerpc32/bits/wordsize.h > +++ b/sysdeps/powerpc/powerpc32/bits/wordsize.h > @@ -5,4 +5,7 @@ > # define __WORDSIZE_TIME64_COMPAT32 1 > #else > # define __WORDSIZE 32 > +# define __WORDSIZE_TIME64_COMPAT32 0 > +# define __WORDSIZE32_SIZE_ULONG 0 > +# define __WORDSIZE32_PTRDIFF_LONG 0 > #endif > diff --git a/sysdeps/powerpc/powerpc64/bits/wordsize.h b/sysdeps/powerpc/powerpc64/bits/wordsize.h > index f31ac9a..04ca9de 100644 > --- a/sysdeps/powerpc/powerpc64/bits/wordsize.h > +++ b/sysdeps/powerpc/powerpc64/bits/wordsize.h > @@ -5,4 +5,7 @@ > # define __WORDSIZE_TIME64_COMPAT32 1 > #else > # define __WORDSIZE 32 > +# define __WORDSIZE_TIME64_COMPAT32 0 > +# define __WORDSIZE32_SIZE_ULONG 0 > +# define __WORDSIZE32_PTRDIFF_LONG 0 > #endif > diff --git a/sysdeps/s390/s390-32/bits/wordsize.h b/sysdeps/s390/s390-32/bits/wordsize.h > index da791fa..bc71b07 100644 > --- a/sysdeps/s390/s390-32/bits/wordsize.h > +++ b/sysdeps/s390/s390-32/bits/wordsize.h > @@ -4,9 +4,12 @@ > # define __WORDSIZE 64 > #else > # define __WORDSIZE 32 > -# define __WORDSIZE32_SIZE_ULONG 1 > +# define __WORDSIZE32_SIZE_ULONG 1 > +# define __WORDSIZE32_PTRDIFF_LONG 0 > #endif > > +#define __WORDSIZE_TIME64_COMPAT32 0 > + > #if !defined __NO_LONG_DOUBLE_MATH && !defined __LONG_DOUBLE_MATH_OPTIONAL > > /* Signal that we didn't used to have a `long double'. The changes all > diff --git a/sysdeps/s390/s390-64/bits/wordsize.h b/sysdeps/s390/s390-64/bits/wordsize.h > index da791fa..bc71b07 100644 > --- a/sysdeps/s390/s390-64/bits/wordsize.h > +++ b/sysdeps/s390/s390-64/bits/wordsize.h > @@ -4,9 +4,12 @@ > # define __WORDSIZE 64 > #else > # define __WORDSIZE 32 > -# define __WORDSIZE32_SIZE_ULONG 1 > +# define __WORDSIZE32_SIZE_ULONG 1 > +# define __WORDSIZE32_PTRDIFF_LONG 0 > #endif > > +#define __WORDSIZE_TIME64_COMPAT32 0 > + > #if !defined __NO_LONG_DOUBLE_MATH && !defined __LONG_DOUBLE_MATH_OPTIONAL > > /* Signal that we didn't used to have a `long double'. The changes all > diff --git a/sysdeps/sparc/sparc32/bits/wordsize.h b/sysdeps/sparc/sparc32/bits/wordsize.h > index d8fd1a5..2f66f10 100644 > --- a/sysdeps/sparc/sparc32/bits/wordsize.h > +++ b/sysdeps/sparc/sparc32/bits/wordsize.h > @@ -5,4 +5,7 @@ > # define __WORDSIZE_TIME64_COMPAT32 1 > #else > # define __WORDSIZE 32 > +# define __WORDSIZE_TIME64_COMPAT32 0 > +# define __WORDSIZE32_SIZE_ULONG 0 > +# define __WORDSIZE32_PTRDIFF_LONG 0 > #endif > diff --git a/sysdeps/sparc/sparc64/bits/wordsize.h b/sysdeps/sparc/sparc64/bits/wordsize.h > index d8fd1a5..2f66f10 100644 > --- a/sysdeps/sparc/sparc64/bits/wordsize.h > +++ b/sysdeps/sparc/sparc64/bits/wordsize.h > @@ -5,4 +5,7 @@ > # define __WORDSIZE_TIME64_COMPAT32 1 > #else > # define __WORDSIZE 32 > +# define __WORDSIZE_TIME64_COMPAT32 0 > +# define __WORDSIZE32_SIZE_ULONG 0 > +# define __WORDSIZE32_PTRDIFF_LONG 0 > #endif > diff --git a/sysdeps/tile/tilegx/bits/wordsize.h b/sysdeps/tile/tilegx/bits/wordsize.h > index 5d4e4b4..9dc4da5 100644 > --- a/sysdeps/tile/tilegx/bits/wordsize.h > +++ b/sysdeps/tile/tilegx/bits/wordsize.h > @@ -5,4 +5,7 @@ > # define __WORDSIZE_TIME64_COMPAT32 1 > #else > # define __WORDSIZE 32 > +# define __WORDSIZE_TIME64_COMPAT32 0 > +# define __WORDSIZE32_SIZE_ULONG 0 > +# define __WORDSIZE32_PTRDIFF_LONG 0 > #endif > diff --git a/sysdeps/tile/tilepro/bits/wordsize.h b/sysdeps/tile/tilepro/bits/wordsize.h > index da587a2..eb9b3c1 100644 > --- a/sysdeps/tile/tilepro/bits/wordsize.h > +++ b/sysdeps/tile/tilepro/bits/wordsize.h > @@ -1,3 +1,7 @@ > /* Determine the wordsize from the preprocessor defines. */ > > #define __WORDSIZE 32 > + > +#define __WORDSIZE32_SIZE_ULONG 0 > +#define __WORDSIZE32_PTRDIFF_LONG 0 > +#define __WORDSIZE_TIME64_COMPAT32 0 > \ No newline at end of file > diff --git a/sysdeps/unix/sysv/linux/alpha/bits/wordsize.h b/sysdeps/unix/sysv/linux/alpha/bits/wordsize.h > index 51fc433..1b27601 100644 > --- a/sysdeps/unix/sysv/linux/alpha/bits/wordsize.h > +++ b/sysdeps/unix/sysv/linux/alpha/bits/wordsize.h > @@ -17,6 +17,8 @@ > > #define __WORDSIZE 64 > > +#define __WORDSIZE_TIME64_COMPAT32 0 > + > #if !defined __NO_LONG_DOUBLE_MATH && !defined __LONG_DOUBLE_MATH_OPTIONAL > > /* Signal that we didn't used to have a `long double'. The changes all > diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/wordsize.h b/sysdeps/unix/sysv/linux/powerpc/bits/wordsize.h > index 3e8a1e0..109f08c 100644 > --- a/sysdeps/unix/sysv/linux/powerpc/bits/wordsize.h > +++ b/sysdeps/unix/sysv/linux/powerpc/bits/wordsize.h > @@ -5,6 +5,9 @@ > # define __WORDSIZE_TIME64_COMPAT32 1 > #else > # define __WORDSIZE 32 > +# define __WORDSIZE_TIME64_COMPAT32 0 > +# define __WORDSIZE32_SIZE_ULONG 0 > +# define __WORDSIZE32_PTRDIFF_LONG 0 > #endif > > #if !defined __NO_LONG_DOUBLE_MATH && !defined __LONG_DOUBLE_MATH_OPTIONAL > diff --git a/sysdeps/unix/sysv/linux/sparc/bits/wordsize.h b/sysdeps/unix/sysv/linux/sparc/bits/wordsize.h > index 2d958d2..3564bb1 100644 > --- a/sysdeps/unix/sysv/linux/sparc/bits/wordsize.h > +++ b/sysdeps/unix/sysv/linux/sparc/bits/wordsize.h > @@ -4,8 +4,12 @@ > # define __WORDSIZE 64 > #else > # define __WORDSIZE 32 > +# define __WORDSIZE32_SIZE_ULONG 0 > +# define __WORDSIZE32_PTRDIFF_LONG 0 > #endif > > +#define __WORDSIZE_TIME64_COMPAT32 0 > + > #if !defined __NO_LONG_DOUBLE_MATH && !defined __LONG_DOUBLE_MATH_OPTIONAL > > # if __WORDSIZE == 32 > diff --git a/sysdeps/wordsize-32/bits/wordsize.h b/sysdeps/wordsize-32/bits/wordsize.h > index 2aa16bc..acb3b14 100644 > --- a/sysdeps/wordsize-32/bits/wordsize.h > +++ b/sysdeps/wordsize-32/bits/wordsize.h > @@ -16,3 +16,7 @@ > <http://www.gnu.org/licenses/>. */ > > #define __WORDSIZE 32 > + > +#define __WORDSIZE32_SIZE_ULONG 0 > +#define __WORDSIZE32_PTRDIFF_LONG 0 > +#define __WORDSIZE_TIME64_COMPAT32 0 > \ No newline at end of file > diff --git a/sysdeps/wordsize-64/bits/wordsize.h b/sysdeps/wordsize-64/bits/wordsize.h > index 0944f9e..04eb0f6 100644 > --- a/sysdeps/wordsize-64/bits/wordsize.h > +++ b/sysdeps/wordsize-64/bits/wordsize.h > @@ -16,3 +16,5 @@ > <http://www.gnu.org/licenses/>. */ > > #define __WORDSIZE 64 > + > +#define __WORDSIZE_TIME64_COMPAT32 0 > \ No newline at end of file > diff --git a/sysdeps/x86/bits/wordsize.h b/sysdeps/x86/bits/wordsize.h > index e25af28..530d253 100644 > --- a/sysdeps/x86/bits/wordsize.h > +++ b/sysdeps/x86/bits/wordsize.h > @@ -4,10 +4,14 @@ > # define __WORDSIZE 64 > #else > # define __WORDSIZE 32 > +# define __WORDSIZE32_SIZE_ULONG 0 > +# define __WORDSIZE32_PTRDIFF_LONG 0 > #endif > > #ifdef __x86_64__ > # define __WORDSIZE_TIME64_COMPAT32 1 > /* Both x86-64 and x32 use the 64-bit system call interface. */ > # define __SYSCALL_WORDSIZE 64 > +#else > +# define __WORDSIZE_TIME64_COMPAT32 0 > #endif > -- > 2.7.4
On Jul 26 2016, Yury Norov <ynorov@caviumnetworks.com> wrote: > diff --git a/bits/wordsize.h b/bits/wordsize.h > index 9ef0e85..29fa8ff 100644 > --- a/bits/wordsize.h > +++ b/bits/wordsize.h > @@ -1 +1,11 @@ > #error "This file must be written based on the data type sizes of the target" > + > +#define __WORDSIZE /* Bits ber word (size of CPU register. */ s/ber/per/; missing paren. > +#define __WORDSIZE32_SIZE_ULONG /* Set to 1 if port is working in 32-bit mode > + on 64-bit CPU to define SIZE_MAX correctly. > + Keep undefined for 64-bit ports. */ > +#define __WORDSIZE32_PTRDIFF_LONG /* Likewize for PTRDIFF_MIN and PTRDIFF_MAX. */ s/Likewize/Likewise/ > +#define __WORDSIZE_TIME64_COMPAT32 /* Set to 1 to force time types to be 32-bit > + in struct lastlog and struct utmp{,x} > + if your 64-bit port should be compatible to > + 32-bit old ports. */ Please put the comments in front of the definitions to avoid overlong lines. > diff --git a/sysdeps/tile/tilepro/bits/wordsize.h b/sysdeps/tile/tilepro/bits/wordsize.h > index da587a2..eb9b3c1 100644 > --- a/sysdeps/tile/tilepro/bits/wordsize.h > +++ b/sysdeps/tile/tilepro/bits/wordsize.h > @@ -1,3 +1,7 @@ > /* Determine the wordsize from the preprocessor defines. */ > > #define __WORDSIZE 32 > + > +#define __WORDSIZE32_SIZE_ULONG 0 > +#define __WORDSIZE32_PTRDIFF_LONG 0 > +#define __WORDSIZE_TIME64_COMPAT32 0 > \ No newline at end of file Missing newline. > diff --git a/sysdeps/wordsize-32/bits/wordsize.h b/sysdeps/wordsize-32/bits/wordsize.h > index 2aa16bc..acb3b14 100644 > --- a/sysdeps/wordsize-32/bits/wordsize.h > +++ b/sysdeps/wordsize-32/bits/wordsize.h > @@ -16,3 +16,7 @@ > <http://www.gnu.org/licenses/>. */ > > #define __WORDSIZE 32 > + > +#define __WORDSIZE32_SIZE_ULONG 0 > +#define __WORDSIZE32_PTRDIFF_LONG 0 > +#define __WORDSIZE_TIME64_COMPAT32 0 > \ No newline at end of file Missing newline. > diff --git a/sysdeps/wordsize-64/bits/wordsize.h b/sysdeps/wordsize-64/bits/wordsize.h > index 0944f9e..04eb0f6 100644 > --- a/sysdeps/wordsize-64/bits/wordsize.h > +++ b/sysdeps/wordsize-64/bits/wordsize.h > @@ -16,3 +16,5 @@ > <http://www.gnu.org/licenses/>. */ > > #define __WORDSIZE 64 > + > +#define __WORDSIZE_TIME64_COMPAT32 0 > \ No newline at end of file Missing newline. Andreas.
diff --git a/bits/wordsize.h b/bits/wordsize.h index 9ef0e85..29fa8ff 100644 --- a/bits/wordsize.h +++ b/bits/wordsize.h @@ -1 +1,11 @@ #error "This file must be written based on the data type sizes of the target" + +#define __WORDSIZE /* Bits ber word (size of CPU register. */ +#define __WORDSIZE32_SIZE_ULONG /* Set to 1 if port is working in 32-bit mode + on 64-bit CPU to define SIZE_MAX correctly. + Keep undefined for 64-bit ports. */ +#define __WORDSIZE32_PTRDIFF_LONG /* Likewize for PTRDIFF_MIN and PTRDIFF_MAX. */ +#define __WORDSIZE_TIME64_COMPAT32 /* Set to 1 to force time types to be 32-bit + in struct lastlog and struct utmp{,x} + if your 64-bit port should be compatible to + 32-bit old ports. */ diff --git a/sysdeps/aarch64/bits/wordsize.h b/sysdeps/aarch64/bits/wordsize.h new file mode 100644 index 0000000..eadbb48 --- /dev/null +++ b/sysdeps/aarch64/bits/wordsize.h @@ -0,0 +1,28 @@ +/* Determine the wordsize from the preprocessor defines. + + Copyright (C) 2016 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/>. */ + +#ifdef __LP64__ +# define __WORDSIZE 64 +#else +# define __WORDSIZE 32 +# define __WORDSIZE32_SIZE_ULONG 1 +# define __WORDSIZE32_PTRDIFF_LONG 1 +#endif + +#define __WORDSIZE_TIME64_COMPAT32 0 diff --git a/sysdeps/generic/stdint.h b/sysdeps/generic/stdint.h index 4427627..3d26d0b 100644 --- a/sysdeps/generic/stdint.h +++ b/sysdeps/generic/stdint.h @@ -248,8 +248,13 @@ typedef unsigned long long int uintmax_t; # define PTRDIFF_MIN (-9223372036854775807L-1) # define PTRDIFF_MAX (9223372036854775807L) # else -# define PTRDIFF_MIN (-2147483647-1) -# define PTRDIFF_MAX (2147483647) +# if __WORDSIZE32_PTRDIFF_LONG +# define PTRDIFF_MIN (-2147483647L-1) +# define PTRDIFF_MAX (2147483647L) +# else +# define PTRDIFF_MIN (-2147483647-1) +# define PTRDIFF_MAX (2147483647) +# endif # endif /* Limits of `sig_atomic_t'. */ @@ -260,7 +265,7 @@ typedef unsigned long long int uintmax_t; # if __WORDSIZE == 64 # define SIZE_MAX (18446744073709551615UL) # else -# ifdef __WORDSIZE32_SIZE_ULONG +# if __WORDSIZE32_SIZE_ULONG # define SIZE_MAX (4294967295UL) # else # define SIZE_MAX (4294967295U) diff --git a/sysdeps/gnu/bits/utmp.h b/sysdeps/gnu/bits/utmp.h index 2a1ffcb..bce1a7b 100644 --- a/sysdeps/gnu/bits/utmp.h +++ b/sysdeps/gnu/bits/utmp.h @@ -35,7 +35,7 @@ previous logins. */ struct lastlog { -#ifdef __WORDSIZE_TIME64_COMPAT32 +#if __WORDSIZE_TIME64_COMPAT32 int32_t ll_time; #else __time_t ll_time; @@ -68,7 +68,7 @@ struct utmp /* 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. */ -#ifdef __WORDSIZE_TIME64_COMPAT32 +#if __WORDSIZE_TIME64_COMPAT32 int32_t ut_session; /* Session ID, used for windowing. */ struct { diff --git a/sysdeps/gnu/bits/utmpx.h b/sysdeps/gnu/bits/utmpx.h index b41548b..a438660 100644 --- a/sysdeps/gnu/bits/utmpx.h +++ b/sysdeps/gnu/bits/utmpx.h @@ -66,7 +66,7 @@ struct utmpx /* 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. */ -#ifdef __WORDSIZE_TIME64_COMPAT32 +#if __WORDSIZE_TIME64_COMPAT32 __int32_t ut_session; /* Session ID, used for windowing. */ struct { diff --git a/sysdeps/mips/bits/wordsize.h b/sysdeps/mips/bits/wordsize.h index bc90435..2f4756e 100644 --- a/sysdeps/mips/bits/wordsize.h +++ b/sysdeps/mips/bits/wordsize.h @@ -20,4 +20,8 @@ #define __WORDSIZE _MIPS_SZPTR #if _MIPS_SIM == _ABI64 # define __WORDSIZE_TIME64_COMPAT32 1 +#else +# define __WORDSIZE32_SIZE_ULONG 0 +# define __WORDSIZE32_PTRDIFF_LONG 0 +# define __WORDSIZE_TIME64_COMPAT32 0 #endif diff --git a/sysdeps/powerpc/powerpc32/bits/wordsize.h b/sysdeps/powerpc/powerpc32/bits/wordsize.h index f31ac9a..04ca9de 100644 --- a/sysdeps/powerpc/powerpc32/bits/wordsize.h +++ b/sysdeps/powerpc/powerpc32/bits/wordsize.h @@ -5,4 +5,7 @@ # define __WORDSIZE_TIME64_COMPAT32 1 #else # define __WORDSIZE 32 +# define __WORDSIZE_TIME64_COMPAT32 0 +# define __WORDSIZE32_SIZE_ULONG 0 +# define __WORDSIZE32_PTRDIFF_LONG 0 #endif diff --git a/sysdeps/powerpc/powerpc64/bits/wordsize.h b/sysdeps/powerpc/powerpc64/bits/wordsize.h index f31ac9a..04ca9de 100644 --- a/sysdeps/powerpc/powerpc64/bits/wordsize.h +++ b/sysdeps/powerpc/powerpc64/bits/wordsize.h @@ -5,4 +5,7 @@ # define __WORDSIZE_TIME64_COMPAT32 1 #else # define __WORDSIZE 32 +# define __WORDSIZE_TIME64_COMPAT32 0 +# define __WORDSIZE32_SIZE_ULONG 0 +# define __WORDSIZE32_PTRDIFF_LONG 0 #endif diff --git a/sysdeps/s390/s390-32/bits/wordsize.h b/sysdeps/s390/s390-32/bits/wordsize.h index da791fa..bc71b07 100644 --- a/sysdeps/s390/s390-32/bits/wordsize.h +++ b/sysdeps/s390/s390-32/bits/wordsize.h @@ -4,9 +4,12 @@ # define __WORDSIZE 64 #else # define __WORDSIZE 32 -# define __WORDSIZE32_SIZE_ULONG 1 +# define __WORDSIZE32_SIZE_ULONG 1 +# define __WORDSIZE32_PTRDIFF_LONG 0 #endif +#define __WORDSIZE_TIME64_COMPAT32 0 + #if !defined __NO_LONG_DOUBLE_MATH && !defined __LONG_DOUBLE_MATH_OPTIONAL /* Signal that we didn't used to have a `long double'. The changes all diff --git a/sysdeps/s390/s390-64/bits/wordsize.h b/sysdeps/s390/s390-64/bits/wordsize.h index da791fa..bc71b07 100644 --- a/sysdeps/s390/s390-64/bits/wordsize.h +++ b/sysdeps/s390/s390-64/bits/wordsize.h @@ -4,9 +4,12 @@ # define __WORDSIZE 64 #else # define __WORDSIZE 32 -# define __WORDSIZE32_SIZE_ULONG 1 +# define __WORDSIZE32_SIZE_ULONG 1 +# define __WORDSIZE32_PTRDIFF_LONG 0 #endif +#define __WORDSIZE_TIME64_COMPAT32 0 + #if !defined __NO_LONG_DOUBLE_MATH && !defined __LONG_DOUBLE_MATH_OPTIONAL /* Signal that we didn't used to have a `long double'. The changes all diff --git a/sysdeps/sparc/sparc32/bits/wordsize.h b/sysdeps/sparc/sparc32/bits/wordsize.h index d8fd1a5..2f66f10 100644 --- a/sysdeps/sparc/sparc32/bits/wordsize.h +++ b/sysdeps/sparc/sparc32/bits/wordsize.h @@ -5,4 +5,7 @@ # define __WORDSIZE_TIME64_COMPAT32 1 #else # define __WORDSIZE 32 +# define __WORDSIZE_TIME64_COMPAT32 0 +# define __WORDSIZE32_SIZE_ULONG 0 +# define __WORDSIZE32_PTRDIFF_LONG 0 #endif diff --git a/sysdeps/sparc/sparc64/bits/wordsize.h b/sysdeps/sparc/sparc64/bits/wordsize.h index d8fd1a5..2f66f10 100644 --- a/sysdeps/sparc/sparc64/bits/wordsize.h +++ b/sysdeps/sparc/sparc64/bits/wordsize.h @@ -5,4 +5,7 @@ # define __WORDSIZE_TIME64_COMPAT32 1 #else # define __WORDSIZE 32 +# define __WORDSIZE_TIME64_COMPAT32 0 +# define __WORDSIZE32_SIZE_ULONG 0 +# define __WORDSIZE32_PTRDIFF_LONG 0 #endif diff --git a/sysdeps/tile/tilegx/bits/wordsize.h b/sysdeps/tile/tilegx/bits/wordsize.h index 5d4e4b4..9dc4da5 100644 --- a/sysdeps/tile/tilegx/bits/wordsize.h +++ b/sysdeps/tile/tilegx/bits/wordsize.h @@ -5,4 +5,7 @@ # define __WORDSIZE_TIME64_COMPAT32 1 #else # define __WORDSIZE 32 +# define __WORDSIZE_TIME64_COMPAT32 0 +# define __WORDSIZE32_SIZE_ULONG 0 +# define __WORDSIZE32_PTRDIFF_LONG 0 #endif diff --git a/sysdeps/tile/tilepro/bits/wordsize.h b/sysdeps/tile/tilepro/bits/wordsize.h index da587a2..eb9b3c1 100644 --- a/sysdeps/tile/tilepro/bits/wordsize.h +++ b/sysdeps/tile/tilepro/bits/wordsize.h @@ -1,3 +1,7 @@ /* Determine the wordsize from the preprocessor defines. */ #define __WORDSIZE 32 + +#define __WORDSIZE32_SIZE_ULONG 0 +#define __WORDSIZE32_PTRDIFF_LONG 0 +#define __WORDSIZE_TIME64_COMPAT32 0 \ No newline at end of file diff --git a/sysdeps/unix/sysv/linux/alpha/bits/wordsize.h b/sysdeps/unix/sysv/linux/alpha/bits/wordsize.h index 51fc433..1b27601 100644 --- a/sysdeps/unix/sysv/linux/alpha/bits/wordsize.h +++ b/sysdeps/unix/sysv/linux/alpha/bits/wordsize.h @@ -17,6 +17,8 @@ #define __WORDSIZE 64 +#define __WORDSIZE_TIME64_COMPAT32 0 + #if !defined __NO_LONG_DOUBLE_MATH && !defined __LONG_DOUBLE_MATH_OPTIONAL /* Signal that we didn't used to have a `long double'. The changes all diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/wordsize.h b/sysdeps/unix/sysv/linux/powerpc/bits/wordsize.h index 3e8a1e0..109f08c 100644 --- a/sysdeps/unix/sysv/linux/powerpc/bits/wordsize.h +++ b/sysdeps/unix/sysv/linux/powerpc/bits/wordsize.h @@ -5,6 +5,9 @@ # define __WORDSIZE_TIME64_COMPAT32 1 #else # define __WORDSIZE 32 +# define __WORDSIZE_TIME64_COMPAT32 0 +# define __WORDSIZE32_SIZE_ULONG 0 +# define __WORDSIZE32_PTRDIFF_LONG 0 #endif #if !defined __NO_LONG_DOUBLE_MATH && !defined __LONG_DOUBLE_MATH_OPTIONAL diff --git a/sysdeps/unix/sysv/linux/sparc/bits/wordsize.h b/sysdeps/unix/sysv/linux/sparc/bits/wordsize.h index 2d958d2..3564bb1 100644 --- a/sysdeps/unix/sysv/linux/sparc/bits/wordsize.h +++ b/sysdeps/unix/sysv/linux/sparc/bits/wordsize.h @@ -4,8 +4,12 @@ # define __WORDSIZE 64 #else # define __WORDSIZE 32 +# define __WORDSIZE32_SIZE_ULONG 0 +# define __WORDSIZE32_PTRDIFF_LONG 0 #endif +#define __WORDSIZE_TIME64_COMPAT32 0 + #if !defined __NO_LONG_DOUBLE_MATH && !defined __LONG_DOUBLE_MATH_OPTIONAL # if __WORDSIZE == 32 diff --git a/sysdeps/wordsize-32/bits/wordsize.h b/sysdeps/wordsize-32/bits/wordsize.h index 2aa16bc..acb3b14 100644 --- a/sysdeps/wordsize-32/bits/wordsize.h +++ b/sysdeps/wordsize-32/bits/wordsize.h @@ -16,3 +16,7 @@ <http://www.gnu.org/licenses/>. */ #define __WORDSIZE 32 + +#define __WORDSIZE32_SIZE_ULONG 0 +#define __WORDSIZE32_PTRDIFF_LONG 0 +#define __WORDSIZE_TIME64_COMPAT32 0 \ No newline at end of file diff --git a/sysdeps/wordsize-64/bits/wordsize.h b/sysdeps/wordsize-64/bits/wordsize.h index 0944f9e..04eb0f6 100644 --- a/sysdeps/wordsize-64/bits/wordsize.h +++ b/sysdeps/wordsize-64/bits/wordsize.h @@ -16,3 +16,5 @@ <http://www.gnu.org/licenses/>. */ #define __WORDSIZE 64 + +#define __WORDSIZE_TIME64_COMPAT32 0 \ No newline at end of file diff --git a/sysdeps/x86/bits/wordsize.h b/sysdeps/x86/bits/wordsize.h index e25af28..530d253 100644 --- a/sysdeps/x86/bits/wordsize.h +++ b/sysdeps/x86/bits/wordsize.h @@ -4,10 +4,14 @@ # define __WORDSIZE 64 #else # define __WORDSIZE 32 +# define __WORDSIZE32_SIZE_ULONG 0 +# define __WORDSIZE32_PTRDIFF_LONG 0 #endif #ifdef __x86_64__ # define __WORDSIZE_TIME64_COMPAT32 1 /* Both x86-64 and x32 use the 64-bit system call interface. */ # define __SYSCALL_WORDSIZE 64 +#else +# define __WORDSIZE_TIME64_COMPAT32 0 #endif