This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Add <sys/_stdint.h> for FreeBSD compatibility


newlib/ChangeLog
2015-03-13  Sebastian Huber  <sebastian.huber@embedded-brains.de>

	* libc/include/sys/_stdint.h: New file.
	* libc/include/stdint.h (int8_t): Move to <sys/_stdint.h>.
	(uint8_t): Likewise.
	(int16_t): Likewise.
	(uint16_t): Likewise.
	(int32_t): Likewise.
	(uint32_t): Likewise.
	(int64_t): Likewise.
	(uint64_t): Likewise.
	* libc/include/sys/types.h: Include <sys/_stdint.h>.
	* libc/sys/rtems/machine/_types.h: Remove <stdint.h> include.
	* libc/sys/time.h>: Replace __uint32_t with uint32_t and
	__uint64_t with uint64_t.
---
 newlib/libc/include/stdint.h           | 25 +-----------------
 newlib/libc/include/sys/_stdint.h      | 46 ++++++++++++++++++++++++++++++++++
 newlib/libc/include/sys/time.h         | 36 +++++++++++++-------------
 newlib/libc/include/sys/types.h        |  1 +
 newlib/libc/sys/rtems/machine/_types.h |  1 -
 5 files changed, 66 insertions(+), 43 deletions(-)
 create mode 100644 newlib/libc/include/sys/_stdint.h

diff --git a/newlib/libc/include/stdint.h b/newlib/libc/include/stdint.h
index 7386164..afb7e8a 100644
--- a/newlib/libc/include/stdint.h
+++ b/newlib/libc/include/stdint.h
@@ -11,53 +11,30 @@
 
 #include <machine/_default_types.h>
 #include <sys/_intsup.h>
+#include <sys/_stdint.h>
 
 #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;
diff --git a/newlib/libc/include/sys/_stdint.h b/newlib/libc/include/sys/_stdint.h
new file mode 100644
index 0000000..d38b16d
--- /dev/null
+++ b/newlib/libc/include/sys/_stdint.h
@@ -0,0 +1,46 @@
+/*
+ * 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 <machine/_default_types.h>
+
+#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
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SYS__STDINT_H */
diff --git a/newlib/libc/include/sys/time.h b/newlib/libc/include/sys/time.h
index e659104..ce8cad6 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 227f83c..9fe2f5d 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 <sys/_types.h>
+#include <sys/_stdint.h>
 
 #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 e8b2bc7..1711c7a 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 <machine/_default_types.h>
-#include <stdint.h> /* For FreeBSD compatibility */
 
 typedef __int32_t blksize_t;
 typedef __int32_t blkcnt_t;
-- 
2.1.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]