Skip to content

Commit cd932a1

Browse files
committed
[libcxx] Define _LIBCPP_HAS_C8RTOMB_MBRTOC8 for picolibc
Starting from picolibc 1.8.9, the `char8_t` related functions are provided. This patch adds logic to detect the underlying picolibc version and define the `_LIBCPP_HAS_C8RTOMB_MBRTOC8 macro` accordingly.
1 parent a1672d7 commit cd932a1

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

libcxx/include/__config

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,8 +1027,12 @@ typedef __char32_t char32_t;
10271027
# else
10281028
# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 0
10291029
# endif
1030-
# else
1031-
# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 0
1030+
# elif defined (_LIBCPP_PICOLIBC_PREREQ)
1031+
# if _LIBCPP_PICOLIBC_PREREQ(1, 8, 9) && defined(__cpp_char8_t)
1032+
# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 1
1033+
# else
1034+
# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 0
1035+
# endif
10321036
# endif
10331037

10341038
// There are a handful of public standard library types that are intended to

libcxx/include/__configuration/platform.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
// user code. Move code paths that need _NEWLIB_VERSION to another customization mechanism.
4848
#if __has_include(<picolibc.h>)
4949
# include <picolibc.h>
50+
# define _LIBCPP_PICOLIBC_VERSION_INT(maj, min, patch) (maj * 10000 + min * 100 + patch)
51+
# define _LIBCPP_PICOLIBC_PREREQ(maj, min, patch) \
52+
_LIBCPP_PICOLIBC_VERSION_INT(__PICOLIBC__, __PICOLIBC_MINOR__, __PICOLIBC_PATCHLEVEL__) >= \
53+
_LIBCPP_PICOLIBC_VERSION_INT(maj, min, patch)
5054
#endif
5155

5256
#ifndef __BYTE_ORDER__

0 commit comments

Comments
 (0)