libc: minimal: add INTn_C macros to stdint.h
Macros like INT64_C(x) convert x to a constant integral expression, i.e. one that can be used in preprocessor code. Implement wrappers that use the GNUC intrinsics to perform the translation. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
parent
5fd15c3038
commit
ee7c9f7fe8
2 changed files with 32 additions and 0 deletions
|
@ -74,6 +74,24 @@ typedef __UINT_LEAST64_TYPE__ uint_least64_t;
|
|||
typedef __INTPTR_TYPE__ intptr_t;
|
||||
typedef __UINTPTR_TYPE__ uintptr_t;
|
||||
|
||||
#ifdef __GNUC__
|
||||
/* These macros must produce constant integer expressions, which can't
|
||||
* be done in the preprocessor (casts aren't allowed). Defer to the
|
||||
* GCC internal functions where they're available.
|
||||
*/
|
||||
#define INT8_C(_v) __INT8_C(_v)
|
||||
#define INT16_C(_v) __INT16_C(_v)
|
||||
#define INT32_C(_v) __INT32_C(_v)
|
||||
#define INT64_C(_v) __INT64_C(_v)
|
||||
#define INTMAX_C(_v) __INTMAX_C(_v)
|
||||
|
||||
#define UINT8_C(_v) __UINT8_C(_v)
|
||||
#define UINT16_C(_v) __UINT16_C(_v)
|
||||
#define UINT32_C(_v) __UINT32_C(_v)
|
||||
#define UINT64_C(_v) __UINT64_C(_v)
|
||||
#define UINTMAX_C(_v) __UINTMAX_C(_v)
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue