From c53187e1adc326c3246917cb936cbab020b4d820 Mon Sep 17 00:00:00 2001 From: chandramouli narayanan Date: Mon, 25 Jun 2012 12:32:17 -0700 Subject: Patches here support 32bit and 64bit environment. Move the standard definitions of constants, variously-sized ints,limits into respective architecture specific files. com32/include/bitsize holds the standard header files that in turn include bitsize32 or bitsize64 based on the architecture. The makefiles should build pick the right ones based on architecture. Files com32/include/sys/cpu.h, com32/include/sys/bitops.h now have architecture specific files underneath to define relevant macros definitions. com32/include/setjmp.h has architecture specific counterparts underneath. ssize_t in dos/stdlib.h is appropriately defined based on architecture to be able to support building for 32bit and 64bit environments. Remanants of the unused old i386-only files, if any, need to be pruned. --- com32/include/bitsize/limits.h | 12 ++++++---- com32/include/bitsize/stddef.h | 14 ++++++++++- com32/include/bitsize/stdint.h | 46 ++++++++++++++++++++++++++++++++++++ com32/include/bitsize/stdintconst.h | 18 +++++++------- com32/include/bitsize/stdintlimits.h | 22 +++++++---------- 5 files changed, 82 insertions(+), 30 deletions(-) (limited to 'com32/include/bitsize') diff --git a/com32/include/bitsize/limits.h b/com32/include/bitsize/limits.h index f90e524b..7129c4a6 100644 --- a/com32/include/bitsize/limits.h +++ b/com32/include/bitsize/limits.h @@ -5,10 +5,12 @@ #ifndef _BITSIZE_LIMITS_H #define _BITSIZE_LIMITS_H -#define LONG_BIT 32 - -#define LONG_MIN (-2147483647L-1) -#define LONG_MAX 2147483647L -#define ULONG_MAX 4294967295UL +#if __SIZEOF_POINTER__ == 4 +#include +#elif __SIZEOF_POINTER__ == 8 +#include +#else +#error "Unable to build for to-be-defined architecture type" +#endif #endif /* _BITSIZE_LIMITS_H */ diff --git a/com32/include/bitsize/stddef.h b/com32/include/bitsize/stddef.h index caa5e726..3d5c3e7a 100644 --- a/com32/include/bitsize/stddef.h +++ b/com32/include/bitsize/stddef.h @@ -1,11 +1,20 @@ /* - * bits32/stddef.h + * Include stddef.h as appropriate for architecture */ #ifndef _BITSIZE_STDDEF_H #define _BITSIZE_STDDEF_H #define _SIZE_T +#if __SIZEOF_POINTER__ == 4 +#include +#elif __SIZEOF_POINTER__ == 8 +#include +#else +#error "Unable to build for to-be-defined architecture type" +#endif +/* Original definitions below */ +/* #if defined(__s390__) || defined(__hppa__) || defined(__cris__) typedef unsigned long size_t; #else @@ -14,5 +23,8 @@ typedef unsigned int size_t; #define _PTRDIFF_T typedef signed int ptrdiff_t; +*/ +#else +#error "BITSIZE_STDDEF already defined" #endif /* _BITSIZE_STDDEF_H */ diff --git a/com32/include/bitsize/stdint.h b/com32/include/bitsize/stdint.h index 8cbfc5dd..854c5430 100644 --- a/com32/include/bitsize/stdint.h +++ b/com32/include/bitsize/stdint.h @@ -5,6 +5,7 @@ #ifndef _BITSIZE_STDINT_H #define _BITSIZE_STDINT_H +/* typedef signed char int8_t; typedef short int int16_t; typedef int int32_t; @@ -30,5 +31,50 @@ typedef unsigned int uintptr_t; #define __PRI64_RANK "ll" #define __PRIFAST_RANK "" #define __PRIPTR_RANK "" +*/ + +/* Exact types */ + +typedef signed char int8_t; +typedef signed short int16_t; +typedef signed int int32_t; +typedef signed long long int64_t; + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; + +/* Small types */ + +typedef signed char int_least8_t; +typedef signed short int_least16_t; +typedef signed int int_least32_t; +typedef signed long long int_least64_t; + +typedef unsigned char uint_least8_t; +typedef unsigned short uint_least16_t; +typedef unsigned int uint_least32_t; +typedef unsigned long long uint_least64_t; + +/* Fast types */ + +typedef signed char int_fast8_t; +typedef signed long long int_fast64_t; + +typedef unsigned char uint_fast8_t; +typedef unsigned int uint_fast32_t; +typedef unsigned long long uint_fast64_t; + +/* Maximal types */ +typedef int64_t intmax_t; +typedef uint64_t uintmax_t; +#if __SIZEOF_POINTER__ == 4 +#include +#elif __SIZEOF_POINTER__ == 8 +#include +#else +#error "Unable to build for to-be-defined architecture type" +#endif #endif /* _BITSIZE_STDINT_H */ diff --git a/com32/include/bitsize/stdintconst.h b/com32/include/bitsize/stdintconst.h index 8157dd06..ae4e9fc0 100644 --- a/com32/include/bitsize/stdintconst.h +++ b/com32/include/bitsize/stdintconst.h @@ -1,18 +1,16 @@ /* - * bits32/stdintconst.h + * bitsize/stdintconst.h */ #ifndef _BITSIZE_STDINTCONST_H #define _BITSIZE_STDINTCONST_H -#define INT_FAST16_C(c) INT32_C(c) -#define INT_FAST32_C(c) INT32_C(c) - -#define UINT_FAST16_C(c) UINT32_C(c) -#define UINT_FAST32_C(c) UINT32_C(c) - -#define INTPTR_C(c) INT32_C(c) -#define UINTPTR_C(c) UINT32_C(c) -#define PTRDIFF_C(c) INT32_C(c) +#if __SIZEOF_POINTER__ == 4 +#include +#elif __SIZEOF_POINTER__ == 8 +#include +#else +#error "Unable to build for to-be-defined architecture type" +#endif #endif /* _BITSIZE_STDINTCONST_H */ diff --git a/com32/include/bitsize/stdintlimits.h b/com32/include/bitsize/stdintlimits.h index b44fe011..9f3657d2 100644 --- a/com32/include/bitsize/stdintlimits.h +++ b/com32/include/bitsize/stdintlimits.h @@ -1,22 +1,16 @@ /* - * bits32/stdintlimits.h + * bitsize/stdintlimits.h */ #ifndef _BITSIZE_STDINTLIMITS_H #define _BITSIZE_STDINTLIMITS_H -#define INT_FAST16_MIN INT32_MIN -#define INT_FAST32_MIN INT32_MIN -#define INT_FAST16_MAX INT32_MAX -#define INT_FAST32_MAX INT32_MAX -#define UINT_FAST16_MAX UINT32_MAX -#define UINT_FAST32_MAX UINT32_MAX - -#define INTPTR_MIN INT32_MIN -#define INTPTR_MAX INT32_MAX -#define UINTPTR_MAX UINT32_MAX - -#define PTRDIFF_MIN INT32_MIN -#define PTRDIFF_MAX INT32_MAX +#if __SIZEOF_POINTER__ == 4 +#include +#elif __SIZEOF_POINTER__ == 8 +#include +#else +#error "Unable to build for to-be-defined architecture type" +#endif #endif /* _BITSIZE_STDINTLIMITS_H */ -- cgit v1.2.1