From 4232d171a620662aaed650879936eac60aefd9e0 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Tue, 3 May 2022 18:58:18 +0200 Subject: [PATCH] sys/types.h: Don't include sys/_stdint.h By including sys/_stdint.h, all types from stdint.h are exposed even if stdint.h isn't pulled in explicitely. Include --- newlib/libc/include/machine/ieee.h | 98 ++++++++++++------------- newlib/libc/include/sys/time.h | 44 +++++------ newlib/libc/include/sys/types.h | 2 +- newlib/libc/stdlib/arc4random_uniform.c | 1 + winsup/cygserver/bsd_helper.h | 1 + winsup/cygwin/gcrt0.c | 1 + winsup/cygwin/include/cygwin/in.h | 16 ++-- winsup/cygwin/include/cygwin/socket.h | 8 +- winsup/cygwin/include/sys/dirent.h | 4 +- winsup/cygwin/winsup.h | 1 + 10 files changed, 90 insertions(+), 86 deletions(-) diff --git a/newlib/libc/include/machine/ieee.h b/newlib/libc/include/machine/ieee.h index 0656909ab..251d3036a 100644 --- a/newlib/libc/include/machine/ieee.h +++ b/newlib/libc/include/machine/ieee.h @@ -12,21 +12,21 @@ } while (0) #ifdef __IEEE_LITTLE_ENDIAN struct ieee_ext { - uint32_t ext_frac:23; - uint32_t ext_exp:8; - uint32_t ext_sign:1; + __uint32_t ext_frac:23; + __uint32_t ext_exp:8; + __uint32_t ext_sign:1; }; #endif #ifdef __IEEE_BIG_ENDIAN struct ieee_ext { #ifndef ___IEEE_BYTES_LITTLE_ENDIAN - uint32_t ext_sign:1; - uint32_t ext_exp:8; - uint32_t ext_frac:23; + __uint32_t ext_sign:1; + __uint32_t ext_exp:8; + __uint32_t ext_frac:23; #else /* ARMEL without __VFP_FP__ */ - uint32_t ext_frac:23; - uint32_t ext_exp:8; - uint32_t ext_sign:1; + __uint32_t ext_frac:23; + __uint32_t ext_exp:8; + __uint32_t ext_sign:1; #endif }; #endif @@ -38,24 +38,24 @@ struct ieee_ext { } while (0) #ifdef __IEEE_LITTLE_ENDIAN struct ieee_ext { - uint32_t ext_fracl; - uint32_t ext_frach:20; - uint32_t ext_exp:11; - uint32_t ext_sign:1; + __uint32_t ext_fracl; + __uint32_t ext_frach:20; + __uint32_t ext_exp:11; + __uint32_t ext_sign:1; }; #endif #ifdef __IEEE_BIG_ENDIAN struct ieee_ext { #ifndef ___IEEE_BYTES_LITTLE_ENDIAN - uint32_t ext_sign:1; - uint32_t ext_exp:11; - uint32_t ext_frach:20; + __uint32_t ext_sign:1; + __uint32_t ext_exp:11; + __uint32_t ext_frach:20; #else /* ARMEL without __VFP_FP__ */ - uint32_t ext_frach:20; - uint32_t ext_exp:11; - uint32_t ext_sign:1; + __uint32_t ext_frach:20; + __uint32_t ext_exp:11; + __uint32_t ext_sign:1; #endif - uint32_t ext_fracl; + __uint32_t ext_fracl; }; #endif #elif LDBL_MANT_DIG == 64 @@ -65,27 +65,27 @@ struct ieee_ext { } while (0) #ifdef __IEEE_LITTLE_ENDIAN /* for Intel CPU */ struct ieee_ext { - uint32_t ext_fracl; - uint32_t ext_frach; - uint32_t ext_exp:15; - uint32_t ext_sign:1; - uint32_t ext_padl:16; - uint32_t ext_padh; + __uint32_t ext_fracl; + __uint32_t ext_frach; + __uint32_t ext_exp:15; + __uint32_t ext_sign:1; + __uint32_t ext_padl:16; + __uint32_t ext_padh; }; #endif #ifdef __IEEE_BIG_ENDIAN struct ieee_ext { #ifndef ___IEEE_BYTES_LITTLE_ENDIAN /* for m68k */ - uint32_t ext_sign:1; - uint32_t ext_exp:15; - uint32_t ext_pad:16; + __uint32_t ext_sign:1; + __uint32_t ext_exp:15; + __uint32_t ext_pad:16; #else /* ARM FPA10 math coprocessor */ - uint32_t ext_exp:15; - uint32_t ext_pad:16; - uint32_t ext_sign:1; + __uint32_t ext_exp:15; + __uint32_t ext_pad:16; + __uint32_t ext_sign:1; #endif - uint32_t ext_frach; - uint32_t ext_fracl; + __uint32_t ext_frach; + __uint32_t ext_fracl; }; #endif #elif LDBL_MANT_DIG == 113 @@ -98,28 +98,28 @@ struct ieee_ext { } while (0) #ifdef __IEEE_LITTLE_ENDIAN struct ieee_ext { - uint32_t ext_fracl; - uint32_t ext_fraclm; - uint32_t ext_frachm; - uint32_t ext_frach:16; - uint32_t ext_exp:15; - uint32_t ext_sign:1; + __uint32_t ext_fracl; + __uint32_t ext_fraclm; + __uint32_t ext_frachm; + __uint32_t ext_frach:16; + __uint32_t ext_exp:15; + __uint32_t ext_sign:1; }; #endif #ifdef __IEEE_BIG_ENDIAN struct ieee_ext { #ifndef ___IEEE_BYTES_LITTLE_ENDIAN - uint32_t ext_sign:1; - uint32_t ext_exp:15; - uint32_t ext_frach:16; + __uint32_t ext_sign:1; + __uint32_t ext_exp:15; + __uint32_t ext_frach:16; #else /* ARMEL without __VFP_FP__ */ - uint32_t ext_frach:16; - uint32_t ext_exp:15; - uint32_t ext_sign:1; + __uint32_t ext_frach:16; + __uint32_t ext_exp:15; + __uint32_t ext_sign:1; #endif - uint32_t ext_frachm; - uint32_t ext_fraclm; - uint32_t ext_fracl; + __uint32_t ext_frachm; + __uint32_t ext_fraclm; + __uint32_t ext_fracl; }; #endif #endif diff --git a/newlib/libc/include/sys/time.h b/newlib/libc/include/sys/time.h index 5a3dec7ab..0d68ab8ab 100644 --- a/newlib/libc/include/sys/time.h +++ b/newlib/libc/include/sys/time.h @@ -64,13 +64,13 @@ struct timezone { #if __BSD_VISIBLE struct bintime { time_t sec; - uint64_t frac; + __uint64_t frac; }; static __inline void -bintime_addx(struct bintime *_bt, uint64_t _x) +bintime_addx(struct bintime *_bt, __uint64_t _x) { - uint64_t _u; + __uint64_t _u; _u = _bt->frac; _bt->frac += _x; @@ -81,7 +81,7 @@ bintime_addx(struct bintime *_bt, uint64_t _x) static __inline void bintime_add(struct bintime *_bt, const struct bintime *_bt2) { - uint64_t _u; + __uint64_t _u; _u = _bt->frac; _bt->frac += _bt2->frac; @@ -93,7 +93,7 @@ bintime_add(struct bintime *_bt, const struct bintime *_bt2) static __inline void bintime_sub(struct bintime *_bt, const struct bintime *_bt2) { - uint64_t _u; + __uint64_t _u; _u = _bt->frac; _bt->frac -= _bt2->frac; @@ -105,7 +105,7 @@ bintime_sub(struct bintime *_bt, const struct bintime *_bt2) static __inline void bintime_mul(struct bintime *_bt, u_int _x) { - uint64_t _p1, _p2; + __uint64_t _p1, _p2; _p1 = (_bt->frac & 0xffffffffull) * _x; _p2 = (_bt->frac >> 32) * _x + (_p1 >> 32); @@ -124,7 +124,7 @@ bintime_shift(struct bintime *_bt, int _exp) _bt->frac <<= _exp; } else if (_exp < 0) { _bt->frac >>= -_exp; - _bt->frac |= (uint64_t)_bt->sec << (64 + _exp); + _bt->frac |= (__uint64_t)_bt->sec << (64 + _exp); _bt->sec >>= -_exp; } } @@ -184,14 +184,14 @@ sbttobt(sbintime_t _sbt) * ((unit * 2^63 / SIFACTOR) + 2^31-1) >> 32 * and use pre-computed constants that are the ceil of the 2^63 / SIFACTOR * term to ensure we are using exactly the right constant. We use the lesser - * evil of ull rather than a uint64_t cast to ensure we have well defined + * evil of ull rather than a __uint64_t cast to ensure we have well defined * right shift semantics. With these changes, we get all the ns, us and ms * conversions back and forth right. */ -static __inline int64_t +static __inline __int64_t sbttons(sbintime_t _sbt) { - uint64_t ns; + __uint64_t ns; ns = _sbt; if (ns >= SBT_1S) @@ -203,7 +203,7 @@ sbttons(sbintime_t _sbt) } static __inline sbintime_t -nstosbt(int64_t _ns) +nstosbt(__int64_t _ns) { sbintime_t sb = 0; @@ -216,7 +216,7 @@ nstosbt(int64_t _ns) return (sb); } -static __inline int64_t +static __inline __int64_t sbttous(sbintime_t _sbt) { @@ -224,7 +224,7 @@ sbttous(sbintime_t _sbt) } static __inline sbintime_t -ustosbt(int64_t _us) +ustosbt(__int64_t _us) { sbintime_t sb = 0; @@ -237,7 +237,7 @@ ustosbt(int64_t _us) return (sb); } -static __inline int64_t +static __inline __int64_t sbttoms(sbintime_t _sbt) { @@ -245,7 +245,7 @@ sbttoms(sbintime_t _sbt) } static __inline sbintime_t -mstosbt(int64_t _ms) +mstosbt(__int64_t _ms) { sbintime_t sb = 0; @@ -277,8 +277,8 @@ bintime2timespec(const struct bintime *_bt, struct timespec *_ts) { _ts->tv_sec = _bt->sec; - _ts->tv_nsec = ((uint64_t)1000000000 * - (uint32_t)(_bt->frac >> 32)) >> 32; + _ts->tv_nsec = ((__uint64_t)1000000000 * + (__uint32_t)(_bt->frac >> 32)) >> 32; } static __inline void @@ -287,7 +287,7 @@ timespec2bintime(const struct timespec *_ts, struct bintime *_bt) _bt->sec = _ts->tv_sec; /* 18446744073 = int(2^64 / 1000000000) */ - _bt->frac = _ts->tv_nsec * (uint64_t)18446744073LL; + _bt->frac = _ts->tv_nsec * (__uint64_t)18446744073LL; } static __inline void @@ -295,7 +295,7 @@ bintime2timeval(const struct bintime *_bt, struct timeval *_tv) { _tv->tv_sec = _bt->sec; - _tv->tv_usec = ((uint64_t)1000000 * (uint32_t)(_bt->frac >> 32)) >> 32; + _tv->tv_usec = ((__uint64_t)1000000 * (__uint32_t)(_bt->frac >> 32)) >> 32; } static __inline void @@ -304,7 +304,7 @@ timeval2bintime(const struct timeval *_tv, struct bintime *_bt) _bt->sec = _tv->tv_sec; /* 18446744073709 = int(2^64 / 1000000) */ - _bt->frac = _tv->tv_usec * (uint64_t)18446744073709LL; + _bt->frac = _tv->tv_usec * (__uint64_t)18446744073709LL; } static __inline struct timespec @@ -313,7 +313,7 @@ sbttots(sbintime_t _sbt) struct timespec _ts; _ts.tv_sec = _sbt >> 32; - _ts.tv_nsec = sbttons((uint32_t)_sbt); + _ts.tv_nsec = sbttons((__uint32_t)_sbt); return (_ts); } @@ -330,7 +330,7 @@ sbttotv(sbintime_t _sbt) struct timeval _tv; _tv.tv_sec = _sbt >> 32; - _tv.tv_usec = sbttous((uint32_t)_sbt); + _tv.tv_usec = sbttous((__uint32_t)_sbt); return (_tv); } diff --git a/newlib/libc/include/sys/types.h b/newlib/libc/include/sys/types.h index 4613ac81f..42e98ce97 100644 --- a/newlib/libc/include/sys/types.h +++ b/newlib/libc/include/sys/types.h @@ -43,7 +43,7 @@ typedef __intptr_t register_t; #define _SYS_TYPES_H #include -#include +#include #if __BSD_VISIBLE #include diff --git a/newlib/libc/stdlib/arc4random_uniform.c b/newlib/libc/stdlib/arc4random_uniform.c index 1aa9a622f..b5ed243a8 100644 --- a/newlib/libc/stdlib/arc4random_uniform.c +++ b/newlib/libc/stdlib/arc4random_uniform.c @@ -18,6 +18,7 @@ #include #include +#include /* * Calculate a uniformly distributed random number less than upper_bound diff --git a/winsup/cygserver/bsd_helper.h b/winsup/cygserver/bsd_helper.h index b2d866277..778d4ee73 100644 --- a/winsup/cygserver/bsd_helper.h +++ b/winsup/cygserver/bsd_helper.h @@ -10,6 +10,7 @@ details. */ #include #include +#include enum tun_bool_t { TUN_UNDEF = 0, diff --git a/winsup/cygwin/gcrt0.c b/winsup/cygwin/gcrt0.c index f02b3be59..d66bdd72c 100644 --- a/winsup/cygwin/gcrt0.c +++ b/winsup/cygwin/gcrt0.c @@ -13,6 +13,7 @@ details. */ #include #include +#include #ifdef __MINGW32__ #include <_bsd_types.h> diff --git a/winsup/cygwin/include/cygwin/in.h b/winsup/cygwin/include/cygwin/in.h index 42b776653..83a01d3a3 100644 --- a/winsup/cygwin/include/cygwin/in.h +++ b/winsup/cygwin/include/cygwin/in.h @@ -148,8 +148,8 @@ struct ip_msfilter { struct in_addr imsf_multiaddr; struct in_addr imsf_interface; - uint32_t imsf_fmode; - uint32_t imsf_numsrc; + __uint32_t imsf_fmode; + __uint32_t imsf_numsrc; struct in_addr imsf_slist[1]; }; @@ -160,30 +160,30 @@ struct ip_msfilter struct in_pktinfo { struct in_addr ipi_addr; - uint32_t ipi_ifindex; + __uint32_t ipi_ifindex; }; /* Request struct for IP agnostic multicast socket ops */ struct group_req { - uint32_t gr_interface; + __uint32_t gr_interface; struct sockaddr_storage gr_group; }; struct group_source_req { - uint32_t gsr_interface; + __uint32_t gsr_interface; struct sockaddr_storage gsr_group; struct sockaddr_storage gsr_source; }; struct group_filter { - uint32_t gf_interface; + __uint32_t gf_interface; struct sockaddr_storage gf_group; - uint32_t gf_fmode; - uint32_t gf_numsrc; + __uint32_t gf_fmode; + __uint32_t gf_numsrc; struct sockaddr_storage gf_slist[1]; }; diff --git a/winsup/cygwin/include/cygwin/socket.h b/winsup/cygwin/include/cygwin/socket.h index 0ca8300d9..4d7a521a2 100644 --- a/winsup/cygwin/include/cygwin/socket.h +++ b/winsup/cygwin/include/cygwin/socket.h @@ -31,16 +31,16 @@ struct sockaddr { /* Definition of sockaddr_storage according to SUSv3. */ #define _SS_MAXSIZE 128 /* Maximum size. */ -#define _SS_ALIGNSIZE (sizeof (int64_t))/* Desired alignment. */ +#define _SS_ALIGNSIZE (sizeof (__int64_t))/* Desired alignment. */ #define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof (sa_family_t)) #define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (sa_family_t) \ + _SS_PAD1SIZE + _SS_ALIGNSIZE)) struct sockaddr_storage { sa_family_t ss_family; - char _ss_pad1[_SS_PAD1SIZE]; - int64_t __ss_align; - char _ss_pad2[_SS_PAD2SIZE]; + __int8_t _ss_pad1[_SS_PAD1SIZE]; + __int64_t __ss_align; + __int8_t _ss_pad2[_SS_PAD2SIZE]; }; #endif diff --git a/winsup/cygwin/include/sys/dirent.h b/winsup/cygwin/include/sys/dirent.h index 0e7a78cc0..393c27e41 100644 --- a/winsup/cygwin/include/sys/dirent.h +++ b/winsup/cygwin/include/sys/dirent.h @@ -21,7 +21,7 @@ #define _DIRENT_HAVE_D_TYPE struct dirent { - uint32_t __d_version; /* Used internally */ + __uint32_t __d_version; /* Used internally */ ino_t d_ino; unsigned char d_type; unsigned char __d_unused1[3]; @@ -51,7 +51,7 @@ typedef struct __DIR char *__d_dirname; /* directory name with trailing '*' */ __int32_t __d_position; /* used by telldir/seekdir */ int __d_fd; - uintptr_t __d_internal; + __uintptr_t __d_internal; void *__handle; void *__fh; unsigned __flags; diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h index 1f265ec28..3cfae786c 100644 --- a/winsup/cygwin/winsup.h +++ b/winsup/cygwin/winsup.h @@ -36,6 +36,7 @@ details. */ #include #include #include +#include /* Declarations for functions used in C and C++ code. */ #ifdef __cplusplus