From 013f58f94e688f665bb1e7d82735cd23c34c454e Mon Sep 17 00:00:00 2001 From: dtrg Date: Fri, 27 Apr 2007 22:42:02 +0000 Subject: [PATCH] Added the stdint.h header file. --- lang/cem/libcc.ansi/headers/.distr | 1 + lang/cem/libcc.ansi/headers/stddef.h | 13 +-- lang/cem/libcc.ansi/headers/stdint.h | 148 ++++++++++----------------- lang/cem/libcc.ansi/pmfile | 1 + 4 files changed, 58 insertions(+), 105 deletions(-) diff --git a/lang/cem/libcc.ansi/headers/.distr b/lang/cem/libcc.ansi/headers/.distr index e06898894..e7d9d0986 100644 --- a/lang/cem/libcc.ansi/headers/.distr +++ b/lang/cem/libcc.ansi/headers/.distr @@ -10,6 +10,7 @@ setjmp.h signal.h stdarg.h stddef.h +stdint.h stdio.h stdlib.h string.h diff --git a/lang/cem/libcc.ansi/headers/stddef.h b/lang/cem/libcc.ansi/headers/stddef.h index 07723fbc5..eb14ffb27 100644 --- a/lang/cem/libcc.ansi/headers/stddef.h +++ b/lang/cem/libcc.ansi/headers/stddef.h @@ -9,21 +9,12 @@ #ifndef _STDDEF_H #define _STDDEF_H +#include + #define NULL 0 #define offsetof(type, ident) ((size_t) (unsigned long) &((type *)0)->ident) -#if _EM_PSIZE == _EM_WSIZE -typedef int ptrdiff_t; /* result of substracting two pointers */ -typedef int intptr_t; /* an integer big enough to store a pointer */ -#elif _EM_PSIZE == _EM_LSIZE -typedef long ptrdiff_t; /* result of substracting two pointers */ -typedef long intptr_t; /* an integer big enough to store a pointer */ -#else -#error unsupported pointer size -#endif /* _EM_PSIZE */ - -typedef unsigned int size_t; /* type returned by sizeof */ typedef char wchar_t; /* type of a wide character */ typedef long off_t; /* type of a position offset */ diff --git a/lang/cem/libcc.ansi/headers/stdint.h b/lang/cem/libcc.ansi/headers/stdint.h index d9e135014..86fd04815 100644 --- a/lang/cem/libcc.ansi/headers/stdint.h +++ b/lang/cem/libcc.ansi/headers/stdint.h @@ -1,120 +1,80 @@ /* - -- simple version used by "gimplify" + * stdint.h - standard types + */ +/* $Id$ */ - last edit: 2007-03-02 D A Gwyn -*/ +#ifndef _STDINT_H +#define _STDINT_H -/* Although we try to unify integer types, some actual machine characteristics - are visible, and these definitions need to work within their limits. We do - assume that the GCC target has an "int" at least 32 bits wide, which works - for all our development platforms. We use "long long" for the widest types - because presumably the programmer really needed something special there. */ - -#define int8_t signed char -#define uint8_t unsigned char -#define int16_t short -#define uint16_t unsigned short -#define int32_t int -#define uint32_t unsigned -#define int64_t long long -#define uint64_t unsigned long long - -#define int_least8_t int -#define uint_least8_t int -#define int_least16_t int -#define uint_least16_t unsigned -#define int_least32_t int -#define uint_least32_t unsigned -#define int_least64_t long long -#define uint_least64_t unsigned long long - -#define intptr_t int -#define uintptr_t unsigned int - -#define intmax_t long long -#define uintmax_t unsigned long long - -#define int_fast8_t int -#define uint_fast8_t unsigned int -#define int_fast16_t int -#define uint_fast16_t unsigned int -#define int_fast32_t int -#define uint_fast32_t unsigned int -#define int_fast64_t long long int -#define uint_fast64_t unsigned long long +/* int8_t is always a char, on all ACK platforms. */ +typedef signed char int8_t; +typedef unsigned char uint8_t; #define INT8_MAX 127 #define INT8_MIN (-128) #define UINT8_MAX 255 +/* int16_t is always a short, on all ACK platforms. */ + +typedef signed short int16_t; +typedef unsigned short uint16_t; #define INT16_MAX 32767 #define INT16_MIN (-32768) #define UINT16_MAX 65535 +/* int32_t is either a int or a long. */ + +#if _EM_WSIZE == 4 +typedef signed int int32_t; +typedef unsigned short uint32_t; +#else +typedef signed long int32_t; +typedef unsigned long uint32_t; +#endif #define INT32_MAX 2147483647 #define INT32_MIN (-2147483648) #define UINT32_MAX 4294967295 +/* We only get int64_t if longs are 8 bytes. */ + +#if _EM_LSIZE == 8 +typedef signed long int64_t; +typedef unsigned long uint64_t; #define INT64_MAX 2147483647LL #define INT64_MIN (-2147483648LL) #define UINT64_MAX 4294967295ULL -#define INT_LEAST8_MAX 2147483647 -#define INT_LEAST8_MIN (-2147483647) -#define UINT_LEAST8_MAX 4294967295 - -#define INT_LEAST16_MAX 2147483647 -#define INT_LEAST16_MIN (-2147483647) -#define UINT_LEAST16_MAX 4294967295 - -#define INT_LEAST32_MAX 2147483647 -#define INT_LEAST32_MIN (-2147483647) -#define UINT_LEAST32_MAX 4294967295 - -#define INT_LEAST64_MAX 2147483647LL -#define INT_LEAST64_MIN (-2147483647LL) -#define UINT_LEAST64_MAX 4294967295ULL - -#define INT_FAST8_MAX 2147483647 -#define INT_FAST8_MIN (-2147483647) -#define UINT_FAST8_MAX 4294967295 - -#define INT_FAST16_MAX 2147483647 -#define INT_FAST16_MIN (-2147483647) -#define UINT_FAST16_MAX 4294967295 - -#define INT_FAST32_MAX 2147483647 -#define INT_FAST32_MIN (-2147483647) -#define UINT_FAST32_MAX 4294967295 - -#define INT_FAST64_MAX 2147483647LL -#define INT_FAST64_MIN (-2147483647LL) -#define UINT_FAST64_MAX 4294967295ULL - +typedef int64_t intmax_t; +typedef uint64_t uintmax_t; +#else +typedef int32_t intmax_t; +typedef uint32_t uintmax_t; +#endif + +/* Pointers can be either 16 or 32 bits. */ + +#if _EM_PSIZE == 2 +typedef int16_t intptr_t; +typedef uint16_t uintptr_t; +typedef int16_t ptrdiff_t; +typedef uint16_t size_t; +#define INTPTR_MAX 32767 +#define INTPTR_MIN (-32768) +#define UINTPTR_MAX 65535 +#else +typedef int32_t intptr_t; +typedef uint32_t uintptr_t; +typedef int32_t ptrdiff_t; +typedef uint32_t size_t; #define INTPTR_MAX 2147483647 #define INTPTR_MIN (-2147483647) #define UINTPTR_MAX 4294967295 +#endif -#define INTMAX_MAX 2147483647LL -#define INTMAX_MIN (-2147483647LL) -#define UINTMAX_MAX 4294967295ULL - -#define PTRDIFF_MAX 2147483647 -#define PTRDIFF_MIN (-2147483647) - -#define SIG_ATOMIC_MAX 4294967295 -#define SIG_ATOMIC_MIN 0 +/* Now those have been defined, these are always the same. */ -#define SIZE_MAX 4294967295 +#define PTRDIFF_MAX INTPTR_MAX +#define PTRDIFF_MIN INTPTR_MIN +#define SIZE_MAX UINTPTR_MAX -/* The trick used to get the right type is due to Clive Feather: */ -#define INT8_C(c) (INT_LEAST8_MAX - INT_LEAST8_MAX + (c)) -#define UINT8_C(c) (UINT_LEAST8_MAX - UINT_LEAST8_MAX + (c)) -#define INT16_C(c) (INT_LEAST16_MAX - INT_LEAST16_MAX + (c)) -#define UINT16_C(c) (UINT_LEAST16_MAX - UINT_LEAST16_MAX + (c)) -#define INT32_C(c) (INT_LEAST32_MAX - INT_LEAST32_MAX + (c)) -#define UINT32_C(c) (UINT_LEAST32_MAX - UINT_LEAST32_MAX + (c)) -#define INT64_C(c) (INT_LEAST64_MAX - INT_LEAST64_MAX + (c)) -#define UINT64_C(c) (UINT_LEAST64_MAX - UINT_LEAST64_MAX + (c)) -#define INTMAX_C(c) (INTMAX_MAX - INTMAX_MAX + (c)) -#define UINTMAX_C(c) (UINTMAX_MAX - UINTMAX_MAX + (c)) +#endif diff --git a/lang/cem/libcc.ansi/pmfile b/lang/cem/libcc.ansi/pmfile index 2431689e7..d0f4631af 100644 --- a/lang/cem/libcc.ansi/pmfile +++ b/lang/cem/libcc.ansi/pmfile @@ -281,6 +281,7 @@ local headers = group { pm.install(d.."headers/signal.h", "%BINDIR%include/ansi/signal.h"), pm.install(d.."headers/stdarg.h", "%BINDIR%include/ansi/stdarg.h"), pm.install(d.."headers/stddef.h", "%BINDIR%include/ansi/stddef.h"), + pm.install(d.."headers/stdint.h", "%BINDIR%include/ansi/stdint.h"), pm.install(d.."headers/stdio.h", "%BINDIR%include/ansi/stdio.h"), pm.install(d.."headers/stdlib.h", "%BINDIR%include/ansi/stdlib.h"), pm.install(d.."headers/string.h", "%BINDIR%include/ansi/string.h"), -- 2.34.1