toolchain/llvm: Provide integer macros only when necessary
Using '#ifndef' before defining a macro is a good way to provide default version of the macro if not defined elsewhere. But it has some disadvantages: - It hides information about the users of these macros. It's hard to determine when this implementation is used. - Correctness depends on file including order. It looks like these macros are used only by minimal libc and only if ENFORCE_ZEPHYR_STDINT is not selected. We expect other libc to provide their own implementation. Signed-off-by: Patryk Duda <patrykd@google.com>
This commit is contained in:
parent
759dcfe18f
commit
1f4e911d68
1 changed files with 10 additions and 29 deletions
|
@ -30,46 +30,27 @@
|
|||
|
||||
#include <zephyr/toolchain/gcc.h>
|
||||
|
||||
#ifndef __INT8_C
|
||||
/*
|
||||
* Provide these definitions only when minimal libc is used.
|
||||
* Avoid collision with defines from include/zephyr/toolchain/zephyr_stdint.h
|
||||
*/
|
||||
#ifdef CONFIG_MINIMAL_LIBC
|
||||
#ifndef CONFIG_ENFORCE_ZEPHYR_STDINT
|
||||
|
||||
#define __INT8_C(x) x
|
||||
#endif
|
||||
|
||||
#ifndef __UINT8_C
|
||||
#define __UINT8_C(x) x ## U
|
||||
#endif
|
||||
|
||||
#ifndef __INT16_C
|
||||
#define __INT16_C(x) x
|
||||
#endif
|
||||
|
||||
#ifndef __UINT16_C
|
||||
#define __UINT16_C(x) x ## U
|
||||
#endif
|
||||
|
||||
#ifndef __INT32_C
|
||||
#define __INT32_C(x) x
|
||||
#endif
|
||||
|
||||
#ifndef __UINT32_C
|
||||
#define __UINT32_C(x) x ## U
|
||||
#endif
|
||||
|
||||
#ifndef __INT64_C
|
||||
#define __INT64_C(x) x
|
||||
#endif
|
||||
|
||||
#ifndef __UINT64_C
|
||||
#define __UINT64_C(x) x ## ULL
|
||||
#endif
|
||||
|
||||
#ifndef __INTMAX_C
|
||||
#endif /* !CONFIG_ENFORCE_ZEPHYR_STDINT */
|
||||
|
||||
#define __INTMAX_C(x) x
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef __UINTMAX_C
|
||||
#define __UINTMAX_C(x) x ## ULL
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_MINIMAL_LIBC */
|
||||
|
||||
#endif /* ZEPHYR_INCLUDE_TOOLCHAIN_LLVM_H_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue