2020-11-11 23:55:37 +08:00
|
|
|
From 6b12d8b5c30a84aa5767b1b18ecf5ba5e99a1654 Mon Sep 17 00:00:00 2001
|
2020-05-17 18:26:59 +08:00
|
|
|
From: Xiang Xiao <xiaoxiang@xiaomi.com>
|
2020-11-08 18:09:47 +08:00
|
|
|
Date: Fri, 2 Oct 2020 13:25:43 +0800
|
2020-05-17 18:26:59 +08:00
|
|
|
Subject: [PATCH] [libcxx] Port to NuttX(https://nuttx.apache.org/) RTOS
|
|
|
|
|
2020-11-08 18:09:47 +08:00
|
|
|
Since NuttX conform to POSIX standard, the code need to add is very simple
|
|
|
|
|
|
|
|
Co-authored-by: YAMAMOTO Takashi <yamamoto@midokura.com>
|
|
|
|
|
|
|
|
Differential Revision: https://reviews.llvm.org/D88718
|
2020-05-17 18:26:59 +08:00
|
|
|
---
|
2020-11-11 23:55:37 +08:00
|
|
|
include/__config | 3 ++-
|
2020-05-17 18:26:59 +08:00
|
|
|
include/__locale | 2 ++
|
2020-11-11 23:55:37 +08:00
|
|
|
include/support/nuttx/xlocale.h | 18 ++++++++++++++++++
|
2020-11-08 18:09:47 +08:00
|
|
|
src/include/config_elast.h | 4 ++++
|
2020-05-17 18:26:59 +08:00
|
|
|
src/locale.cpp | 2 +-
|
2020-11-11 23:55:37 +08:00
|
|
|
5 files changed, 27 insertions(+), 2 deletions(-)
|
2020-05-17 18:26:59 +08:00
|
|
|
create mode 100644 include/support/nuttx/xlocale.h
|
|
|
|
|
|
|
|
diff --git a/include/__config libcxx/include/__config
|
2020-11-11 23:55:37 +08:00
|
|
|
index eeef9c53a9f..9ace3b46028 100644
|
2020-05-17 18:26:59 +08:00
|
|
|
--- a/include/__config
|
|
|
|
+++ libcxx/include/__config
|
2020-11-11 23:55:37 +08:00
|
|
|
@@ -1117,6 +1117,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
|
2020-05-17 18:26:59 +08:00
|
|
|
# if defined(__FreeBSD__) || \
|
|
|
|
defined(__wasi__) || \
|
|
|
|
defined(__NetBSD__) || \
|
|
|
|
+ defined(__NuttX__) || \
|
|
|
|
defined(__linux__) || \
|
|
|
|
defined(__GNU__) || \
|
|
|
|
defined(__APPLE__) || \
|
2020-11-11 23:55:37 +08:00
|
|
|
@@ -1219,7 +1220,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
|
2020-11-08 18:09:47 +08:00
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
-#if defined(__BIONIC__) || defined(__CloudABI__) || \
|
|
|
|
+#if defined(__BIONIC__) || defined(__CloudABI__) || defined(__NuttX__) || \
|
|
|
|
defined(__Fuchsia__) || defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC)
|
|
|
|
#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
|
|
|
|
#endif
|
2020-05-17 18:26:59 +08:00
|
|
|
diff --git a/include/__locale libcxx/include/__locale
|
2020-11-11 23:55:37 +08:00
|
|
|
index 125adcf68c8..ebededf066b 100644
|
2020-05-17 18:26:59 +08:00
|
|
|
--- a/include/__locale
|
|
|
|
+++ libcxx/include/__locale
|
2020-11-11 23:55:37 +08:00
|
|
|
@@ -22,6 +22,8 @@
|
2020-05-17 18:26:59 +08:00
|
|
|
#if defined(_LIBCPP_MSVCRT_LIKE)
|
|
|
|
# include <cstring>
|
|
|
|
# include <support/win32/locale_win32.h>
|
|
|
|
+#elif defined(__NuttX__)
|
|
|
|
+# include <support/nuttx/xlocale.h>
|
|
|
|
#elif defined(_AIX)
|
|
|
|
# include <support/ibm/xlocale.h>
|
|
|
|
#elif defined(__ANDROID__)
|
|
|
|
diff --git a/include/support/nuttx/xlocale.h libcxx/include/support/nuttx/xlocale.h
|
|
|
|
new file mode 100644
|
2020-11-08 18:09:47 +08:00
|
|
|
index 00000000000..b70d6200504
|
2020-05-17 18:26:59 +08:00
|
|
|
--- /dev/null
|
|
|
|
+++ libcxx/include/support/nuttx/xlocale.h
|
2020-11-08 18:09:47 +08:00
|
|
|
@@ -0,0 +1,18 @@
|
2020-05-17 18:26:59 +08:00
|
|
|
+// -*- C++ -*-
|
|
|
|
+//===-------------------- support/nuttx/xlocale.h -------------------------===//
|
|
|
|
+//
|
|
|
|
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
+// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
+//
|
|
|
|
+//===----------------------------------------------------------------------===//
|
|
|
|
+
|
|
|
|
+#ifndef _LIBCPP_SUPPORT_NUTTX_XLOCALE_H
|
|
|
|
+#define _LIBCPP_SUPPORT_NUTTX_XLOCALE_H
|
|
|
|
+
|
|
|
|
+#if defined(__NuttX__)
|
|
|
|
+#include <support/xlocale/__posix_l_fallback.h>
|
|
|
|
+#include <support/xlocale/__strtonum_fallback.h>
|
|
|
|
+#endif // __NuttX__
|
|
|
|
+
|
|
|
|
+#endif
|
|
|
|
diff --git a/src/include/config_elast.h libcxx/src/include/config_elast.h
|
2020-11-08 18:09:47 +08:00
|
|
|
index 501cbc4ffeb..3113f9fb5cd 100644
|
2020-05-17 18:26:59 +08:00
|
|
|
--- a/src/include/config_elast.h
|
|
|
|
+++ libcxx/src/include/config_elast.h
|
2020-11-08 18:09:47 +08:00
|
|
|
@@ -17,10 +17,14 @@
|
|
|
|
#include <errno.h>
|
|
|
|
#endif
|
2020-05-17 18:26:59 +08:00
|
|
|
|
2020-11-08 18:09:47 +08:00
|
|
|
+// Note: _LIBCPP_ELAST needs to be defined only on platforms
|
|
|
|
+// where strerror/strerror_r can't handle out-of-range errno values.
|
2020-05-17 18:26:59 +08:00
|
|
|
#if defined(ELAST)
|
|
|
|
#define _LIBCPP_ELAST ELAST
|
2020-11-08 18:09:47 +08:00
|
|
|
#elif defined(_NEWLIB_VERSION)
|
2020-05-17 18:26:59 +08:00
|
|
|
#define _LIBCPP_ELAST __ELASTERROR
|
2020-11-08 18:09:47 +08:00
|
|
|
+#elif defined(__NuttX__)
|
|
|
|
+// No _LIBCPP_ELAST needed on NuttX
|
2020-05-17 18:26:59 +08:00
|
|
|
#elif defined(__Fuchsia__)
|
|
|
|
// No _LIBCPP_ELAST needed on Fuchsia
|
2020-11-08 18:09:47 +08:00
|
|
|
#elif defined(__wasi__)
|
2020-05-17 18:26:59 +08:00
|
|
|
diff --git a/src/locale.cpp libcxx/src/locale.cpp
|
2020-11-11 23:55:37 +08:00
|
|
|
index 5fdc14992f8..ed93727b544 100644
|
2020-05-17 18:26:59 +08:00
|
|
|
--- a/src/locale.cpp
|
|
|
|
+++ libcxx/src/locale.cpp
|
|
|
|
@@ -30,7 +30,7 @@
|
|
|
|
#include "__sso_allocator"
|
|
|
|
#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
|
|
|
|
#include "support/win32/locale_win32.h"
|
|
|
|
-#elif !defined(__BIONIC__)
|
|
|
|
+#elif !defined(__BIONIC__) && !defined(__NuttX__)
|
|
|
|
#include <langinfo.h>
|
|
|
|
#endif
|
|
|
|
#include <stdlib.h>
|
|
|
|
--
|
|
|
|
2.17.1
|
|
|
|
|