@@ -11,6 +11,13 @@ extern "C" {
1111#endif
1212
1313/* clang-format off */
14+ /* The word size of platform */
15+ #ifdef __wasm64__
16+ #define __WORDSIZE 64
17+ #else
18+ #define __WORDSIZE 32
19+ #endif
20+
1421typedef char int8_t ;
1522typedef short int int16_t ;
1623typedef int int32_t ;
@@ -25,22 +32,56 @@ typedef unsigned long long int uint64_t;
2532typedef __INTPTR_TYPE__ intptr_t ;
2633typedef __UINTPTR_TYPE__ uintptr_t ;
2734
35+ /* Signed and unsigned */
36+ #if __WORDSIZE == 64
37+ #define INT64_C (c ) c ## L
38+ #define UINT64_C (c ) c ## UL
39+ #define INTMAX_C (c ) c ## L
40+ #define UINTMAX_C (c ) c ## UL
41+ #else
42+ #define INT64_C (c ) c ## LL
43+ #define UINT64_C (c ) c ## ULL
44+ #define INTMAX_C (c ) c ## LL
45+ #define UINTMAX_C (c ) c ## ULL
46+ #endif
47+
48+
2849/* Minimum of signed integral types. */
2950# define INT8_MIN (-128)
3051# define INT16_MIN (-32767-1)
3152# define INT32_MIN (-2147483647-1)
32- # define INT64_MIN (-__INT64_C(9223372036854775807)-1)
53+ # define INT64_MIN (-INT64_C(9223372036854775807)-1)
54+
3355/* Maximum of signed integral types. */
3456# define INT8_MAX (127)
3557# define INT16_MAX (32767)
3658# define INT32_MAX (2147483647)
37- # define INT64_MAX (__INT64_C (9223372036854775807))
59+ # define INT64_MAX (INT64_C (9223372036854775807))
3860
3961/* Maximum of unsigned integral types. */
4062# define UINT8_MAX (255)
4163# define UINT16_MAX (65535)
4264# define UINT32_MAX (4294967295U)
43- # define UINT64_MAX (__UINT64_C(18446744073709551615))
65+ # define UINT64_MAX (UINT64_C(18446744073709551615))
66+
67+ /* Values to test for integral types holding `void *' pointer. */
68+ #if __WORDSIZE == 64
69+ #define INTPTR_MIN INT64_MIN
70+ #define INTPTR_MAX INT64_MAX
71+ #define UINTPTR_MAX UINT64_MAX
72+ #else
73+ #define INTPTR_MIN INT32_MIN
74+ #define INTPTR_MAX INT32_MAX
75+ #define UINTPTR_MAX UINT32_MAX
76+ #endif
77+
78+ /* Limit of `size_t' type. */
79+ #if __WORDSIZE == 64
80+ #define SIZE_MAX UINT64_MAX
81+ #else
82+ #define SIZE_MAX UINT32_MAX
83+ #endif
84+
4485/* clang-format on */
4586
4687#ifdef __cplusplus
0 commit comments