aboutsummaryrefslogtreecommitdiff
path: root/libcxx/include/regex
diff options
context:
space:
mode:
authorAlex Richardson <alexrichardson@google.com>2022-06-20 15:44:57 +0100
committerAlex Richardson <alexrichardson@google.com>2022-11-23 09:04:42 +0000
commit4559864897500193d2812cea7b66dc8daba0b836 (patch)
treea593dcea871312d783050c5d7fd5b6e7abc7d5f7 /libcxx/include/regex
parent88218d5c5282c7b13bee667a0ce975a540aed74c (diff)
downloadllvm-4559864897500193d2812cea7b66dc8daba0b836.zip
llvm-4559864897500193d2812cea7b66dc8daba0b836.tar.gz
llvm-4559864897500193d2812cea7b66dc8daba0b836.tar.bz2
[libc++] Fix __regex_word value when using newlib/picolibc
The ctype mask for newlib/picolibc is fully saturated, so __regex_word has to overlap with one of the values. This commit uses the same workaround as bionic did (uint16_t for char_class_type inside regex_traits). It should be possible to have libc++ provide the default rune table instead, but that will require a new mechanism to detect newlib inside __config since the header defining the newlib/picolibc macros has not been included yet inside __config. Doing it this way also avoids duplicating the ctype table for newlib, reducing the global data size. Differential Revision: https://reviews.llvm.org/D138195
Diffstat (limited to 'libcxx/include/regex')
-rw-r--r--libcxx/include/regex7
1 files changed, 6 insertions, 1 deletions
diff --git a/libcxx/include/regex b/libcxx/include/regex
index 3c3a2e4..f351973 100644
--- a/libcxx/include/regex
+++ b/libcxx/include/regex
@@ -1026,7 +1026,7 @@ public:
typedef _CharT char_type;
typedef basic_string<char_type> string_type;
typedef locale locale_type;
-#ifdef __BIONIC__
+#if defined(__BIONIC__) || defined(_NEWLIB_VERSION)
// Originally bionic's ctype_base used its own ctype masks because the
// builtin ctype implementation wasn't in libc++ yet. Bionic's ctype mask
// was only 8 bits wide and already saturated, so it used a wider type here
@@ -1035,6 +1035,11 @@ public:
// implementation, but this was not updated to match. Since then Android has
// needed to maintain a stable libc++ ABI, and this can't be changed without
// an ABI break.
+ // We also need this workaround for newlib since _NEWLIB_VERSION is not
+ // defined yet inside __config, so we can't set the
+ // _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE macro. Additionally, newlib is
+ // often used for space constrained environments, so it makes sense not to
+ // duplicate the ctype table.
typedef uint16_t char_class_type;
#else
typedef ctype_base::mask char_class_type;