From 3dc6b4c9bd9624ed259e676f8e9761dbf660c1bb Mon Sep 17 00:00:00 2001 From: Philippe Leduc Date: Wed, 24 Apr 2024 17:01:11 +0200 Subject: [PATCH] Add basic support for locales in order to C++ streams to build and work for simple cases (POSIX / C locale). Fix build with C++ GCC toolchain --- arch/arm/src/cmake/Toolchain.cmake | 2 - arch/arm/src/common/Toolchain.defs | 2 - arch/arm64/src/Toolchain.defs | 2 - arch/arm64/src/cmake/Toolchain.cmake | 2 - arch/avr/src/avr/Toolchain.defs | 2 - arch/avr/src/avr32/Toolchain.defs | 4 +- arch/ceva/src/xc5/Toolchain.defs | 2 - arch/ceva/src/xm6/Toolchain.defs | 2 - arch/mips/src/mips32/Toolchain.defs | 2 - arch/misoc/src/lm32/Toolchain.defs | 2 - arch/misoc/src/minerva/Toolchain.defs | 2 - arch/or1k/src/mor1kx/Toolchain.defs | 2 - arch/risc-v/src/cmake/Toolchain.cmake | 2 - arch/risc-v/src/common/Toolchain.defs | 2 - arch/sim/src/cmake/Toolchain.cmake | 2 - arch/sparc/src/sparc_v8/Toolchain.defs | 2 - arch/x86_64/src/cmake/Toolchain.cmake | 2 - arch/xtensa/src/lx6/Toolchain.defs | 2 - arch/xtensa/src/lx7/Toolchain.defs | 2 - boards/sim/sim/sim/scripts/Make.defs | 2 - include/ctype.h | 17 ++++++ libs/libc/ctype/CMakeLists.txt | 3 +- libs/libc/ctype/Make.defs | 2 +- libs/libc/ctype/lib_ctype.c | 77 ++++++++++++++++++++++++++ libs/libc/locale/CMakeLists.txt | 11 +++- libs/libc/locale/Make.defs | 1 + libs/libc/locale/lib_maxlocale.c | 45 +++++++++++++++ libs/libxx/Kconfig | 2 + tools/Export.mk | 5 ++ tools/mkexport.sh | 2 + tools/toolchain.cmake.export | 3 +- 31 files changed, 164 insertions(+), 46 deletions(-) create mode 100644 libs/libc/ctype/lib_ctype.c create mode 100644 libs/libc/locale/lib_maxlocale.c diff --git a/arch/arm/src/cmake/Toolchain.cmake b/arch/arm/src/cmake/Toolchain.cmake index 41d2c89dd6..4c55953543 100644 --- a/arch/arm/src/cmake/Toolchain.cmake +++ b/arch/arm/src/cmake/Toolchain.cmake @@ -187,8 +187,6 @@ set(ARCHCFLAGS "-Wstrict-prototypes") if(NOT CONFIG_LIBCXXTOOLCHAIN) set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -nostdinc++") -else() - set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -D_STDLIB_H_") endif() if(NOT CONFIG_CXX_EXCEPTION) diff --git a/arch/arm/src/common/Toolchain.defs b/arch/arm/src/common/Toolchain.defs index 22c65a5ee8..e96aa55f02 100644 --- a/arch/arm/src/common/Toolchain.defs +++ b/arch/arm/src/common/Toolchain.defs @@ -301,8 +301,6 @@ ARCHCXXFLAGS += -Wno-attributes -Wno-unknown-pragmas ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y) ARCHCXXFLAGS += -nostdinc++ -else - ARCHCXXFLAGS += -D_STDLIB_H_ endif ifneq ($(CONFIG_ARCH_TOOLCHAIN_CLANG),y) diff --git a/arch/arm64/src/Toolchain.defs b/arch/arm64/src/Toolchain.defs index 4de3fa6732..015622af49 100644 --- a/arch/arm64/src/Toolchain.defs +++ b/arch/arm64/src/Toolchain.defs @@ -109,8 +109,6 @@ ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y) ARCHCXXFLAGS += -nostdinc++ -else - ARCHCXXFLAGS += -D_STDLIB_H_ endif ifneq ($(CONFIG_ARCH_TOOLCHAIN_CLANG),y) diff --git a/arch/arm64/src/cmake/Toolchain.cmake b/arch/arm64/src/cmake/Toolchain.cmake index e6069a30ab..233172e68b 100644 --- a/arch/arm64/src/cmake/Toolchain.cmake +++ b/arch/arm64/src/cmake/Toolchain.cmake @@ -127,8 +127,6 @@ set(ARCHCXXFLAGS if(NOT CONFIG_LIBCXXTOOLCHAIN) set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -nostdinc++") -else() - set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -D_STDLIB_H_") endif() if(NOT ${CONFIG_ARCH_TOOLCHAIN_CLANG}) diff --git a/arch/avr/src/avr/Toolchain.defs b/arch/avr/src/avr/Toolchain.defs index 6ed29966fa..d60a34c24c 100644 --- a/arch/avr/src/avr/Toolchain.defs +++ b/arch/avr/src/avr/Toolchain.defs @@ -106,8 +106,6 @@ ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y) ARCHCXXFLAGS += -nostdinc++ -else - ARCHCXXFLAGS += -D_STDLIB_H_ endif ifneq ($(CONFIG_CXX_STANDARD),) diff --git a/arch/avr/src/avr32/Toolchain.defs b/arch/avr/src/avr32/Toolchain.defs index fe8a6edc01..97ce2fd174 100644 --- a/arch/avr/src/avr32/Toolchain.defs +++ b/arch/avr/src/avr32/Toolchain.defs @@ -46,15 +46,13 @@ else endif ARCHCFLAGS += -fno-common -ARCHCXXFLAGS += -fno-common +ARCHCXXFLAGS += -fno-common ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y) ARCHCXXFLAGS += -nostdinc++ -else - ARCHCXXFLAGS += -D_STDLIB_H_ endif ifneq ($(CONFIG_CXX_STANDARD),) diff --git a/arch/ceva/src/xc5/Toolchain.defs b/arch/ceva/src/xc5/Toolchain.defs index 63d52a76e7..4baa578d51 100644 --- a/arch/ceva/src/xc5/Toolchain.defs +++ b/arch/ceva/src/xc5/Toolchain.defs @@ -72,8 +72,6 @@ ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y) ARCHCXXFLAGS += -nostdinc++ -else - ARCHCXXFLAGS += -D_STDLIB_H_ endif ARCHCPUFLAGS = -mrtl-version-$(RTL_VERSION) -Wa,-rtl$(RTL_VERSION) diff --git a/arch/ceva/src/xm6/Toolchain.defs b/arch/ceva/src/xm6/Toolchain.defs index e85becdfe1..9bc1263905 100644 --- a/arch/ceva/src/xm6/Toolchain.defs +++ b/arch/ceva/src/xm6/Toolchain.defs @@ -72,8 +72,6 @@ ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y) ARCHCXXFLAGS += -nostdinc++ -else - ARCHCXXFLAGS += -D_STDLIB_H_ endif ARCHCPUFLAGS = -mrtl-version-$(RTL_VERSION) -Wa,-rtl$(RTL_VERSION) diff --git a/arch/mips/src/mips32/Toolchain.defs b/arch/mips/src/mips32/Toolchain.defs index 2b37f35be5..92853e5880 100644 --- a/arch/mips/src/mips32/Toolchain.defs +++ b/arch/mips/src/mips32/Toolchain.defs @@ -267,8 +267,6 @@ ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y) ARCHCXXFLAGS += -nostdinc++ -else - ARCHCXXFLAGS += -D_STDLIB_H_ endif ifneq ($(CONFIG_CXX_STANDARD),) diff --git a/arch/misoc/src/lm32/Toolchain.defs b/arch/misoc/src/lm32/Toolchain.defs index 7a8e89918d..6bfb4f7823 100644 --- a/arch/misoc/src/lm32/Toolchain.defs +++ b/arch/misoc/src/lm32/Toolchain.defs @@ -79,8 +79,6 @@ ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y) ARCHCXXFLAGS += -nostdinc++ -else - ARCHCXXFLAGS += -D_STDLIB_H_ endif ifneq ($(CONFIG_CXX_STANDARD),) diff --git a/arch/misoc/src/minerva/Toolchain.defs b/arch/misoc/src/minerva/Toolchain.defs index f7401aa499..05ae535e96 100644 --- a/arch/misoc/src/minerva/Toolchain.defs +++ b/arch/misoc/src/minerva/Toolchain.defs @@ -67,8 +67,6 @@ EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name) ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y) ARCHCXXFLAGS += -nostdinc++ -else - ARCHCXXFLAGS += -D_STDLIB_H_ endif ifeq ($(CONFIG_LIBM_TOOLCHAIN),y) diff --git a/arch/or1k/src/mor1kx/Toolchain.defs b/arch/or1k/src/mor1kx/Toolchain.defs index 3baa1ab927..eb49f87d56 100644 --- a/arch/or1k/src/mor1kx/Toolchain.defs +++ b/arch/or1k/src/mor1kx/Toolchain.defs @@ -62,8 +62,6 @@ ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y) ARCHCXXFLAGS += -nostdinc++ -else - ARCHCXXFLAGS += -D_STDLIB_H_ endif ifneq ($(CONFIG_CXX_STANDARD),) diff --git a/arch/risc-v/src/cmake/Toolchain.cmake b/arch/risc-v/src/cmake/Toolchain.cmake index 7beca6b3a4..a72460c048 100644 --- a/arch/risc-v/src/cmake/Toolchain.cmake +++ b/arch/risc-v/src/cmake/Toolchain.cmake @@ -158,8 +158,6 @@ set(ARCHCXXFLAGS if(NOT CONFIG_LIBCXXTOOLCHAIN) set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -nostdinc++") -else() - set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -D_STDLIB_H_") endif() if(NOT ${CONFIG_ARCH_TOOLCHAIN_CLANG}) diff --git a/arch/risc-v/src/common/Toolchain.defs b/arch/risc-v/src/common/Toolchain.defs index a8fb39e163..c9e09c2261 100644 --- a/arch/risc-v/src/common/Toolchain.defs +++ b/arch/risc-v/src/common/Toolchain.defs @@ -95,8 +95,6 @@ ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y) ARCHCXXFLAGS += -nostdinc++ -else - ARCHCXXFLAGS += -D_STDLIB_H_ endif ifneq ($(CONFIG_ARCH_TOOLCHAIN_CLANG),y) diff --git a/arch/sim/src/cmake/Toolchain.cmake b/arch/sim/src/cmake/Toolchain.cmake index ab07999033..46003a3a86 100644 --- a/arch/sim/src/cmake/Toolchain.cmake +++ b/arch/sim/src/cmake/Toolchain.cmake @@ -102,8 +102,6 @@ set(ARCHCFLAGS "-Wstrict-prototypes") if(NOT CONFIG_LIBCXXTOOLCHAIN) set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -nostdinc++") -else() - set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -D_STDLIB_H_") endif() if(NOT CONFIG_CXX_EXCEPTION) diff --git a/arch/sparc/src/sparc_v8/Toolchain.defs b/arch/sparc/src/sparc_v8/Toolchain.defs index cd72f0ffb2..42f5dbdf82 100644 --- a/arch/sparc/src/sparc_v8/Toolchain.defs +++ b/arch/sparc/src/sparc_v8/Toolchain.defs @@ -84,8 +84,6 @@ ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y) ARCHCXXFLAGS += -nostdinc++ -else - ARCHCXXFLAGS += -D_STDLIB_H_ endif ifneq ($(CONFIG_CXX_STANDARD),) diff --git a/arch/x86_64/src/cmake/Toolchain.cmake b/arch/x86_64/src/cmake/Toolchain.cmake index 7464128193..1bd11bca4b 100644 --- a/arch/x86_64/src/cmake/Toolchain.cmake +++ b/arch/x86_64/src/cmake/Toolchain.cmake @@ -93,8 +93,6 @@ set(ARCHCXXFLAGS if(NOT CONFIG_LIBCXXTOOLCHAIN) set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -nostdinc++") -else() - set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -D_STDLIB_H_") endif() if(NOT CONFIG_CXX_EXCEPTION) diff --git a/arch/xtensa/src/lx6/Toolchain.defs b/arch/xtensa/src/lx6/Toolchain.defs index ce0567f37b..0417bef85a 100644 --- a/arch/xtensa/src/lx6/Toolchain.defs +++ b/arch/xtensa/src/lx6/Toolchain.defs @@ -113,8 +113,6 @@ ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y) ARCHCXXFLAGS += -nostdinc++ -else - ARCHCXXFLAGS += -D_STDLIB_H_ endif ifneq ($(CONFIG_ARCH_TOOLCHAIN_CLANG),y) diff --git a/arch/xtensa/src/lx7/Toolchain.defs b/arch/xtensa/src/lx7/Toolchain.defs index fc45c45756..c46fcca9d2 100644 --- a/arch/xtensa/src/lx7/Toolchain.defs +++ b/arch/xtensa/src/lx7/Toolchain.defs @@ -117,8 +117,6 @@ ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y) ARCHCXXFLAGS += -nostdinc++ -else - ARCHCXXFLAGS += -D_STDLIB_H_ endif ifneq ($(CONFIG_ARCH_TOOLCHAIN_CLANG),y) diff --git a/boards/sim/sim/sim/scripts/Make.defs b/boards/sim/sim/sim/scripts/Make.defs index 4b7399fedf..457298f8d4 100644 --- a/boards/sim/sim/sim/scripts/Make.defs +++ b/boards/sim/sim/sim/scripts/Make.defs @@ -122,8 +122,6 @@ ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y) ARCHCXXFLAGS += -nostdinc++ -else - ARCHCXXFLAGS += -D_STDLIB_H_ endif ifneq ($(CONFIG_CXX_STANDARD),) diff --git a/include/ctype.h b/include/ctype.h index a24231030c..3e560fb551 100644 --- a/include/ctype.h +++ b/include/ctype.h @@ -33,6 +33,23 @@ #include #include +/**************************************************************************** + * Macro Definitions + ****************************************************************************/ + +/* GNU libstdc++ is expecting ctype.h to define a few macros for + * locale related functions like C++ streams. + */ + +#define _U 01 +#define _L 02 +#define _N 04 +#define _S 010 +#define _P 020 +#define _C 040 +#define _X 0100 +#define _B 0200 + /**************************************************************************** * Inline Functions ****************************************************************************/ diff --git a/libs/libc/ctype/CMakeLists.txt b/libs/libc/ctype/CMakeLists.txt index 2376e5e2a5..c77b2b4d41 100644 --- a/libs/libc/ctype/CMakeLists.txt +++ b/libs/libc/ctype/CMakeLists.txt @@ -34,4 +34,5 @@ target_sources( lib_isupper.c lib_isxdigit.c lib_tolower.c - lib_toupper.c) + lib_toupper.c + lib_ctype.c) diff --git a/libs/libc/ctype/Make.defs b/libs/libc/ctype/Make.defs index cea6cd882b..86c4272753 100644 --- a/libs/libc/ctype/Make.defs +++ b/libs/libc/ctype/Make.defs @@ -23,7 +23,7 @@ CSRCS += lib_isalnum.c lib_isalpha.c lib_isascii.c lib_isblank.c CSRCS += lib_iscntrl.c lib_isdigit.c lib_isgraph.c lib_islower.c CSRCS += lib_isprint.c lib_ispunct.c lib_isspace.c lib_isupper.c -CSRCS += lib_isxdigit.c lib_tolower.c lib_toupper.c +CSRCS += lib_isxdigit.c lib_tolower.c lib_toupper.c lib_ctype.c DEPPATH += --dep-path ctype VPATH += :ctype diff --git a/libs/libc/ctype/lib_ctype.c b/libs/libc/ctype/lib_ctype.c new file mode 100644 index 0000000000..c0bea821c1 --- /dev/null +++ b/libs/libc/ctype/lib_ctype.c @@ -0,0 +1,77 @@ +/**************************************************************************** + * libs/libc/ctype/lib_ctype.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/* GNU libstdc++ is expecting an array _ctype_ to be defined. This array + * is usually defined in GNU libc or newlib. + * Here the system support only basic ASCII locale. + */ + +const char _ctype_[] = +{ + 0, + _C, _C, _C, _C, _C, _C, _C, _C, \ + _C, _C | _S, _C | _S, _C | _S, _C | _S, _C | _S, _C, _C, \ + _C, _C, _C, _C, _C, _C, _C, _C, \ + _C, _C, _C, _C, _C, _C, _C, _C, \ + _S | _B, _P, _P, _P, _P, _P, _P, _P, \ + _P, _P, _P, _P, _P, _P, _P, _P, \ + _N, _N, _N, _N, _N, _N, _N, _N, \ + _N, _N, _P, _P, _P, _P, _P, _P, \ + _P, _U | _X, _U | _X, _U | _X, _U | _X, _U | _X, _U | _X, _U, \ + _U, _U, _U, _U, _U, _U, _U, _U, \ + _U, _U, _U, _U, _U, _U, _U, _U, \ + _U, _U, _U, _P, _P, _P, _P, _P, \ + _P, _L | _X, _L | _X, _L | _X, _L | _X, _L | _X, _L | _X, _L, \ + _L, _L, _L, _L, _L, _L, _L, _L, \ + _L, _L, _L, _L, _L, _L, _L, _L, \ + _L, _L, _L, _P, _P, _P, _P, _C, \ + 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0 +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ diff --git a/libs/libc/locale/CMakeLists.txt b/libs/libc/locale/CMakeLists.txt index e293a05908..71346f3999 100644 --- a/libs/libc/locale/CMakeLists.txt +++ b/libs/libc/locale/CMakeLists.txt @@ -19,6 +19,13 @@ # ############################################################################## if(CONFIG_LIBC_LOCALE) - target_sources(c PRIVATE lib_duplocale.c lib_freelocale.c lib_localeconv.c - lib_newlocale.c lib_setlocale.c lib_uselocale.c) + target_sources( + c + PRIVATE lib_duplocale.c + lib_freelocale.c + lib_localeconv.c + lib_newlocale.c + lib_setlocale.c + lib_uselocale.c + lib_maxlocale.c) endif() diff --git a/libs/libc/locale/Make.defs b/libs/libc/locale/Make.defs index 5b6c0ba8d6..4612ab584f 100644 --- a/libs/libc/locale/Make.defs +++ b/libs/libc/locale/Make.defs @@ -25,6 +25,7 @@ ifeq ($(CONFIG_LIBC_LOCALE),y) CSRCS += lib_duplocale.c lib_freelocale.c lib_localeconv.c CSRCS += lib_newlocale.c lib_setlocale.c lib_uselocale.c CSRCS += lib_catalog.c lib_gettext.c lib_langinfo.c lib_iconv.c +CSRCS += lib_maxlocale.c # Add the locale directory to the build diff --git a/libs/libc/locale/lib_maxlocale.c b/libs/libc/locale/lib_maxlocale.c new file mode 100644 index 0000000000..1e007531dd --- /dev/null +++ b/libs/libc/locale/lib_maxlocale.c @@ -0,0 +1,45 @@ +/**************************************************************************** + * libs/libc/locale/lib_maxlocale.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#ifdef CONFIG_LIBC_LOCALE + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/* GNU libstdc++ is expecting some functions to be defined. + */ + +/* Shall return the max number of bytes of a multibyte character */ + +int __locale_mb_cur_max(void) +{ + return MB_CUR_MAX; +} + +#endif diff --git a/libs/libxx/Kconfig b/libs/libxx/Kconfig index 05f73e9585..d38134b93d 100644 --- a/libs/libxx/Kconfig +++ b/libs/libxx/Kconfig @@ -28,6 +28,8 @@ choice config LIBCXXTOOLCHAIN bool "Toolchain C++ support" + select HAVE_CXXINITIALIZE + select LIBC_LOCALE ---help--- Use Standard C++ library from toolchain. diff --git a/tools/Export.mk b/tools/Export.mk index c63d8c5b8a..ec7fa5c2e2 100644 --- a/tools/Export.mk +++ b/tools/Export.mk @@ -99,6 +99,11 @@ ifdef CONFIG_BUILD_PROTECTED endif ifdef CONFIG_BUILD_KERNEL @echo "NUTTX_BUILD=\"kernel\"" >> $(EXPORTDIR)/makeinfo.sh +endif +ifdef CONFIG_LIBCXX + @echo "NUTTX_CXX=\"libcxx\"" >> $(EXPORTDIR)/makeinfo.sh +else + @echo "NUTTX_CXX=\"cxx\"" >> $(EXPORTDIR)/makeinfo.sh endif $(Q) chmod 755 $(EXPORTDIR)/makeinfo.sh diff --git a/tools/mkexport.sh b/tools/mkexport.sh index 70db1a52f8..01fe771ef4 100755 --- a/tools/mkexport.sh +++ b/tools/mkexport.sh @@ -266,6 +266,7 @@ echo "NUTTX_ARCH = ${NUTTX_ARCH}" >>"${EXPORTDIR}/scripts/Make.defs" echo "NUTTX_ARCH_CHIP = ${NUTTX_ARCH_CHIP}" >>"${EXPORTDIR}/scripts/Make.defs" echo "NUTTX_BOARD = ${NUTTX_BOARD}" >>"${EXPORTDIR}/scripts/Make.defs" echo "NUTTX_BUILD = ${NUTTX_BUILD}" >>"${EXPORTDIR}/scripts/Make.defs" +echo "NUTTX_CXX = ${NUTTX_CXX}" >>"${EXPORTDIR}/scripts/Make.defs" echo "set(ARCHCFLAGS \"${ARCHCFLAGS}\")" > "${EXPORTDIR}/scripts/target.cmake" echo "set(ARCHCPUFLAGS \"${ARCHCPUFLAGS}\")" >>"${EXPORTDIR}/scripts/target.cmake" @@ -296,6 +297,7 @@ echo "set(NUTTX_ARCH \"${NUTTX_ARCH}\")" >>"${EXPORTDIR}/scripts/ echo "set(NUTTX_ARCH_CHIP \"${NUTTX_ARCH_CHIP}\")" >>"${EXPORTDIR}/scripts/target.cmake" echo "set(NUTTX_BOARD \"${NUTTX_BOARD}\")" >>"${EXPORTDIR}/scripts/target.cmake" echo "set(NUTTX_BUILD \"${NUTTX_BUILD}\")" >>"${EXPORTDIR}/scripts/target.cmake" +echo "set(NUTTX_CXX \"${NUTTX_CXX}\")" >>"${EXPORTDIR}/scripts/target.cmake" # Additional compilation options when the kernel is built diff --git a/tools/toolchain.cmake.export b/tools/toolchain.cmake.export index f739bc0fe0..1e9bc7ca5a 100644 --- a/tools/toolchain.cmake.export +++ b/tools/toolchain.cmake.export @@ -16,7 +16,8 @@ set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES ${NUTTX_PATH}/include ${NUTTX_PATH}/arch/chip) set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES - ${NUTTX_PATH}/include/libcxx ${NUTTX_PATH}/include ${NUTTX_PATH}/arch/chip) + ${NUTTX_PATH}/include/${NUTTX_CXX} ${NUTTX_PATH}/include + ${NUTTX_PATH}/arch/chip) file(GLOB STARTUP_OBJS ${NUTTX_PATH}/startup/*)