diff options
author | Tomas Carnecky <tomas.carnecky@gmail.com> | 2016-05-08 14:44:07 +0200 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2016-05-10 08:40:50 +0200 |
commit | 260a5648c299636a94b12b9b97bf9743b0a1496d (patch) | |
tree | 2de1ffe579d1558d4352e496cf2e53b907e954d1 /includes/HsFFI.h | |
parent | dd3e84701db7d05a6664aa5826732da3ee8ce265 (diff) | |
download | haskell-260a5648c299636a94b12b9b97bf9743b0a1496d.tar.gz |
Use stdint types for Stg{Word,Int}{8,16,32,64}
We can't define Stg{Int,Word} in terms of {,u}intptr_t because STG
depends on them being the exact same size as void*, and {,u}intptr_t
does not make that guarantee. Furthermore, we also need to define
StgHalf{Int,Word}, so the preprocessor if needs to stay. But we can at
least keep it in a single place instead of repeating it in various
files.
Also define STG_{INT,WORD}{8,16,32,64}_{MIN,MAX} and use it in HsFFI.h,
further reducing the need for CPP in other files.
Reviewers: austin, bgamari, simonmar, hvr, erikd
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2182
Diffstat (limited to 'includes/HsFFI.h')
-rw-r--r-- | includes/HsFFI.h | 84 |
1 files changed, 16 insertions, 68 deletions
diff --git a/includes/HsFFI.h b/includes/HsFFI.h index 20be3606ed..4f015b6e25 100644 --- a/includes/HsFFI.h +++ b/includes/HsFFI.h @@ -20,50 +20,6 @@ extern "C" { #include "ghcconfig.h" #include "stg/Types.h" -/* get limits for integral types */ -#if defined HAVE_STDINT_H && !defined USE_INTTYPES_H_FOR_RTS_PROBES_D -/* ISO C 99 says: - * "C++ implementations should define these macros only when - * __STDC_LIMIT_MACROS is defined before <stdint.h> is included." - */ -#define __STDC_LIMIT_MACROS -#include <stdint.h> -#elif defined(HAVE_INTTYPES_H) -#include <inttypes.h> -#else -/* second best guess (e.g. on Solaris) */ -#include <limits.h> -#endif - -#ifdef INT8_MIN -#define __INT8_MIN INT8_MIN -#define __INT16_MIN INT16_MIN -#define __INT32_MIN INT32_MIN -#define __INT64_MIN INT64_MIN -#define __INT8_MAX INT8_MAX -#define __INT16_MAX INT16_MAX -#define __INT32_MAX INT32_MAX -#define __INT64_MAX INT64_MAX -#define __UINT8_MAX UINT8_MAX -#define __UINT16_MAX UINT16_MAX -#define __UINT32_MAX UINT32_MAX -#define __UINT64_MAX UINT64_MAX -#else -/* if we had no luck, let's do it for ourselves (assuming 64bit long longs) */ -#define __INT8_MIN (-128) -#define __INT16_MIN (-32767-1) -#define __INT32_MIN (-2147483647-1) -#define __INT64_MIN (-9223372036854775807LL-1) -#define __INT8_MAX (127) -#define __INT16_MAX (32767) -#define __INT32_MAX (2147483647) -#define __INT64_MAX (9223372036854775807LL) -#define __UINT8_MAX (255U) -#define __UINT16_MAX (65535U) -#define __UINT32_MAX (4294967295U) -#define __UINT64_MAX (18446744073709551615ULL) -#endif - /* get limits for floating point types */ #include <float.h> @@ -96,31 +52,23 @@ typedef void* HsStablePtr; #define HS_BOOL_MIN HS_BOOL_FALSE #define HS_BOOL_MAX HS_BOOL_TRUE -/* this mirrors the distinction of cases in StgTypes.h */ -#if SIZEOF_VOID_P == 8 -#define HS_INT_MIN __INT64_MIN -#define HS_INT_MAX __INT64_MAX -#define HS_WORD_MAX __UINT64_MAX -#elif SIZEOF_VOID_P == 4 -#define HS_INT_MIN __INT32_MIN -#define HS_INT_MAX __INT32_MAX -#define HS_WORD_MAX __UINT32_MAX -#else -#error GHC untested on this architecture: sizeof(void *) != 4 or 8 -#endif -#define HS_INT8_MIN __INT8_MIN -#define HS_INT8_MAX __INT8_MAX -#define HS_INT16_MIN __INT16_MIN -#define HS_INT16_MAX __INT16_MAX -#define HS_INT32_MIN __INT32_MIN -#define HS_INT32_MAX __INT32_MAX -#define HS_INT64_MIN __INT64_MIN -#define HS_INT64_MAX __INT64_MAX -#define HS_WORD8_MAX __UINT8_MAX -#define HS_WORD16_MAX __UINT16_MAX -#define HS_WORD32_MAX __UINT32_MAX -#define HS_WORD64_MAX __UINT64_MAX +#define HS_INT_MIN STG_INT_MIN +#define HS_INT_MAX STG_INT_MAX +#define HS_WORD_MAX STG_WORD_MAX + +#define HS_INT8_MIN STG_INT8_MIN +#define HS_INT8_MAX STG_INT8_MAX +#define HS_INT16_MIN STG_INT16_MIN +#define HS_INT16_MAX STG_INT16_MAX +#define HS_INT32_MIN STG_INT32_MIN +#define HS_INT32_MAX STG_INT32_MAX +#define HS_INT64_MIN STG_INT64_MIN +#define HS_INT64_MAX STG_INT64_MAX +#define HS_WORD8_MAX STG_WORD8_MAX +#define HS_WORD16_MAX STG_WORD16_MAX +#define HS_WORD32_MAX STG_WORD32_MAX +#define HS_WORD64_MAX STG_WORD64_MAX #define HS_FLOAT_RADIX FLT_RADIX #define HS_FLOAT_ROUNDS FLT_ROUNDS |