diff options
author | Fabian Keßler <fabian_kessler@gmx.de> | 2024-05-01 00:08:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-30 15:08:38 -0700 |
commit | cd7a7a56fc73c73855036f77a4f69ea90c75c27a (patch) | |
tree | 198532b89e3bacd7eca2c9d6ad24349491c4e0ab /libc/include | |
parent | 89f833588e573b6b9762bb4eca5b08a5d7bad9c5 (diff) | |
download | llvm-cd7a7a56fc73c73855036f77a4f69ea90c75c27a.zip llvm-cd7a7a56fc73c73855036f77a4f69ea90c75c27a.tar.gz llvm-cd7a7a56fc73c73855036f77a4f69ea90c75c27a.tar.bz2 |
Add basic char*_t support for libc (partial WG14 N2653) (#90360)
This PR implements a part of WG14 N2653:
- Define C23 char8_t
- Define C11 char16_t
- Define C11 char32_t
Missing goals are:
- The type of UTF-8 character literals is changed from unsigned char to
char8_t. (Since UTF-8 character literals already have type unsigned
char, this is not a semantic change).
- New mbrtoc8() and c8rtomb() functions declared in <uchar.h> enable
conversions between multibyte characters and UTF-8.
- A new ATOMIC_CHAR8_T_LOCK_FREE macro.
- A new atomic_char8_t typedef name.
Diffstat (limited to 'libc/include')
-rw-r--r-- | libc/include/CMakeLists.txt | 3 | ||||
-rw-r--r-- | libc/include/llvm-libc-types/CMakeLists.txt | 15 | ||||
-rw-r--r-- | libc/include/llvm-libc-types/char16_t.h | 17 | ||||
-rw-r--r-- | libc/include/llvm-libc-types/char32_t.h | 17 | ||||
-rw-r--r-- | libc/include/llvm-libc-types/char8_t.h | 17 |
5 files changed, 69 insertions, 0 deletions
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt index aeef46a..6dea8e5 100644 --- a/libc/include/CMakeLists.txt +++ b/libc/include/CMakeLists.txt @@ -603,6 +603,9 @@ add_gen_header( DEPENDS .llvm_libc_common_h .llvm-libc-types.mbstate_t + .llvm-libc-types.char8_t + .llvm-libc-types.char16_t + .llvm-libc-types.char32_t ) add_gen_header( diff --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt index 310374f..16e343d 100644 --- a/libc/include/llvm-libc-types/CMakeLists.txt +++ b/libc/include/llvm-libc-types/CMakeLists.txt @@ -90,6 +90,21 @@ add_header(tcflag_t HDR tcflag_t.h) add_header(struct_termios HDR struct_termios.h DEPENDS .cc_t .speed_t .tcflag_t) add_header(__getoptargv_t HDR __getoptargv_t.h) add_header(wchar_t HDR wchar_t.h) +add_header(char8_t HDR char8_t.h) +add_header( + char16_t + HDR + char16_t.h + DEPENDS + libc.include.llvm-libc-macros.stdint_macros +) +add_header( + char32_t + HDR + char32_t.h + DEPENDS + libc.include.llvm-libc-macros.stdint_macros +) add_header(wint_t HDR wint_t.h) add_header(sa_family_t HDR sa_family_t.h) add_header(socklen_t HDR socklen_t.h) diff --git a/libc/include/llvm-libc-types/char16_t.h b/libc/include/llvm-libc-types/char16_t.h new file mode 100644 index 0000000..1f5847a --- /dev/null +++ b/libc/include/llvm-libc-types/char16_t.h @@ -0,0 +1,17 @@ +//===-- Definition of char16_t type ---------------------------------------===// +// +// 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 LLVM_LIBC_TYPES_CHAR16_T_H +#define LLVM_LIBC_TYPES_CHAR16_T_H + +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L +#include "../llvm-libc-macros/stdint-macros.h" +typedef uint_least16_t char16_t; +#endif + +#endif // LLVM_LIBC_TYPES_CHAR16_T_H diff --git a/libc/include/llvm-libc-types/char32_t.h b/libc/include/llvm-libc-types/char32_t.h new file mode 100644 index 0000000..20b72dc --- /dev/null +++ b/libc/include/llvm-libc-types/char32_t.h @@ -0,0 +1,17 @@ +//===-- Definition of char32_t type ---------------------------------------===// +// +// 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 LLVM_LIBC_TYPES_CHAR32_T_H +#define LLVM_LIBC_TYPES_CHAR32_T_H + +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L +#include "../llvm-libc-macros/stdint-macros.h" +typedef uint_least32_t char32_t; +#endif + +#endif // LLVM_LIBC_TYPES_CHAR32_T_H diff --git a/libc/include/llvm-libc-types/char8_t.h b/libc/include/llvm-libc-types/char8_t.h new file mode 100644 index 0000000..ddadab1 --- /dev/null +++ b/libc/include/llvm-libc-types/char8_t.h @@ -0,0 +1,17 @@ +//===-- Definition of char8_t type ----------------------------------------===// +// +// 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 LLVM_LIBC_TYPES_CHAR8_T_H +#define LLVM_LIBC_TYPES_CHAR8_T_H + +#if !defined(__cplusplus) && defined(__STDC_VERSION__) && \ + __STDC_VERSION__ >= 202311L +typedef unsigned char char8_t; +#endif + +#endif // LLVM_LIBC_TYPES_CHAR8_T_H |