Added the stdint.h header file.

This commit is contained in:
dtrg 2007-04-27 22:42:02 +00:00
parent 0d8578410c
commit 013f58f94e
4 changed files with 56 additions and 103 deletions

View file

@ -10,6 +10,7 @@ setjmp.h
signal.h
stdarg.h
stddef.h
stdint.h
stdio.h
stdlib.h
string.h

View file

@ -9,21 +9,12 @@
#ifndef _STDDEF_H
#define _STDDEF_H
#include <stdint.h>
#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 */

View file

@ -1,120 +1,80 @@
/*
<stdint.h> -- 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
typedef int64_t intmax_t;
typedef uint64_t uintmax_t;
#else
typedef int32_t intmax_t;
typedef uint32_t uintmax_t;
#endif
#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
/* 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
/* Now those have been defined, these are always the same. */
#define PTRDIFF_MAX 2147483647
#define PTRDIFF_MIN (-2147483647)
#define PTRDIFF_MAX INTPTR_MAX
#define PTRDIFF_MIN INTPTR_MIN
#define SIZE_MAX UINTPTR_MAX
#define SIG_ATOMIC_MAX 4294967295
#define SIG_ATOMIC_MIN 0
#define SIZE_MAX 4294967295
/* 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

View file

@ -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"),