-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[libc] add wctype.h header #149202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[libc] add wctype.h header #149202
Conversation
Add basic configurations to generate wctype.h header file. To begin with this header file just exposes one function iswalpha.
@llvm/pr-subscribers-backend-risc-v @llvm/pr-subscribers-libc Author: Prabhu Rajasekaran (Prabhuk) ChangesAdd basic configurations to generate wctype.h header file. To begin with this header file just exposes one function iswalpha. Full diff: https://github.com/llvm/llvm-project/pull/149202.diff 8 Files Affected:
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index de7549c57ff44..80cd15eebc91f 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -278,6 +278,9 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.wchar.wcslen
libc.src.wchar.wctob
+ # wctype.h entrypoints
+ libc.src.wctype.iswalpha
+
# internal entrypoints
libc.startup.baremetal.init
libc.startup.baremetal.fini
diff --git a/libc/config/baremetal/arm/headers.txt b/libc/config/baremetal/arm/headers.txt
index 5666ef7e0012d..1f64afebdaaa7 100644
--- a/libc/config/baremetal/arm/headers.txt
+++ b/libc/config/baremetal/arm/headers.txt
@@ -23,4 +23,5 @@ set(TARGET_PUBLIC_HEADERS
libc.include.time
libc.include.uchar
libc.include.wchar
+ libc.include.wctype
)
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index 55268d19529c7..984b960acb2d7 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -720,6 +720,15 @@ add_header_macro(
.llvm-libc-types.wchar_t
)
+add_header_macro(
+ wctype
+ ../libc/include/wctype.yaml
+ wctype.h
+ DEPENDS
+ .llvm_libc_common_h
+ .llvm-libc-types.wint_t
+)
+
add_header_macro(
locale
../libc/include/locale.yaml
diff --git a/libc/include/wctype.yaml b/libc/include/wctype.yaml
new file mode 100644
index 0000000000000..fb4f96f7d17e4
--- /dev/null
+++ b/libc/include/wctype.yaml
@@ -0,0 +1,10 @@
+header: wctype.h
+types:
+ - type_name: wint_t
+functions:
+ - name: iswalpha
+ standards:
+ - stdc
+ return_type: int
+ arguments:
+ - type: wint_t
diff --git a/libc/src/CMakeLists.txt b/libc/src/CMakeLists.txt
index a665253c4cc03..d7a1e1f49e6ff 100644
--- a/libc/src/CMakeLists.txt
+++ b/libc/src/CMakeLists.txt
@@ -17,6 +17,7 @@ add_subdirectory(strings)
add_subdirectory(time)
add_subdirectory(unistd)
add_subdirectory(wchar)
+add_subdirectory(wctype)
if(${LIBC_TARGET_OS} STREQUAL "linux")
add_subdirectory(dirent)
diff --git a/libc/src/wctype/CMakeLists.txt b/libc/src/wctype/CMakeLists.txt
new file mode 100644
index 0000000000000..3ac5eaef8ed8b
--- /dev/null
+++ b/libc/src/wctype/CMakeLists.txt
@@ -0,0 +1,9 @@
+add_entrypoint_object(
+ iswalpha
+ SRCS
+ iswalpha.cpp
+ HDRS
+ iswalpha.h
+ DEPENDS
+ libc.src.__support.wctype_utils
+)
diff --git a/libc/src/wctype/iswalpha.cpp b/libc/src/wctype/iswalpha.cpp
new file mode 100644
index 0000000000000..7bd9e894234d6
--- /dev/null
+++ b/libc/src/wctype/iswalpha.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of iswcalpha ---------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/wctype/iswalpha.h"
+#include "src/__support/common.h"
+#include "src/__support/wctype_utils.h"
+
+#include "hdr/types/wint_t.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(bool, iswalpha, (wint_t c)) { return internal::iswalpha(c); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/wctype/iswalpha.h b/libc/src/wctype/iswalpha.h
new file mode 100644
index 0000000000000..681fc6ba79a54
--- /dev/null
+++ b/libc/src/wctype/iswalpha.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for iswalpha ----------------------*- C++ -*-===//
+//
+// 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_SRC_WCTYPE_ISWALPHA_H
+#define LLVM_LIBC_SRC_WCTYPE_ISWALPHA_H
+
+#include "hdr/types/wint_t.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bool iswalpha(wint_t c);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_WCTYPE_ISWALPHA_H
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about Linux (aarch64, arm, x86_64, riscv), Darwin aarch64, and Windows targets?
My focus was on baremetal 32 bit targets and was not sure if these platforms also needed this change. Added these entrypoints now. PTAL. Thank you. |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/153/builds/38494 Here is the relevant piece of the build log for the reference
|
Add basic configurations to generate wctype.h header file. To begin with this header file just exposes one function iswalpha.