Add some missing macros for int literals in wamr-sdk libc-builtin-sysroot stdint.h (#1888)

This commit is contained in:
Qiang 2023-01-17 15:25:57 +08:00 committed by GitHub
parent a1786428e6
commit 64767fddd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,6 +11,13 @@ extern "C" {
#endif #endif
/* clang-format off */ /* clang-format off */
/* The word size of platform */
#ifdef __wasm64__
#define __WORDSIZE 64
#else
#define __WORDSIZE 32
#endif
typedef char int8_t; typedef char int8_t;
typedef short int int16_t; typedef short int int16_t;
typedef int int32_t; typedef int int32_t;
@ -25,22 +32,56 @@ typedef unsigned long long int uint64_t;
typedef __INTPTR_TYPE__ intptr_t; typedef __INTPTR_TYPE__ intptr_t;
typedef __UINTPTR_TYPE__ uintptr_t; typedef __UINTPTR_TYPE__ uintptr_t;
/* Signed and unsigned */
#if __WORDSIZE == 64
#define INT64_C(c) c ## L
#define UINT64_C(c) c ## UL
#define INTMAX_C(c) c ## L
#define UINTMAX_C(c) c ## UL
#else
#define INT64_C(c) c ## LL
#define UINT64_C(c) c ## ULL
#define INTMAX_C(c) c ## LL
#define UINTMAX_C(c) c ## ULL
#endif
/* Minimum of signed integral types. */ /* Minimum of signed integral types. */
# define INT8_MIN (-128) # define INT8_MIN (-128)
# define INT16_MIN (-32767-1) # define INT16_MIN (-32767-1)
# define INT32_MIN (-2147483647-1) # define INT32_MIN (-2147483647-1)
# define INT64_MIN (-__INT64_C(9223372036854775807)-1) # define INT64_MIN (-INT64_C(9223372036854775807)-1)
/* Maximum of signed integral types. */ /* Maximum of signed integral types. */
# define INT8_MAX (127) # define INT8_MAX (127)
# define INT16_MAX (32767) # define INT16_MAX (32767)
# define INT32_MAX (2147483647) # define INT32_MAX (2147483647)
# define INT64_MAX (__INT64_C(9223372036854775807)) # define INT64_MAX (INT64_C(9223372036854775807))
/* Maximum of unsigned integral types. */ /* Maximum of unsigned integral types. */
# define UINT8_MAX (255) # define UINT8_MAX (255)
# define UINT16_MAX (65535) # define UINT16_MAX (65535)
# define UINT32_MAX (4294967295U) # define UINT32_MAX (4294967295U)
# define UINT64_MAX (__UINT64_C(18446744073709551615)) # define UINT64_MAX (UINT64_C(18446744073709551615))
/* Values to test for integral types holding `void *' pointer. */
#if __WORDSIZE == 64
#define INTPTR_MIN INT64_MIN
#define INTPTR_MAX INT64_MAX
#define UINTPTR_MAX UINT64_MAX
#else
#define INTPTR_MIN INT32_MIN
#define INTPTR_MAX INT32_MAX
#define UINTPTR_MAX UINT32_MAX
#endif
/* Limit of `size_t' type. */
#if __WORDSIZE == 64
#define SIZE_MAX UINT64_MAX
#else
#define SIZE_MAX UINT32_MAX
#endif
/* clang-format on */ /* clang-format on */
#ifdef __cplusplus #ifdef __cplusplus