[libcxx-commits] [libcxx] cbf1904 - Upstream Bionic definitions of ctype_base/regex.

Dan Albert via libcxx-commits libcxx-commits at lists.llvm.org
Mon Apr 6 13:38:26 PDT 2020


Author: Dan Albert
Date: 2020-04-06T13:38:16-07:00
New Revision: cbf1904a3e054357806163b12547e1bed1641d5c

URL: https://github.com/llvm/llvm-project/commit/cbf1904a3e054357806163b12547e1bed1641d5c
DIFF: https://github.com/llvm/llvm-project/commit/cbf1904a3e054357806163b12547e1bed1641d5c.diff

LOG: Upstream Bionic definitions of ctype_base/regex.

Summary:
This is a patch that Android has been carrying in its tree for several
years. This patch upstreams the existing ABI.

There's some historical cruft here. __regex_word used to be a part of
regex_traits rather than ctype_base. Bionic also used to use its own
ctype implementation because the libc++ builtin one wasn't available
yet. Bionic's ctype masks were 8 bits wide and already saturated, so a
wider type needed to be used for the regex mask, and the existing
value was already used so Android needed to specify its own.

Since then Android has migrated to the builtin ctype implementation
and this patch probably should have been dropped then. Unfortunately
that was not noticed at the time, so now we need to keep this to
maintain the current ABI.

Reviewers: EricWF, #libc, ldionne

Reviewed By: #libc, ldionne

Subscribers: dexonsmith, ldionne, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D76171

Added: 
    

Modified: 
    libcxx/include/__locale
    libcxx/include/regex

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__locale b/libcxx/include/__locale
index 2b6982fc6810..6d10fa4d3d64 100644
--- a/libcxx/include/__locale
+++ b/libcxx/include/__locale
@@ -496,7 +496,13 @@ public:
     static const mask punct  = 1<<7;
     static const mask xdigit = 1<<8;
     static const mask blank  = 1<<9;
+#if defined(__BIONIC__)
+    // Historically this was a part of regex_traits rather than ctype_base. The
+    // historical value of the constant is preserved for ABI compatibility.
+    static const mask __regex_word = 0x8000;
+#else
     static const mask __regex_word = 1<<10;
+#endif // defined(__BIONIC__)
 #endif
     static const mask alnum  = alpha | digit;
     static const mask graph  = alnum | punct;

diff  --git a/libcxx/include/regex b/libcxx/include/regex
index e33ac25b8b38..c917c401293d 100644
--- a/libcxx/include/regex
+++ b/libcxx/include/regex
@@ -1001,7 +1001,19 @@ public:
     typedef _CharT                  char_type;
     typedef basic_string<char_type> string_type;
     typedef locale                  locale_type;
+#ifdef __BIONIC__
+    // 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
+    // to make room for __regex_word (then a part of this class rather than
+    // ctype_base). Bionic has since moved to the builtin ctype_base
+    // 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.
+    typedef uint16_t char_class_type;
+#else
     typedef ctype_base::mask        char_class_type;
+#endif
 
     static const char_class_type __regex_word = ctype_base::__regex_word;
 private:


        


More information about the libcxx-commits mailing list