From 897d3a3cc4b84f1ce4f598f048c4588b5acb81f9 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 1 Apr 2015 20:34:08 +0200 Subject: [PATCH] Add for FreeBSD compatibility * libc/include/sys/_stdint.h: New file. * libc/include/stdint.h (int8_t): Move to . (uint8_t): Likewise. (int16_t): Likewise. (uint16_t): Likewise. (int32_t): Likewise. (uint32_t): Likewise. (int64_t): Likewise. (uint64_t): Likewise. (intptr_t): Likewise. (uintptr_t): Likewise. * libc/include/sys/types.h: Include . * libc/sys/rtems/machine/_types.h: Remove include. * libc/sys/time.h>: Replace __uint32_t with uint32_t and __uint64_t with uint64_t. Signed-off-by: Corinna Vinschen --- newlib/ChangeLog | 18 ++++++++++ newlib/libc/include/stdint.h | 28 +-------------- newlib/libc/include/sys/_stdint.h | 49 ++++++++++++++++++++++++++ newlib/libc/include/sys/time.h | 36 +++++++++---------- newlib/libc/include/sys/types.h | 1 + newlib/libc/sys/rtems/machine/_types.h | 1 - 6 files changed, 87 insertions(+), 46 deletions(-) create mode 100644 newlib/libc/include/sys/_stdint.h diff --git a/newlib/ChangeLog b/newlib/ChangeLog index d6d194af0..1d43b0df2 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,21 @@ +2015-04-01 Sebastian Huber + + * libc/include/sys/_stdint.h: New file. + * libc/include/stdint.h (int8_t): Move to . + (uint8_t): Likewise. + (int16_t): Likewise. + (uint16_t): Likewise. + (int32_t): Likewise. + (uint32_t): Likewise. + (int64_t): Likewise. + (uint64_t): Likewise. + (intptr_t): Likewise. + (uintptr_t): Likewise. + * libc/include/sys/types.h: Include . + * libc/sys/rtems/machine/_types.h: Remove include. + * libc/sys/time.h>: Replace __uint32_t with uint32_t and + __uint64_t with uint64_t. + 2015-04-01 Jon TURNEY * libc/include/sys/signal.h (stack_t): Make typedef generally diff --git a/newlib/libc/include/stdint.h b/newlib/libc/include/stdint.h index 7386164b9..a2c9fea03 100644 --- a/newlib/libc/include/stdint.h +++ b/newlib/libc/include/stdint.h @@ -11,53 +11,30 @@ #include #include +#include #ifdef __cplusplus extern "C" { #endif -#ifdef ___int8_t_defined -typedef __int8_t int8_t ; -typedef __uint8_t uint8_t ; -#define __int8_t_defined 1 -#endif - #ifdef ___int_least8_t_defined typedef __int_least8_t int_least8_t; typedef __uint_least8_t uint_least8_t; #define __int_least8_t_defined 1 #endif -#ifdef ___int16_t_defined -typedef __int16_t int16_t ; -typedef __uint16_t uint16_t ; -#define __int16_t_defined 1 -#endif - #ifdef ___int_least16_t_defined typedef __int_least16_t int_least16_t; typedef __uint_least16_t uint_least16_t; #define __int_least16_t_defined 1 #endif -#ifdef ___int32_t_defined -typedef __int32_t int32_t ; -typedef __uint32_t uint32_t ; -#define __int32_t_defined 1 -#endif - #ifdef ___int_least32_t_defined typedef __int_least32_t int_least32_t; typedef __uint_least32_t uint_least32_t; #define __int_least32_t_defined 1 #endif -#ifdef ___int64_t_defined -typedef __int64_t int64_t ; -typedef __uint64_t uint64_t ; -#define __int64_t_defined 1 -#endif - #ifdef ___int_least64_t_defined typedef __int_least64_t int_least64_t; typedef __uint_least64_t uint_least64_t; @@ -166,9 +143,6 @@ typedef __uint_least64_t uint_least64_t; typedef unsigned long uintmax_t; #endif -typedef __intptr_t intptr_t; -typedef __uintptr_t uintptr_t; - #ifdef __INTPTR_TYPE__ #define INTPTR_MIN (-__INTPTR_MAX__ - 1) #define INTPTR_MAX __INTPTR_MAX__ diff --git a/newlib/libc/include/sys/_stdint.h b/newlib/libc/include/sys/_stdint.h new file mode 100644 index 000000000..add1860c5 --- /dev/null +++ b/newlib/libc/include/sys/_stdint.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2004, 2005 by + * Ralf Corsepius, Ulm/Germany. All rights reserved. + * + * Permission to use, copy, modify, and distribute this software + * is freely granted, provided that this notice is preserved. + */ + +#ifndef _SYS__STDINT_H +#define _SYS__STDINT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef ___int8_t_defined +typedef __int8_t int8_t ; +typedef __uint8_t uint8_t ; +#define __int8_t_defined 1 +#endif + +#ifdef ___int16_t_defined +typedef __int16_t int16_t ; +typedef __uint16_t uint16_t ; +#define __int16_t_defined 1 +#endif + +#ifdef ___int32_t_defined +typedef __int32_t int32_t ; +typedef __uint32_t uint32_t ; +#define __int32_t_defined 1 +#endif + +#ifdef ___int64_t_defined +typedef __int64_t int64_t ; +typedef __uint64_t uint64_t ; +#define __int64_t_defined 1 +#endif + +typedef __intptr_t intptr_t; +typedef __uintptr_t uintptr_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS__STDINT_H */ diff --git a/newlib/libc/include/sys/time.h b/newlib/libc/include/sys/time.h index e65910467..ce8cad662 100644 --- a/newlib/libc/include/sys/time.h +++ b/newlib/libc/include/sys/time.h @@ -57,13 +57,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; @@ -74,7 +74,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; @@ -86,7 +86,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; @@ -98,7 +98,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); @@ -117,7 +117,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; } } @@ -179,8 +179,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 @@ -189,7 +189,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 @@ -197,7 +197,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 @@ -206,7 +206,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 @@ -215,7 +215,7 @@ sbttots(sbintime_t _sbt) struct timespec _ts; _ts.tv_sec = _sbt >> 32; - _ts.tv_nsec = ((__uint64_t)1000000000 * (__uint32_t)_sbt) >> 32; + _ts.tv_nsec = ((uint64_t)1000000000 * (uint32_t)_sbt) >> 32; return (_ts); } @@ -224,7 +224,7 @@ tstosbt(struct timespec _ts) { return (((sbintime_t)_ts.tv_sec << 32) + - (_ts.tv_nsec * (((__uint64_t)1 << 63) / 500000000) >> 32)); + (_ts.tv_nsec * (((uint64_t)1 << 63) / 500000000) >> 32)); } static __inline struct timeval @@ -233,7 +233,7 @@ sbttotv(sbintime_t _sbt) struct timeval _tv; _tv.tv_sec = _sbt >> 32; - _tv.tv_usec = ((__uint64_t)1000000 * (__uint32_t)_sbt) >> 32; + _tv.tv_usec = ((uint64_t)1000000 * (uint32_t)_sbt) >> 32; return (_tv); } @@ -242,7 +242,7 @@ tvtosbt(struct timeval _tv) { return (((sbintime_t)_tv.tv_sec << 32) + - (_tv.tv_usec * (((__uint64_t)1 << 63) / 500000) >> 32)); + (_tv.tv_usec * (((uint64_t)1 << 63) / 500000) >> 32)); } #endif /* __BSD_VISIBLE */ @@ -390,7 +390,7 @@ int tvtohz(struct timeval *tv); #define TC_DEFAULTPERC 5 #define BT2FREQ(bt) \ - (((__uint64_t)0x8000000000000000 + ((bt)->frac >> 2)) / \ + (((uint64_t)0x8000000000000000 + ((bt)->frac >> 2)) / \ ((bt)->frac >> 1)) #define SBT2FREQ(sbt) ((SBT_1S + ((sbt) >> 1)) / (sbt)) @@ -398,7 +398,7 @@ int tvtohz(struct timeval *tv); #define FREQ2BT(freq, bt) \ { \ (bt)->sec = 0; \ - (bt)->frac = ((__uint64_t)0x8000000000000000 / (freq)) << 1; \ + (bt)->frac = ((uint64_t)0x8000000000000000 / (freq)) << 1; \ } #define TIMESEL(sbt, sbt2) \ diff --git a/newlib/libc/include/sys/types.h b/newlib/libc/include/sys/types.h index 227f83cf5..9fe2f5de1 100644 --- a/newlib/libc/include/sys/types.h +++ b/newlib/libc/include/sys/types.h @@ -59,6 +59,7 @@ typedef quad_t * qaddr_t; #define _SYS_TYPES_H #include +#include #ifdef __i386__ #if defined (GO32) || defined (__MSDOS__) diff --git a/newlib/libc/sys/rtems/machine/_types.h b/newlib/libc/sys/rtems/machine/_types.h index e8b2bc7e6..1711c7ae8 100644 --- a/newlib/libc/sys/rtems/machine/_types.h +++ b/newlib/libc/sys/rtems/machine/_types.h @@ -9,7 +9,6 @@ #define _HAVE_SYSTYPES #include -#include /* For FreeBSD compatibility */ typedef __int32_t blksize_t; typedef __int32_t blkcnt_t;