Skip to content

Commit 64767fd

Browse files
authored
Add some missing macros for int literals in wamr-sdk libc-builtin-sysroot stdint.h (#1888)
1 parent a178642 commit 64767fd

File tree

1 file changed

+44
-3
lines changed
  • wamr-sdk/app/libc-builtin-sysroot/include

1 file changed

+44
-3
lines changed

wamr-sdk/app/libc-builtin-sysroot/include/stdint.h

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
1421
typedef char int8_t;
1522
typedef short int int16_t;
1623
typedef int int32_t;
@@ -25,22 +32,56 @@ typedef unsigned long long int uint64_t;
2532
typedef __INTPTR_TYPE__ intptr_t;
2633
typedef __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

Comments
 (0)