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
<machine/_default_types.h instead. Fix up newlib and Cygwin
files which rely on stdint.h types, too.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2022-05-03 18:58:18 +02:00
parent 5a6de512ab
commit 4232d171a6
10 changed files with 90 additions and 86 deletions

View File

@ -12,21 +12,21 @@
} while (0) } while (0)
#ifdef __IEEE_LITTLE_ENDIAN #ifdef __IEEE_LITTLE_ENDIAN
struct ieee_ext { struct ieee_ext {
uint32_t ext_frac:23; __uint32_t ext_frac:23;
uint32_t ext_exp:8; __uint32_t ext_exp:8;
uint32_t ext_sign:1; __uint32_t ext_sign:1;
}; };
#endif #endif
#ifdef __IEEE_BIG_ENDIAN #ifdef __IEEE_BIG_ENDIAN
struct ieee_ext { struct ieee_ext {
#ifndef ___IEEE_BYTES_LITTLE_ENDIAN #ifndef ___IEEE_BYTES_LITTLE_ENDIAN
uint32_t ext_sign:1; __uint32_t ext_sign:1;
uint32_t ext_exp:8; __uint32_t ext_exp:8;
uint32_t ext_frac:23; __uint32_t ext_frac:23;
#else /* ARMEL without __VFP_FP__ */ #else /* ARMEL without __VFP_FP__ */
uint32_t ext_frac:23; __uint32_t ext_frac:23;
uint32_t ext_exp:8; __uint32_t ext_exp:8;
uint32_t ext_sign:1; __uint32_t ext_sign:1;
#endif #endif
}; };
#endif #endif
@ -38,24 +38,24 @@ struct ieee_ext {
} while (0) } while (0)
#ifdef __IEEE_LITTLE_ENDIAN #ifdef __IEEE_LITTLE_ENDIAN
struct ieee_ext { struct ieee_ext {
uint32_t ext_fracl; __uint32_t ext_fracl;
uint32_t ext_frach:20; __uint32_t ext_frach:20;
uint32_t ext_exp:11; __uint32_t ext_exp:11;
uint32_t ext_sign:1; __uint32_t ext_sign:1;
}; };
#endif #endif
#ifdef __IEEE_BIG_ENDIAN #ifdef __IEEE_BIG_ENDIAN
struct ieee_ext { struct ieee_ext {
#ifndef ___IEEE_BYTES_LITTLE_ENDIAN #ifndef ___IEEE_BYTES_LITTLE_ENDIAN
uint32_t ext_sign:1; __uint32_t ext_sign:1;
uint32_t ext_exp:11; __uint32_t ext_exp:11;
uint32_t ext_frach:20; __uint32_t ext_frach:20;
#else /* ARMEL without __VFP_FP__ */ #else /* ARMEL without __VFP_FP__ */
uint32_t ext_frach:20; __uint32_t ext_frach:20;
uint32_t ext_exp:11; __uint32_t ext_exp:11;
uint32_t ext_sign:1; __uint32_t ext_sign:1;
#endif #endif
uint32_t ext_fracl; __uint32_t ext_fracl;
}; };
#endif #endif
#elif LDBL_MANT_DIG == 64 #elif LDBL_MANT_DIG == 64
@ -65,27 +65,27 @@ struct ieee_ext {
} while (0) } while (0)
#ifdef __IEEE_LITTLE_ENDIAN /* for Intel CPU */ #ifdef __IEEE_LITTLE_ENDIAN /* for Intel CPU */
struct ieee_ext { struct ieee_ext {
uint32_t ext_fracl; __uint32_t ext_fracl;
uint32_t ext_frach; __uint32_t ext_frach;
uint32_t ext_exp:15; __uint32_t ext_exp:15;
uint32_t ext_sign:1; __uint32_t ext_sign:1;
uint32_t ext_padl:16; __uint32_t ext_padl:16;
uint32_t ext_padh; __uint32_t ext_padh;
}; };
#endif #endif
#ifdef __IEEE_BIG_ENDIAN #ifdef __IEEE_BIG_ENDIAN
struct ieee_ext { struct ieee_ext {
#ifndef ___IEEE_BYTES_LITTLE_ENDIAN /* for m68k */ #ifndef ___IEEE_BYTES_LITTLE_ENDIAN /* for m68k */
uint32_t ext_sign:1; __uint32_t ext_sign:1;
uint32_t ext_exp:15; __uint32_t ext_exp:15;
uint32_t ext_pad:16; __uint32_t ext_pad:16;
#else /* ARM FPA10 math coprocessor */ #else /* ARM FPA10 math coprocessor */
uint32_t ext_exp:15; __uint32_t ext_exp:15;
uint32_t ext_pad:16; __uint32_t ext_pad:16;
uint32_t ext_sign:1; __uint32_t ext_sign:1;
#endif #endif
uint32_t ext_frach; __uint32_t ext_frach;
uint32_t ext_fracl; __uint32_t ext_fracl;
}; };
#endif #endif
#elif LDBL_MANT_DIG == 113 #elif LDBL_MANT_DIG == 113
@ -98,28 +98,28 @@ struct ieee_ext {
} while (0) } while (0)
#ifdef __IEEE_LITTLE_ENDIAN #ifdef __IEEE_LITTLE_ENDIAN
struct ieee_ext { struct ieee_ext {
uint32_t ext_fracl; __uint32_t ext_fracl;
uint32_t ext_fraclm; __uint32_t ext_fraclm;
uint32_t ext_frachm; __uint32_t ext_frachm;
uint32_t ext_frach:16; __uint32_t ext_frach:16;
uint32_t ext_exp:15; __uint32_t ext_exp:15;
uint32_t ext_sign:1; __uint32_t ext_sign:1;
}; };
#endif #endif
#ifdef __IEEE_BIG_ENDIAN #ifdef __IEEE_BIG_ENDIAN
struct ieee_ext { struct ieee_ext {
#ifndef ___IEEE_BYTES_LITTLE_ENDIAN #ifndef ___IEEE_BYTES_LITTLE_ENDIAN
uint32_t ext_sign:1; __uint32_t ext_sign:1;
uint32_t ext_exp:15; __uint32_t ext_exp:15;
uint32_t ext_frach:16; __uint32_t ext_frach:16;
#else /* ARMEL without __VFP_FP__ */ #else /* ARMEL without __VFP_FP__ */
uint32_t ext_frach:16; __uint32_t ext_frach:16;
uint32_t ext_exp:15; __uint32_t ext_exp:15;
uint32_t ext_sign:1; __uint32_t ext_sign:1;
#endif #endif
uint32_t ext_frachm; __uint32_t ext_frachm;
uint32_t ext_fraclm; __uint32_t ext_fraclm;
uint32_t ext_fracl; __uint32_t ext_fracl;
}; };
#endif #endif
#endif #endif

View File

@ -64,13 +64,13 @@ struct timezone {
#if __BSD_VISIBLE #if __BSD_VISIBLE
struct bintime { struct bintime {
time_t sec; time_t sec;
uint64_t frac; __uint64_t frac;
}; };
static __inline void 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; _u = _bt->frac;
_bt->frac += _x; _bt->frac += _x;
@ -81,7 +81,7 @@ bintime_addx(struct bintime *_bt, uint64_t _x)
static __inline void static __inline void
bintime_add(struct bintime *_bt, const struct bintime *_bt2) bintime_add(struct bintime *_bt, const struct bintime *_bt2)
{ {
uint64_t _u; __uint64_t _u;
_u = _bt->frac; _u = _bt->frac;
_bt->frac += _bt2->frac; _bt->frac += _bt2->frac;
@ -93,7 +93,7 @@ bintime_add(struct bintime *_bt, const struct bintime *_bt2)
static __inline void static __inline void
bintime_sub(struct bintime *_bt, const struct bintime *_bt2) bintime_sub(struct bintime *_bt, const struct bintime *_bt2)
{ {
uint64_t _u; __uint64_t _u;
_u = _bt->frac; _u = _bt->frac;
_bt->frac -= _bt2->frac; _bt->frac -= _bt2->frac;
@ -105,7 +105,7 @@ bintime_sub(struct bintime *_bt, const struct bintime *_bt2)
static __inline void static __inline void
bintime_mul(struct bintime *_bt, u_int _x) bintime_mul(struct bintime *_bt, u_int _x)
{ {
uint64_t _p1, _p2; __uint64_t _p1, _p2;
_p1 = (_bt->frac & 0xffffffffull) * _x; _p1 = (_bt->frac & 0xffffffffull) * _x;
_p2 = (_bt->frac >> 32) * _x + (_p1 >> 32); _p2 = (_bt->frac >> 32) * _x + (_p1 >> 32);
@ -124,7 +124,7 @@ bintime_shift(struct bintime *_bt, int _exp)
_bt->frac <<= _exp; _bt->frac <<= _exp;
} else if (_exp < 0) { } else if (_exp < 0) {
_bt->frac >>= -_exp; _bt->frac >>= -_exp;
_bt->frac |= (uint64_t)_bt->sec << (64 + _exp); _bt->frac |= (__uint64_t)_bt->sec << (64 + _exp);
_bt->sec >>= -_exp; _bt->sec >>= -_exp;
} }
} }
@ -184,14 +184,14 @@ sbttobt(sbintime_t _sbt)
* ((unit * 2^63 / SIFACTOR) + 2^31-1) >> 32 * ((unit * 2^63 / SIFACTOR) + 2^31-1) >> 32
* and use pre-computed constants that are the ceil of the 2^63 / SIFACTOR * 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 * 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 * right shift semantics. With these changes, we get all the ns, us and ms
* conversions back and forth right. * conversions back and forth right.
*/ */
static __inline int64_t static __inline __int64_t
sbttons(sbintime_t _sbt) sbttons(sbintime_t _sbt)
{ {
uint64_t ns; __uint64_t ns;
ns = _sbt; ns = _sbt;
if (ns >= SBT_1S) if (ns >= SBT_1S)
@ -203,7 +203,7 @@ sbttons(sbintime_t _sbt)
} }
static __inline sbintime_t static __inline sbintime_t
nstosbt(int64_t _ns) nstosbt(__int64_t _ns)
{ {
sbintime_t sb = 0; sbintime_t sb = 0;
@ -216,7 +216,7 @@ nstosbt(int64_t _ns)
return (sb); return (sb);
} }
static __inline int64_t static __inline __int64_t
sbttous(sbintime_t _sbt) sbttous(sbintime_t _sbt)
{ {
@ -224,7 +224,7 @@ sbttous(sbintime_t _sbt)
} }
static __inline sbintime_t static __inline sbintime_t
ustosbt(int64_t _us) ustosbt(__int64_t _us)
{ {
sbintime_t sb = 0; sbintime_t sb = 0;
@ -237,7 +237,7 @@ ustosbt(int64_t _us)
return (sb); return (sb);
} }
static __inline int64_t static __inline __int64_t
sbttoms(sbintime_t _sbt) sbttoms(sbintime_t _sbt)
{ {
@ -245,7 +245,7 @@ sbttoms(sbintime_t _sbt)
} }
static __inline sbintime_t static __inline sbintime_t
mstosbt(int64_t _ms) mstosbt(__int64_t _ms)
{ {
sbintime_t sb = 0; sbintime_t sb = 0;
@ -277,8 +277,8 @@ bintime2timespec(const struct bintime *_bt, struct timespec *_ts)
{ {
_ts->tv_sec = _bt->sec; _ts->tv_sec = _bt->sec;
_ts->tv_nsec = ((uint64_t)1000000000 * _ts->tv_nsec = ((__uint64_t)1000000000 *
(uint32_t)(_bt->frac >> 32)) >> 32; (__uint32_t)(_bt->frac >> 32)) >> 32;
} }
static __inline void static __inline void
@ -287,7 +287,7 @@ timespec2bintime(const struct timespec *_ts, struct bintime *_bt)
_bt->sec = _ts->tv_sec; _bt->sec = _ts->tv_sec;
/* 18446744073 = int(2^64 / 1000000000) */ /* 18446744073 = int(2^64 / 1000000000) */
_bt->frac = _ts->tv_nsec * (uint64_t)18446744073LL; _bt->frac = _ts->tv_nsec * (__uint64_t)18446744073LL;
} }
static __inline void static __inline void
@ -295,7 +295,7 @@ bintime2timeval(const struct bintime *_bt, struct timeval *_tv)
{ {
_tv->tv_sec = _bt->sec; _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 static __inline void
@ -304,7 +304,7 @@ timeval2bintime(const struct timeval *_tv, struct bintime *_bt)
_bt->sec = _tv->tv_sec; _bt->sec = _tv->tv_sec;
/* 18446744073709 = int(2^64 / 1000000) */ /* 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 static __inline struct timespec
@ -313,7 +313,7 @@ sbttots(sbintime_t _sbt)
struct timespec _ts; struct timespec _ts;
_ts.tv_sec = _sbt >> 32; _ts.tv_sec = _sbt >> 32;
_ts.tv_nsec = sbttons((uint32_t)_sbt); _ts.tv_nsec = sbttons((__uint32_t)_sbt);
return (_ts); return (_ts);
} }
@ -330,7 +330,7 @@ sbttotv(sbintime_t _sbt)
struct timeval _tv; struct timeval _tv;
_tv.tv_sec = _sbt >> 32; _tv.tv_sec = _sbt >> 32;
_tv.tv_usec = sbttous((uint32_t)_sbt); _tv.tv_usec = sbttous((__uint32_t)_sbt);
return (_tv); return (_tv);
} }

View File

@ -43,7 +43,7 @@ typedef __intptr_t register_t;
#define _SYS_TYPES_H #define _SYS_TYPES_H
#include <sys/_types.h> #include <sys/_types.h>
#include <sys/_stdint.h> #include <machine/_default_types.h>
#if __BSD_VISIBLE #if __BSD_VISIBLE
#include <machine/endian.h> #include <machine/endian.h>

View File

@ -18,6 +18,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
/* /*
* Calculate a uniformly distributed random number less than upper_bound * Calculate a uniformly distributed random number less than upper_bound

View File

@ -10,6 +10,7 @@ details. */
#include <sys/types.h> #include <sys/types.h>
#include <sys/syslog.h> #include <sys/syslog.h>
#include <stdint.h>
enum tun_bool_t { enum tun_bool_t {
TUN_UNDEF = 0, TUN_UNDEF = 0,

View File

@ -13,6 +13,7 @@ details. */
#include <sys/types.h> #include <sys/types.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#ifdef __MINGW32__ #ifdef __MINGW32__
#include <_bsd_types.h> #include <_bsd_types.h>

View File

@ -148,8 +148,8 @@ struct ip_msfilter
{ {
struct in_addr imsf_multiaddr; struct in_addr imsf_multiaddr;
struct in_addr imsf_interface; struct in_addr imsf_interface;
uint32_t imsf_fmode; __uint32_t imsf_fmode;
uint32_t imsf_numsrc; __uint32_t imsf_numsrc;
struct in_addr imsf_slist[1]; struct in_addr imsf_slist[1];
}; };
@ -160,30 +160,30 @@ struct ip_msfilter
struct in_pktinfo struct in_pktinfo
{ {
struct in_addr ipi_addr; struct in_addr ipi_addr;
uint32_t ipi_ifindex; __uint32_t ipi_ifindex;
}; };
/* Request struct for IP agnostic multicast socket ops */ /* Request struct for IP agnostic multicast socket ops */
struct group_req struct group_req
{ {
uint32_t gr_interface; __uint32_t gr_interface;
struct sockaddr_storage gr_group; struct sockaddr_storage gr_group;
}; };
struct group_source_req struct group_source_req
{ {
uint32_t gsr_interface; __uint32_t gsr_interface;
struct sockaddr_storage gsr_group; struct sockaddr_storage gsr_group;
struct sockaddr_storage gsr_source; struct sockaddr_storage gsr_source;
}; };
struct group_filter struct group_filter
{ {
uint32_t gf_interface; __uint32_t gf_interface;
struct sockaddr_storage gf_group; struct sockaddr_storage gf_group;
uint32_t gf_fmode; __uint32_t gf_fmode;
uint32_t gf_numsrc; __uint32_t gf_numsrc;
struct sockaddr_storage gf_slist[1]; struct sockaddr_storage gf_slist[1];
}; };

View File

@ -31,16 +31,16 @@ struct sockaddr {
/* Definition of sockaddr_storage according to SUSv3. */ /* Definition of sockaddr_storage according to SUSv3. */
#define _SS_MAXSIZE 128 /* Maximum size. */ #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_PAD1SIZE (_SS_ALIGNSIZE - sizeof (sa_family_t))
#define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (sa_family_t) \ #define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (sa_family_t) \
+ _SS_PAD1SIZE + _SS_ALIGNSIZE)) + _SS_PAD1SIZE + _SS_ALIGNSIZE))
struct sockaddr_storage { struct sockaddr_storage {
sa_family_t ss_family; sa_family_t ss_family;
char _ss_pad1[_SS_PAD1SIZE]; __int8_t _ss_pad1[_SS_PAD1SIZE];
int64_t __ss_align; __int64_t __ss_align;
char _ss_pad2[_SS_PAD2SIZE]; __int8_t _ss_pad2[_SS_PAD2SIZE];
}; };
#endif #endif

View File

@ -21,7 +21,7 @@
#define _DIRENT_HAVE_D_TYPE #define _DIRENT_HAVE_D_TYPE
struct dirent struct dirent
{ {
uint32_t __d_version; /* Used internally */ __uint32_t __d_version; /* Used internally */
ino_t d_ino; ino_t d_ino;
unsigned char d_type; unsigned char d_type;
unsigned char __d_unused1[3]; unsigned char __d_unused1[3];
@ -51,7 +51,7 @@ typedef struct __DIR
char *__d_dirname; /* directory name with trailing '*' */ char *__d_dirname; /* directory name with trailing '*' */
__int32_t __d_position; /* used by telldir/seekdir */ __int32_t __d_position; /* used by telldir/seekdir */
int __d_fd; int __d_fd;
uintptr_t __d_internal; __uintptr_t __d_internal;
void *__handle; void *__handle;
void *__fh; void *__fh;
unsigned __flags; unsigned __flags;

View File

@ -36,6 +36,7 @@ details. */
#include <sys/types.h> #include <sys/types.h>
#include <sys/strace.h> #include <sys/strace.h>
#include <sys/smallprint.h> #include <sys/smallprint.h>
#include <stdint.h>
/* Declarations for functions used in C and C++ code. */ /* Declarations for functions used in C and C++ code. */
#ifdef __cplusplus #ifdef __cplusplus