This is the mail archive of the
newlib@sources.redhat.com
mailing list for the newlib project.
RTEMS patch sweep: *types.h
- From: Ralf Corsepius <ralf dot corsepius at rtems dot org>
- To: Newlib List <newlib at sources dot redhat dot com>
- Cc: Joel Sherrill <joel dot sherrill at OARcorp dot com>, Eric Norum <norume at aps dot anl dot gov>
- Date: Tue, 22 Feb 2005 02:07:20 +0100
- Subject: RTEMS patch sweep: *types.h
Hi,
Another part of the RTEMS patches.
These patches address several issues at once:
1. The #ifdef'ed __rtems__ intXX_t types in machine/types.h conflict
with current RTEMS (RTEMS now has stdint.h)
2. The #ifdef'ed __rtems__ intXX_t types in machine/types.h are broken
for some targets (H8300, avr, c4x).
3. RTEMS needs BSDs __uintXX_t's.
Though these patches should be generally applicable, all changes these
patches introduce have been if'ed __rtems__ to avoid potential conflicts
with other OSes.
Ralf
Index: libc/include/machine/types.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/machine/types.h,v
retrieving revision 1.6
diff -u -r1.6 types.h
--- libc/include/machine/types.h 16 Jan 2003 22:37:54 -0000 1.6
+++ libc/include/machine/types.h 22 Feb 2005 00:59:16 -0000
@@ -6,25 +6,8 @@
* closely match the types defined in the BSD machine/types.h.
* This is needed to let the RTEMS/BSD TCP/IP stack compile.
*/
-
#if defined(__rtems__)
-typedef signed long long int64_t;
-#if defined( __h8300__)
-typedef signed long int32_t;
-#else
-typedef signed int int32_t;
-#endif
-typedef signed short int16_t;
-typedef signed char int8_t;
-
-typedef unsigned long long u_int64_t;
-#if defined( __h8300__)
-typedef unsigned long u_int32_t;
-#else
-typedef unsigned int u_int32_t;
-#endif
-typedef unsigned short u_int16_t;
-typedef unsigned char u_int8_t;
+#include <machine/_types.h>
#endif
#define _CLOCK_T_ unsigned long /* clock() */
Index: libc/include/sys/types.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/sys/types.h,v
retrieving revision 1.19
diff -u -r1.19 types.h
--- libc/include/sys/types.h 2 Jul 2003 20:32:07 -0000 1.19
+++ libc/include/sys/types.h 22 Feb 2005 00:59:16 -0000
@@ -21,6 +21,8 @@
#ifndef __INTTYPES_DEFINED__
#define __INTTYPES_DEFINED__
+
+#if !defined (__rtems__)
typedef short int __int16_t;
typedef unsigned short int __uint16_t;
@@ -39,6 +41,38 @@
__extension__ typedef long long __int64_t;
__extension__ typedef unsigned long long __uint64_t;
#endif
+#else /* __rtems__ */
+
+/*
+ * The following section is RTEMS specific and is needed to more
+ * closely match the types defined in the BSD sys/types.h.
+ * This is needed to let the RTEMS/BSD TCP/IP stack compile.
+ */
+
+#include <machine/_types.h>
+
+/* deprecated */
+#if ___int8_t_defined
+typedef __uint8_t u_int8_t;
+#endif
+#if ___int16_t_defined
+typedef __uint16_t u_int16_t;
+#endif
+#if ___int32_t_defined
+typedef __uint32_t u_int32_t;
+#endif
+
+#if ___int64_t_defined
+typedef __uint64_t u_int64_t;
+
+/* deprecated */
+typedef __uint64_t u_quad_t;
+typedef __int64_t quad_t;
+typedef quad_t * qaddr_t;
+#endif
+
+#endif
+
#endif /* ! __INTTYPES_DEFINED */
#ifndef __need_inttypes
Index: libc/sys/rtems/machine/_types.h
===================================================================
RCS file: libc/sys/rtems/machine/_types.h
diff -N libc/sys/rtems/machine/_types.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libc/sys/rtems/machine/_types.h 22 Feb 2005 00:59:16 -0000
@@ -0,0 +1,121 @@
+/*
+ * $Id$
+ */
+
+#ifndef _MACHINE__TYPES_H
+#define _MACHINE__TYPES_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Guess on types by examining *_MIN/*_MAX defines.
+ */
+#if defined(__GNUC__) && (__GNUC__ >= 3 ) \
+ && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 2 )
+/* GCC >= 3.3.0 has __<val>__ implicitly defined. */
+#define __EXP(x) __##x##__
+#else
+/* Fall back to POSIX versions from <limits.h> */
+#define __EXP(x) x
+#include <limits.h>
+#endif
+
+#if __EXP(SCHAR_MAX) == 0x7f
+typedef signed char __int8_t ;
+typedef unsigned char __uint8_t ;
+#define ___int8_t_defined 1
+#endif
+
+#if __EXP(INT_MAX) == 0x7fff
+typedef signed int __int16_t;
+typedef unsigned int __uint16_t;
+#define ___int16_t_defined 1
+#elif __EXP(SHRT_MAX) == 0x7fff
+typedef signed short __int16_t;
+typedef unsigned short __uint16_t;
+#define ___int16_t_defined 1
+#elif __EXP(SCHAR_MAX) == 0x7fff
+typedef signed char __int16_t;
+typedef unsigned char __uint16_t;
+#define ___int16_t_defined 1
+#endif
+
+#if ___int16_t_defined
+typedef __int16_t __int_least16_t;
+typedef __uint16_t __uint_least16_t;
+#define ___int_least16_t_defined 1
+
+#if !___int8_t_defined
+typedef __int16_t __int_least8_t;
+typedef __uint16_t __uint_least8_t;
+#define ___int_least8_t_defined 1
+#endif
+#endif
+
+#if __EXP(INT_MAX) == 0x7fffffffL
+typedef signed int __int32_t;
+typedef unsigned int __uint32_t;
+#define ___int32_t_defined 1
+#elif __EXP(LONG_MAX) == 0x7fffffffL
+typedef signed long __int32_t;
+typedef unsigned long __uint32_t;
+#define ___int32_t_defined 1
+#elif __EXP(SHRT_MAX) == 0x7fffffffL
+typedef signed short __int32_t;
+typedef unsigned short __uint32_t;
+#define ___int32_t_defined 1
+#elif __EXP(SCHAR_MAX) == 0x7fffffffL
+typedef signed char __int32_t;
+typedef unsigned char __uint32_t;
+#define ___int32_t_defined 1
+#endif
+
+#if ___int32_t_defined
+typedef __int32_t __int_least32_t;
+typedef __uint32_t __uint_least32_t;
+#define ___int_least32_t_defined 1
+
+#if !___int8_t_defined
+typedef __int32_t __int_least8_t;
+typedef __uint32_t __uint_least8_t;
+#define ___int_least8_t_defined 1
+#endif
+#if !___int16_t_defined
+typedef __int32_t __int_least16_t;
+typedef __uint32_t __uint_least16_t;
+#define ___int_least16_t_defined 1
+#endif
+#endif
+
+#if __EXP(LONG_MAX) > 0x7fffffff
+typedef signed long __int64_t;
+typedef unsigned long __uint64_t;
+#define ___int64_t_defined 1
+
+/* GCC has __LONG_LONG_MAX__ */
+#elif defined(__LONG_LONG_MAX__) && (__LONG_LONG_MAX__ > 0x7fffffff)
+typedef signed long long __int64_t;
+typedef unsigned long long __uint64_t;
+#define ___int64_t_defined 1
+
+/* POSIX mandates LLONG_MAX in <limits.h> */
+#elif defined(LLONG_MAX) && (LLONG_MAX > 0x7fffffff)
+typedef signed long long __int64_t;
+typedef unsigned long long __uint64_t;
+#define ___int64_t_defined 1
+
+#elif __EXP(INT_MAX) > 0x7fffffff
+typedef signed int __int64_t;
+typedef unsigned int __uint64_t;
+#define ___int64_t_defined 1
+#endif
+
+#undef __EXP
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _MACHINE__TYPES_H */