aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Hosek <phosek@google.com>2024-03-12 21:26:58 -0700
committerGitHub <noreply@github.com>2024-03-12 21:26:58 -0700
commite25bf70d50cbf8bdebeacdaf3313486c1b1d0395 (patch)
tree68e1555d893be98dcd090e06f5a80c3ab3e7a289
parent2dbaf265255a5fa9643a8092ec2dffa881d2cf93 (diff)
downloadllvm-e25bf70d50cbf8bdebeacdaf3313486c1b1d0395.zip
llvm-e25bf70d50cbf8bdebeacdaf3313486c1b1d0395.tar.gz
llvm-e25bf70d50cbf8bdebeacdaf3313486c1b1d0395.tar.bz2
[libc] Add an empty definition of mbstate_t (#84993)
We expect to eventually provide a complete implementation, but having an empty definition is necessary to unblock the use of libc++ in embedded environments. See #84884 for more details.
-rw-r--r--libc/config/baremetal/api.td4
-rw-r--r--libc/config/baremetal/arm/headers.txt1
-rw-r--r--libc/config/baremetal/riscv/headers.txt1
-rw-r--r--libc/include/CMakeLists.txt10
-rw-r--r--libc/include/llvm-libc-types/CMakeLists.txt1
-rw-r--r--libc/include/llvm-libc-types/mbstate_t.h16
-rw-r--r--libc/include/uchar.h.def16
-rw-r--r--libc/spec/spec.td2
-rw-r--r--libc/spec/stdc.td12
9 files changed, 63 insertions, 0 deletions
diff --git a/libc/config/baremetal/api.td b/libc/config/baremetal/api.td
index 33b3a03..f096cdc 100644
--- a/libc/config/baremetal/api.td
+++ b/libc/config/baremetal/api.td
@@ -66,3 +66,7 @@ def StdlibAPI : PublicAPI<"stdlib.h"> {
def StringAPI : PublicAPI<"string.h"> {
let Types = ["size_t"];
}
+
+def UCharAPI : PublicAPI<"uchar.h"> {
+ let Types = ["mbstate_t"];
+}
diff --git a/libc/config/baremetal/arm/headers.txt b/libc/config/baremetal/arm/headers.txt
index 68d7017..962981f 100644
--- a/libc/config/baremetal/arm/headers.txt
+++ b/libc/config/baremetal/arm/headers.txt
@@ -13,4 +13,5 @@ set(TARGET_PUBLIC_HEADERS
libc.include.string
libc.include.strings
libc.include.sys_queue
+ libc.include.uchar
)
diff --git a/libc/config/baremetal/riscv/headers.txt b/libc/config/baremetal/riscv/headers.txt
index 68d7017..962981f 100644
--- a/libc/config/baremetal/riscv/headers.txt
+++ b/libc/config/baremetal/riscv/headers.txt
@@ -13,4 +13,5 @@ set(TARGET_PUBLIC_HEADERS
libc.include.string
libc.include.strings
libc.include.sys_queue
+ libc.include.uchar
)
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index 34d6839..b2cb104 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -583,12 +583,22 @@ add_gen_header(
)
add_gen_header(
+ uchar
+ DEF_FILE uchar.h.def
+ GEN_HDR uchar.h
+ DEPENDS
+ .llvm_libc_common_h
+ .llvm-libc-types.mbstate_t
+)
+
+add_gen_header(
wchar
DEF_FILE wchar.h.def
GEN_HDR wchar.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.wchar_macros
+ .llvm-libc-types.mbstate_t
.llvm-libc-types.size_t
.llvm-libc-types.wint_t
.llvm-libc-types.wchar_t
diff --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt
index e4f23b2..7fef976 100644
--- a/libc/include/llvm-libc-types/CMakeLists.txt
+++ b/libc/include/llvm-libc-types/CMakeLists.txt
@@ -39,6 +39,7 @@ add_header(uid_t HDR uid_t.h)
add_header(imaxdiv_t HDR imaxdiv_t.h)
add_header(ino_t HDR ino_t.h)
add_header(jmp_buf HDR jmp_buf.h)
+add_header(mbstate_t HDR mbstate_t.h)
add_header(mode_t HDR mode_t.h)
add_header(mtx_t HDR mtx_t.h DEPENDS .__futex_word .__mutex_type)
add_header(nlink_t HDR nlink_t.h)
diff --git a/libc/include/llvm-libc-types/mbstate_t.h b/libc/include/llvm-libc-types/mbstate_t.h
new file mode 100644
index 0000000..540d509
--- /dev/null
+++ b/libc/include/llvm-libc-types/mbstate_t.h
@@ -0,0 +1,16 @@
+//===-- Definition of mbstate_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_MBSTATE_T_H
+#define LLVM_LIBC_TYPES_MBSTATE_T_H
+
+// TODO: Complete this once we implement functions that operate on this type.
+typedef struct {
+} mbstate_t;
+
+#endif // LLVM_LIBC_TYPES_MBSTATE_T_H
diff --git a/libc/include/uchar.h.def b/libc/include/uchar.h.def
new file mode 100644
index 0000000..7e62d43
--- /dev/null
+++ b/libc/include/uchar.h.def
@@ -0,0 +1,16 @@
+//===-- C standard library header uchar.h ---------------------------------===//
+//
+// 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_UCHAR_H
+#define LLVM_LIBC_UCHAR_H
+
+#include <__llvm-libc-common.h>
+
+%%public_api()
+
+#endif // LLVM_LIBC_UCHAR_H
diff --git a/libc/spec/spec.td b/libc/spec/spec.td
index 580bd9c..87bf443 100644
--- a/libc/spec/spec.td
+++ b/libc/spec/spec.td
@@ -153,6 +153,8 @@ def EntryType : NamedType<"ENTRY">;
def EntryTypePtr : PtrType<EntryType>;
def EntryTypePtrPtr : PtrType<EntryTypePtr>;
+def MBStateTType : NamedType<"mbstate_t">;
+
class Macro<string name> {
string Name = name;
}
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index 938d372..afe01b1 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -1284,12 +1284,23 @@ def StdC : StandardSpec<"stdc"> {
]
>;
+ HeaderSpec UChar = HeaderSpec<
+ "uchar.h",
+ [], // Macros
+ [ //Types
+ MBStateTType,
+ ],
+ [], // Enumerations
+ []
+ >;
+
HeaderSpec WChar = HeaderSpec<
"wchar.h",
[ // Macros
Macro<"WEOF">,
],
[ //Types
+ MBStateTType,
SizeTType,
WIntType,
WCharType,
@@ -1324,6 +1335,7 @@ def StdC : StandardSpec<"stdc"> {
Signal,
Threads,
Time,
+ UChar,
WChar,
];
}