]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
stdlib: Implement mbrtoc8, c8rtomb, and the char8_t typedef.
authorTom Honermann <tom@honermann.net>
Thu, 30 Jun 2022 12:52:14 +0000 (08:52 -0400)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 6 Jul 2022 12:29:42 +0000 (09:29 -0300)
This change provides implementations for the mbrtoc8 and c8rtomb
functions adopted for C++20 via WG21 P0482R6 and for C2X via WG14
N2653.  It also provides the char8_t typedef from WG14 N2653.

The mbrtoc8 and c8rtomb functions are declared in uchar.h in C2X
mode or when the _GNU_SOURCE macro or C++20 __cpp_char8_t feature
test macro is defined.

The char8_t typedef is declared in uchar.h in C2X mode or when the
_GNU_SOURCE macro is defined and the C++20 __cpp_char8_t feature
test macro is not defined (if __cpp_char8_t is defined, then char8_t
is a builtin type).

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
40 files changed:
NEWS
sysdeps/mach/hurd/i386/libc.abilist
sysdeps/unix/sysv/linux/aarch64/libc.abilist
sysdeps/unix/sysv/linux/alpha/libc.abilist
sysdeps/unix/sysv/linux/arc/libc.abilist
sysdeps/unix/sysv/linux/arm/be/libc.abilist
sysdeps/unix/sysv/linux/arm/le/libc.abilist
sysdeps/unix/sysv/linux/csky/libc.abilist
sysdeps/unix/sysv/linux/hppa/libc.abilist
sysdeps/unix/sysv/linux/i386/libc.abilist
sysdeps/unix/sysv/linux/ia64/libc.abilist
sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
sysdeps/unix/sysv/linux/nios2/libc.abilist
sysdeps/unix/sysv/linux/or1k/libc.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
sysdeps/unix/sysv/linux/sh/be/libc.abilist
sysdeps/unix/sysv/linux/sh/le/libc.abilist
sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
wcsmbs/Makefile
wcsmbs/Versions
wcsmbs/c8rtomb.c [new file with mode: 0644]
wcsmbs/mbrtoc8.c [new file with mode: 0644]
wcsmbs/uchar.h

diff --git a/NEWS b/NEWS
index dbf351b89511baeaffc00fafe381b5393cab6599..df882ec2438e38a070d24707e9a9860551e8add3 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -51,6 +51,15 @@ Major new features:
   Previously, input bytes not within the ASCII range resulted in
   unpredictable output.
 
+* Support for the mbrtoc8 and c8rtomb multibyte/UTF-8 character conversion
+  functions has been added per the ISO C2X N2653 and C++20 P0482R6 proposals.
+  Support for the char8_t typedef has been added per the ISO C2X N2653
+  proposal.  The functions are declared in uchar.h in C2X mode or when the
+  _GNU_SOURCE macro or C++20 __cpp_char8_t feature test macro is defined.
+  The char8_t typedef is declared in uchar.h in C2X mode or when the
+  _GNU_SOURCE macro is defined and the C++20 __cpp_char8_t feature test macro
+  is not defined (if __cpp_char8_t is defined, then char8_t is a builtin type).
+
 Deprecated and removed features, and other changes affecting compatibility:
 
 * Support for prelink will be removed in the next release; this includes
index 4dc87e90616b8bd0de30deab2f39aab77a91fdbe..66fb0e28fa25d4db5c76f044fd523d02b009346a 100644 (file)
@@ -2289,6 +2289,8 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 close_range F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
index 16d34b55c6b932a53d830cec387c164f21ae9960..516b029d30364236f30a6c3e64626bede7935daf 100644 (file)
@@ -2616,10 +2616,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index 3f794bea0f01d2cea3156f8a6e78fcf47104bdc5..dde08899fe927019d0dffb5b88ec6d0801070640 100644 (file)
@@ -2713,10 +2713,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index 072627810ce5cf0e285fe31c9550777e98a0b2f1..ade44d3029eb3e4d03756f378c139b2d45d193ac 100644 (file)
@@ -2377,10 +2377,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index dbd5f07e6e40f85c567f2c37ff299c5969c76b0e..98b33708af5e5dbcb598106b67d36a250ac652eb 100644 (file)
@@ -496,10 +496,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index 0f02d79faa5c20b8f9eef0fcd840f7d72549370d..05dbbe5bccb4ebd7ae5c239b6963598e913ba228 100644 (file)
@@ -493,10 +493,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index 11d3b36a78bfd4f197e71a18cd432ccee4108c42..430a24349edbe76c19923cef59203426f3913e45 100644 (file)
@@ -2652,10 +2652,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index 5caa1321b15ea9f0a5127f6597db40a8f2483103..de446165267ee6e34cc73632e01c0df8f1903c9f 100644 (file)
@@ -2601,10 +2601,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index 276d7d5619687d3aaa906adeddd5ff0cf79c0c20..18b4fbf26eee2ef7b196ea6d5375967cf748c285 100644 (file)
@@ -2785,10 +2785,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index 5e2249518e9790865ea0a1fb9969ed71bf194071..a8e959d4171eb2a3581a91ec1c686e9154172e01 100644 (file)
@@ -2551,10 +2551,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index 802469a5b928478b2ef412b54ab6b06e529260ac..3a7e4ef6e4f8d403ec63f5729ef2a160f14351f1 100644 (file)
@@ -497,10 +497,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index 2f949397df5c89229ba774197d37eac855267d0c..864ad2cdf8c3d17f0892f1fed189203eb0e7dbc7 100644 (file)
@@ -2728,10 +2728,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index f63cc9cd4c22aba0141252096785625ad5b7cdba..163058420d6fcf03c4034892034cf04d7a119e1b 100644 (file)
@@ -2701,10 +2701,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index 88d2b707f9ef52b616bb0795965bfeda48b2180f..a6debfda56fc294b3c534c65f08011f4563b9b9b 100644 (file)
@@ -2698,10 +2698,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index 6c2bc0ee78f66e90e7efd95904ddef8f59186dd4..2b53d888de654bdfee314de7dda97736c3afd6b4 100644 (file)
@@ -2693,10 +2693,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index 09c9980d95febcf27684d9a119bb864e79aa657f..849aae41304517aa40bddad25d867b160993acf0 100644 (file)
@@ -2691,10 +2691,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index 763920ea8f8fb30fa60e1e7442e17dbfe42bff73..37f6c1bf58d86bf438d286cf2d8507a093baff38 100644 (file)
@@ -2699,10 +2699,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index 36d30558c1369dea59e0d228b1c959b3110f20f0..ff1eb91e101523e782508e7a54d20b15d3ce85c5 100644 (file)
@@ -2602,10 +2602,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index e4383fe46406c9fd566f8374366149aa06689eb3..361b91f547a75264decb75a236bd59cfaa616ef8 100644 (file)
@@ -2740,10 +2740,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index 735a8eea7ea6d7d444a39b57e33ee768e92833fa..cb916063779dcaa8cabdf02ce9c7042bea7a917b 100644 (file)
@@ -2123,10 +2123,12 @@ GLIBC_2.35 wprintf F
 GLIBC_2.35 write F
 GLIBC_2.35 writev F
 GLIBC_2.35 wscanf F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index 715dd31afe71530e1794cfcfa77e432e67577362..1264aff6ef49a4794de3ded60ca6c534aea6cdff 100644 (file)
@@ -2755,10 +2755,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index ac4b69e5fc410a8aec092feb93c4a561308fc009..f96d6e37b508806b97eb34450d9b8b12975a9967 100644 (file)
@@ -2788,10 +2788,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index fd42f1bc11aa4180c100ad51530146c07ab61a99..e7082e1bd354487e5fc0dc3a64f83b9b958d1f09 100644 (file)
@@ -2510,10 +2510,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index 24688916ddc365798c749a7edf6a28f42c4f5f9e..1032c7e46a9775e8c407773c472d9051cb824cca 100644 (file)
@@ -2812,10 +2812,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index 536eddf9f1faf9cda5908f1f458cb9cf4b89b161..f932db7c22a3b678271fc232b03eb00c3df1304d 100644 (file)
@@ -2379,10 +2379,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index 214b4f1c87d5111e6bbba730f3c9bcdaa1dc6cb6..ccc53b0bb859b90e23a82392dd4853997ae8ed34 100644 (file)
@@ -2579,10 +2579,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index bd738a4eb8d6d7f2109543d0d771f5175f91b340..dbf65010076cf71c863c713d48752fc90bc7d31c 100644 (file)
@@ -2753,10 +2753,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index 170361236a18f0f88b21c104cb98a19338bde313..98f08a01b6db78255b4d2b842215d12ee75af124 100644 (file)
@@ -2547,10 +2547,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index 88fcd03300df7ef517736110ece0dba85dfd6bf0..df11cc8f1382ba75ef090c398b8aff7650fe5b2b 100644 (file)
@@ -2608,10 +2608,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index f1115ef46d16adf5e7a5ffd6bcb5837064e6eb76..4ee5513d183808d3515b4bcb8eda0bbf4e5593b6 100644 (file)
@@ -2605,10 +2605,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index 6063da1acf316f87eed78a8994bac837ff9cda22..3cefa76871c3892fe3459269513ef16fffd3b32d 100644 (file)
@@ -2748,10 +2748,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index 780d2c0987dfbbdd4defe510c5ed1e2b1ec4dd8e..e3ea5c438337f0d5185c7cbc8e4c0330f3498993 100644 (file)
@@ -2574,10 +2574,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index 56cad609fe524d1f12cad935f76cab1392475dfc..2944bc783795da4447fc3c492e4ee535a09a8441 100644 (file)
@@ -2525,10 +2525,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index 2ed242a62dc7bb733fcb675c810222cd09b986cb..47296193afc74995364e652cc4a104b05f6284e0 100644 (file)
@@ -2631,10 +2631,12 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 c8rtomb F
 GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mbrtoc8 F
 GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
index df9a85f4a9d952ff53b40a3f24f62856890c38e0..bda281ad708ca4189ebe7eac3aaa7bfb5caa9184 100644 (file)
@@ -42,7 +42,7 @@ routines := wcscat wcschr wcscmp wcscpy wcscspn wcsdup wcslen wcsncat \
            wcsmbsload mbsrtowcs_l \
            isoc99_wscanf isoc99_vwscanf isoc99_fwscanf isoc99_vfwscanf \
            isoc99_swscanf isoc99_vswscanf \
-           mbrtoc16 c16rtomb mbrtoc32 c32rtomb
+           mbrtoc8 c8rtomb mbrtoc16 c16rtomb mbrtoc32 c32rtomb
 
 strop-tests :=  wcscmp wcsncmp wmemcmp wcslen wcschr wcsrchr wcscpy wcsnlen \
                wcpcpy wcsncpy wcpncpy wcscat wcsncat wcschrnul wcsspn wcspbrk \
index 0b31c1b94047c89e900268bd0749b1814a5d2a48..ec28acfb73f49677236df6b6f8e258def566dba2 100644 (file)
@@ -49,4 +49,7 @@ libc {
     wcstof32; wcstof64; wcstof32x;
     wcstof32_l; wcstof64_l; wcstof32x_l;
   }
+  GLIBC_2.36 {
+    c8rtomb; mbrtoc8;
+  }
 }
diff --git a/wcsmbs/c8rtomb.c b/wcsmbs/c8rtomb.c
new file mode 100644 (file)
index 0000000..b564770
--- /dev/null
@@ -0,0 +1,132 @@
+/* UTF-8 to multibyte conversion.
+   Copyright (C) 2022 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <uchar.h>
+#include <wchar.h>
+
+
+/* This is the private state used if PS is NULL.  */
+static mbstate_t state;
+
+size_t
+c8rtomb (char *s, char8_t c8, mbstate_t *ps)
+{
+  /* This implementation depends on the converter invoked by wcrtomb not
+     needing to retain state in either the top most bit of ps->__count or
+     in ps->__value between invocations.  This implementation uses the
+     top most bit of ps->__count to indicate that trailing code units are
+     expected and uses ps->__value to store previously seen code units.  */
+
+  wchar_t wc;
+
+  if (ps == NULL)
+    ps = &state;
+
+  if (s == NULL)
+    {
+      /* if 's' is a null pointer, behave as if u8'\0' was passed as 'c8'.  If
+         this occurs for an incomplete code unit sequence, then an error will
+         be reported below.  */
+      c8 = u8""[0];
+    }
+
+  if (! (ps->__count & 0x80000000))
+    {
+      /* Initial state.  */
+      if ((c8 >= 0x80 && c8 <= 0xC1) || c8 >= 0xF5)
+       {
+         /* An invalid lead code unit.  */
+         __set_errno (EILSEQ);
+         return -1;
+       }
+      if (c8 >= 0xC2)
+       {
+         /* A valid lead code unit.  */
+         ps->__count |= 0x80000000;
+         ps->__value.__wchb[0] = c8;
+         ps->__value.__wchb[3] = 1;
+         return 0;
+       }
+      /* A single byte (ASCII) code unit.  */
+      wc = c8;
+    }
+  else
+    {
+      char8_t cu1 = ps->__value.__wchb[0];
+      if (ps->__value.__wchb[3] == 1)
+       {
+         /* A single lead code unit was previously seen.  */
+         if ((c8 < 0x80 || c8 > 0xBF)
+              || (cu1 == 0xE0 && c8 < 0xA0)
+              || (cu1 == 0xED && c8 > 0x9F)
+              || (cu1 == 0xF0 && c8 < 0x90)
+              || (cu1 == 0xF4 && c8 > 0x8F))
+           {
+             /* An invalid second code unit.  */
+             __set_errno (EILSEQ);
+             return -1;
+           }
+         if (cu1 >= 0xE0)
+           {
+             /* A three or four code unit sequence.  */
+             ps->__value.__wchb[1] = c8;
+             ++ps->__value.__wchb[3];
+             return 0;
+           }
+         wc = ((cu1 & 0x1F) << 6)
+              + (c8 & 0x3F);
+       }
+      else
+       {
+         char8_t cu2 = ps->__value.__wchb[1];
+         /* A three or four byte code unit sequence.  */
+         if (c8 < 0x80 || c8 > 0xBF)
+           {
+             /* An invalid third or fourth code unit.  */
+             __set_errno (EILSEQ);
+             return -1;
+           }
+         if (ps->__value.__wchb[3] == 2 && cu1 >= 0xF0)
+           {
+             /* A four code unit sequence.  */
+             ps->__value.__wchb[2] = c8;
+             ++ps->__value.__wchb[3];
+             return 0;
+           }
+         if (cu1 < 0xF0)
+           {
+             wc = ((cu1 & 0x0F) << 12)
+                  + ((cu2 & 0x3F) << 6)
+                  + (c8 & 0x3F);
+           }
+         else
+           {
+             char8_t cu3 = ps->__value.__wchb[2];
+             wc = ((cu1 & 0x07) << 18)
+                  + ((cu2 & 0x3F) << 12)
+                  + ((cu3 & 0x3F) << 6)
+                  + (c8 & 0x3F);
+           }
+       }
+      ps->__count &= 0x7fffffff;
+      ps->__value.__wch = 0;
+    }
+
+  return wcrtomb (s, wc, ps);
+}
diff --git a/wcsmbs/mbrtoc8.c b/wcsmbs/mbrtoc8.c
new file mode 100644 (file)
index 0000000..dd80b52
--- /dev/null
@@ -0,0 +1,126 @@
+/* Multibyte to UTF-8 conversion.
+   Copyright (C) 2022 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <assert.h>
+#include <dlfcn.h>
+#include <errno.h>
+#include <gconv.h>
+#include <uchar.h>
+#include <wcsmbsload.h>
+
+#include <sysdep.h>
+
+#ifndef EILSEQ
+# define EILSEQ EINVAL
+#endif
+
+
+/* This is the private state used if PS is NULL.  */
+static mbstate_t state;
+
+size_t
+mbrtoc8 (char8_t *pc8, const char *s, size_t n, mbstate_t *ps)
+{
+  /* This implementation depends on the converter invoked by mbrtowc not
+     needing to retain state in either the top most bit of ps->__count or
+     in ps->__value between invocations.  This implementation uses the
+     top most bit of ps->__count to indicate that trailing code units are
+     yet to be written and uses ps->__value to store those code units.  */
+
+  if (ps == NULL)
+    ps = &state;
+
+  /* If state indicates that trailing code units are yet to be written, write
+     those first regardless of whether 's' is a null pointer.  */
+  if (ps->__count & 0x80000000)
+    {
+      /* ps->__value.__wchb[3] stores the index of the next code unit to
+         write.  Code units are stored in reverse order.  */
+      size_t i = ps->__value.__wchb[3];
+      if (pc8 != NULL)
+       {
+         *pc8 = ps->__value.__wchb[i];
+       }
+      if (i == 0)
+       {
+         ps->__count &= 0x7fffffff;
+         ps->__value.__wch = 0;
+       }
+      else
+       --ps->__value.__wchb[3];
+      return -3;
+    }
+
+  if (s == NULL)
+    {
+      /* if 's' is a null pointer, behave as if a null pointer was passed for
+         'pc8', an empty string was passed for 's', and 1 passed for 'n'.  */
+      pc8 = NULL;
+      s = "";
+      n = 1;
+    }
+
+  wchar_t wc;
+  size_t result;
+
+  result = mbrtowc (&wc, s, n, ps);
+  if (result <= n)
+    {
+      if (wc <= 0x7F)
+       {
+         if (pc8 != NULL)
+           *pc8 = wc;
+       }
+      else if (wc <= 0x7FF)
+       {
+         if (pc8 != NULL)
+           *pc8 = 0xC0 + ((wc >> 6) & 0x1F);
+         ps->__value.__wchb[0] = 0x80 + (wc & 0x3F);
+         ps->__value.__wchb[3] = 0;
+         ps->__count |= 0x80000000;
+       }
+      else if (wc <= 0xFFFF)
+       {
+         if (pc8 != NULL)
+           *pc8 = 0xE0 + ((wc >> 12) & 0x0F);
+         ps->__value.__wchb[1] = 0x80 + ((wc >> 6) & 0x3F);
+         ps->__value.__wchb[0] = 0x80 + (wc & 0x3F);
+         ps->__value.__wchb[3] = 1;
+         ps->__count |= 0x80000000;
+       }
+      else if (wc <= 0x10FFFF)
+       {
+         if (pc8 != NULL)
+           *pc8 = 0xF0 + ((wc >> 18) & 0x07);
+         ps->__value.__wchb[2] = 0x80 + ((wc >> 12) & 0x3F);
+         ps->__value.__wchb[1] = 0x80 + ((wc >> 6) & 0x3F);
+         ps->__value.__wchb[0] = 0x80 + (wc & 0x3F);
+         ps->__value.__wchb[3] = 2;
+         ps->__count |= 0x80000000;
+       }
+    }
+  if (result == 0 && wc != 0)
+    {
+      /* mbrtowc() never returns -3.  When a MB sequence converts to multiple
+         WCs, no input is consumed when writing the subsequent WCs resulting
+         in a result of 0 even if a null character wasn't written.  */
+      result = -3;
+    }
+
+  return result;
+}
index 051cdcbeb5082cc7e27ed08398da1c685f6297e4..c37e8619a004fa04bfeb9b83b6f0f5aff09bc1fc 100644 (file)
 #include <bits/types.h>
 #include <bits/types/mbstate_t.h>
 
+/* Declare the C2x char8_t typedef in C2x modes, but only if the C++
+  __cpp_char8_t feature test macro is not defined.  */
+#if __GLIBC_USE (ISOC2X) && !defined __cpp_char8_t
+/* Define the 8-bit character type.  */
+typedef unsigned char char8_t;
+#endif
+
 #ifndef __USE_ISOCXX11
 /* Define the 16-bit and 32-bit character types.  */
 typedef __uint_least16_t char16_t;
@@ -40,6 +47,20 @@ typedef __uint_least32_t char32_t;
 
 __BEGIN_DECLS
 
+/* Declare the C2x mbrtoc8() and c8rtomb() functions in C2x modes or if
+   the C++ __cpp_char8_t feature test macro is defined.  */
+#if __GLIBC_USE (ISOC2X) || defined __cpp_char8_t
+/* Write char8_t representation of multibyte character pointed
+   to by S to PC8.  */
+extern size_t mbrtoc8  (char8_t *__restrict __pc8,
+                       const char *__restrict __s, size_t __n,
+                       mbstate_t *__restrict __p) __THROW;
+
+/* Write multibyte representation of char8_t C8 to S.  */
+extern size_t c8rtomb  (char *__restrict __s, char8_t __c8,
+                       mbstate_t *__restrict __ps) __THROW;
+#endif
+
 /* Write char16_t representation of multibyte character pointed
    to by S to PC16.  */
 extern size_t mbrtoc16 (char16_t *__restrict __pc16,