Elyes Haouas has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/83459?usp=email )
Change subject: tree: Add kconfig option for testing C2x dialect ......................................................................
tree: Add kconfig option for testing C2x dialect
This adds C2x dialect for testing and prepar for C2x dialect support.
Change-Id: I07db866bebfd25f1a60d18a3228ada2957500234 Signed-off-by: Elyes Haouas ehaouas@noos.fr --- M Makefile.mk M src/Kconfig M src/include/stdbool.h M src/include/stddef.h 4 files changed, 19 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/59/83459/1
diff --git a/Makefile.mk b/Makefile.mk index bf6363a..1f6415a 100644 --- a/Makefile.mk +++ b/Makefile.mk @@ -507,7 +507,11 @@ # Options controlling the kind of output CFLAGS_common += -pipe # Options controlling C dialect +ifeq ($(CONFIG_ALLOW_UNSUPPORTED_C2X),y) +CFLAGS_common += -std=gnu2x +else CFLAGS_common += -std=gnu11 +endif # C language options CFLAGS_common += -ffreestanding CFLAGS_common += -fno-builtin diff --git a/src/Kconfig b/src/Kconfig index ef3c72c..14cea50 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -98,6 +98,13 @@ On some architectures CLANG does not work that well. Use this only to try to get CLANG working.
+config ALLOW_UNSUPPORTED_C2X + bool + default n + help + C2x is not supported. Don't enable this option. + Use only to build test and prepar for C2x dialect. + config ANY_TOOLCHAIN bool "Allow building with any toolchain" default n diff --git a/src/include/stdbool.h b/src/include/stdbool.h index 3733527..a587673 100644 --- a/src/include/stdbool.h +++ b/src/include/stdbool.h @@ -3,7 +3,10 @@ #ifndef __STDBOOL_H__ #define __STDBOOL_H__
+#if __STDC_VERSION__ < 202300L typedef _Bool bool; +#endif + #define true 1 #define false 0
diff --git a/src/include/stddef.h b/src/include/stddef.h index 82d38c3..6a68152 100644 --- a/src/include/stddef.h +++ b/src/include/stddef.h @@ -19,7 +19,12 @@ typedef __WCHAR_TYPE__ wchar_t; typedef __WINT_TYPE__ wint_t;
+#if __STDC_VERSION__ > 202300L +typedef typeof(nullptr) nullptr_t; +#define NULL nullptr +#else #define NULL ((void *)0) +#endif
/* The devicetree data structures are only mutable in ramstage. All other stages have a constant devicetree. */