[libc-commits] [libc] [libc] add iswblank entrypoint (PR #185272)

via libc-commits libc-commits at lists.llvm.org
Wed Mar 11 08:50:23 PDT 2026


https://github.com/alowqie updated https://github.com/llvm/llvm-project/pull/185272

>From 69c120ac11d16a3d58244df123a1a8661935355c Mon Sep 17 00:00:00 2001
From: alowqie <25634711+alowqie at users.noreply.github.com>
Date: Sun, 8 Mar 2026 12:25:25 +0100
Subject: [PATCH 1/2] [libc] add iswblank entrypoint

---
 libc/config/baremetal/arm/entrypoints.txt   |  1 +
 libc/config/baremetal/riscv/entrypoints.txt |  1 +
 libc/config/darwin/aarch64/entrypoints.txt  |  1 +
 libc/config/linux/aarch64/entrypoints.txt   |  1 +
 libc/config/linux/arm/entrypoints.txt       |  1 +
 libc/config/linux/riscv/entrypoints.txt     |  1 +
 libc/config/linux/x86_64/entrypoints.txt    |  1 +
 libc/config/windows/entrypoints.txt         |  1 +
 libc/include/wctype.yaml                    |  6 ++++++
 libc/src/wctype/CMakeLists.txt              | 11 ++++++++++
 libc/src/wctype/iswblank.cpp                | 21 ++++++++++++++++++
 libc/src/wctype/iswblank.h                  | 21 ++++++++++++++++++
 libc/test/src/wctype/CMakeLists.txt         |  9 ++++++++
 libc/test/src/wctype/iswblank_test.cpp      | 24 +++++++++++++++++++++
 14 files changed, 100 insertions(+)
 create mode 100644 libc/src/wctype/iswblank.cpp
 create mode 100644 libc/src/wctype/iswblank.h
 create mode 100644 libc/test/src/wctype/iswblank_test.cpp

diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 3731f4341163d..9962cc2c7df41 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -304,6 +304,7 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.wctype.iswdigit
     libc.src.wctype.iswlower
     libc.src.wctype.iswspace
+    libc.src.wctype.iswblank
 
     # internal entrypoints
     libc.startup.baremetal.init
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index 35598afd527e1..c1f9663280e83 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -301,6 +301,7 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.wctype.iswdigit
     libc.src.wctype.iswlower
     libc.src.wctype.iswspace
+    libc.src.wctype.iswblank
 
     # internal entrypoints
     libc.startup.baremetal.init
diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index dccbba529f77e..a6fcf12157f7e 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -107,6 +107,7 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.wctype.iswdigit
     libc.src.wctype.iswlower
     libc.src.wctype.iswspace
+    libc.src.wctype.iswblank
 )
 
 if(LLVM_LIBC_FULL_BUILD)
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 6d90052164eab..34eff64823f3f 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -374,6 +374,7 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.wctype.iswdigit
     libc.src.wctype.iswlower
     libc.src.wctype.iswspace
+    libc.src.wctype.iswblank
 
     # sys/uio.h entrypoints
     libc.src.sys.uio.writev
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index 66634f0e86bb4..b9e679041d2d8 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -199,6 +199,7 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.wctype.iswdigit
     libc.src.wctype.iswlower
     libc.src.wctype.iswspace
+    libc.src.wctype.iswblank
 )
 
 if(LLVM_LIBC_FULL_BUILD)
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 38f38bd105355..a0a2a486c761f 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -378,6 +378,7 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.wctype.iswdigit
     libc.src.wctype.iswlower
     libc.src.wctype.iswspace
+    libc.src.wctype.iswblank
 
     # sys/uio.h entrypoints
     libc.src.sys.uio.writev
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 860795dbf77ba..a2454102cb0a1 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -423,6 +423,7 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.wctype.iswdigit
     libc.src.wctype.iswlower
     libc.src.wctype.iswspace
+    libc.src.wctype.iswblank
 
     # sys/uio.h entrypoints
     libc.src.sys.uio.writev
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index 3a0ee3c5e3e73..d5a33895f1cb2 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -112,6 +112,7 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.wctype.iswcntrl
     libc.src.wctype.iswlower
     libc.src.wctype.iswspace
+    libc.src.wctype.iswblank
 )
 
 set(TARGET_LIBM_ENTRYPOINTS
diff --git a/libc/include/wctype.yaml b/libc/include/wctype.yaml
index c2432e235330f..cbb69b6422e29 100644
--- a/libc/include/wctype.yaml
+++ b/libc/include/wctype.yaml
@@ -32,3 +32,9 @@ functions:
     return_type: int
     arguments:
       - type: wint_t
+  - name: iswblank
+    standards:
+      - stdc
+    return_type: int
+    arguments:
+      - type: wint_t
diff --git a/libc/src/wctype/CMakeLists.txt b/libc/src/wctype/CMakeLists.txt
index f93081f05f85a..e617ed3e2b19c 100644
--- a/libc/src/wctype/CMakeLists.txt
+++ b/libc/src/wctype/CMakeLists.txt
@@ -62,3 +62,14 @@ add_entrypoint_object(
     libc.src.__support.wctype_utils
     libc.hdr.types.wint_t
 )
+
+add_entrypoint_object(
+  iswblank
+  SRCS
+    iswblank.cpp
+  HDRS
+    iswblank.h
+  DEPENDS
+    libc.src.__support.wctype_utils
+    libc.hdr.types.wint_t
+)
diff --git a/libc/src/wctype/iswblank.cpp b/libc/src/wctype/iswblank.cpp
new file mode 100644
index 0000000000000..2c42218e582b9
--- /dev/null
+++ b/libc/src/wctype/iswblank.cpp
@@ -0,0 +1,21 @@
+//===-- Implementation of iswblank ----------------------------------------===//
+//
+// 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/iswblank.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(int, iswblank, (wint_t c)) {
+  return internal::isblank(static_cast<wchar_t>(c));
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/wctype/iswblank.h b/libc/src/wctype/iswblank.h
new file mode 100644
index 0000000000000..78e7573f5cea6
--- /dev/null
+++ b/libc/src/wctype/iswblank.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for iswblank ----------------------*- 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_ISWBLANK_H
+#define LLVM_LIBC_SRC_WCTYPE_ISWBLANK_H
+
+#include "hdr/types/wint_t.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+int iswblank(wint_t c);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_WCTYPE_ISWBLANK_H
diff --git a/libc/test/src/wctype/CMakeLists.txt b/libc/test/src/wctype/CMakeLists.txt
index b7934192e7f82..f580f8201829e 100644
--- a/libc/test/src/wctype/CMakeLists.txt
+++ b/libc/test/src/wctype/CMakeLists.txt
@@ -62,3 +62,12 @@ add_libc_test(
     libc.src.wctype.iswspace
 )
 
+add_libc_test(
+  iswblank_test
+  SUITE
+    libc_wctype_unittests
+  SRCS
+    iswblank_test.cpp
+  DEPENDS
+    libc.src.wctype.iswblank
+)
diff --git a/libc/test/src/wctype/iswblank_test.cpp b/libc/test/src/wctype/iswblank_test.cpp
new file mode 100644
index 0000000000000..137f8c218ee1a
--- /dev/null
+++ b/libc/test/src/wctype/iswblank_test.cpp
@@ -0,0 +1,24 @@
+//===-- Unittests for iswblank --------------------------------------------===//
+//
+// 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/__support/CPP/span.h"
+#include "src/wctype/iswblank.h"
+
+#include "test/UnitTest/Test.h"
+
+TEST(LlvmLibciswblank, SimpleTest) {
+  EXPECT_NE(LIBC_NAMESPACE::iswblank(' '), 0);
+  EXPECT_NE(LIBC_NAMESPACE::iswblank('\t'), 0);
+
+  EXPECT_EQ(LIBC_NAMESPACE::iswblank('a'), 0);
+  EXPECT_EQ(LIBC_NAMESPACE::iswblank('\n'), 0);
+  EXPECT_EQ(LIBC_NAMESPACE::iswblank('3'), 0);
+  EXPECT_EQ(LIBC_NAMESPACE::iswblank('?'), 0);
+  EXPECT_EQ(LIBC_NAMESPACE::iswblank('\0'), 0);
+  EXPECT_EQ(LIBC_NAMESPACE::iswblank(-1), 0);
+}

>From ebc4d455efa4b310ce86a615ad718a504b03c55e Mon Sep 17 00:00:00 2001
From: alowqie <areida at pm.me>
Date: Mon, 9 Mar 2026 19:57:16 +0100
Subject: [PATCH 2/2] add missing dependency, remove include

---
 libc/src/wctype/CMakeLists.txt         |  2 +-
 libc/src/wctype/iswblank.cpp           | 42 +++++++++++------------
 libc/src/wctype/iswblank.h             | 42 +++++++++++------------
 libc/test/src/wctype/iswblank_test.cpp | 47 +++++++++++++-------------
 4 files changed, 66 insertions(+), 67 deletions(-)

diff --git a/libc/src/wctype/CMakeLists.txt b/libc/src/wctype/CMakeLists.txt
index e617ed3e2b19c..f4eeee4729142 100644
--- a/libc/src/wctype/CMakeLists.txt
+++ b/libc/src/wctype/CMakeLists.txt
@@ -26,7 +26,7 @@ add_entrypoint_object(
   HDRS
     iswdigit.h
   DEPENDS
-    libc.src.__support.wctype_utils    
+    libc.src.__support.wctype_utils
 )
 
 add_entrypoint_object(
diff --git a/libc/src/wctype/iswblank.cpp b/libc/src/wctype/iswblank.cpp
index 2c42218e582b9..f1f35743eecb6 100644
--- a/libc/src/wctype/iswblank.cpp
+++ b/libc/src/wctype/iswblank.cpp
@@ -1,21 +1,21 @@
-//===-- Implementation of iswblank ----------------------------------------===//
-//
-// 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/iswblank.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(int, iswblank, (wint_t c)) {
-  return internal::isblank(static_cast<wchar_t>(c));
-}
-
-} // namespace LIBC_NAMESPACE_DECL
+//===-- Implementation of iswblank ----------------------------------------===//
+//
+// 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/iswblank.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(int, iswblank, (wint_t c)) {
+  return internal::isblank(static_cast<wchar_t>(c));
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/wctype/iswblank.h b/libc/src/wctype/iswblank.h
index 78e7573f5cea6..031568650e700 100644
--- a/libc/src/wctype/iswblank.h
+++ b/libc/src/wctype/iswblank.h
@@ -1,21 +1,21 @@
-//===-- Implementation header for iswblank ----------------------*- 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_ISWBLANK_H
-#define LLVM_LIBC_SRC_WCTYPE_ISWBLANK_H
-
-#include "hdr/types/wint_t.h"
-#include "src/__support/common.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-int iswblank(wint_t c);
-
-} // namespace LIBC_NAMESPACE_DECL
-
-#endif // LLVM_LIBC_SRC_WCTYPE_ISWBLANK_H
+//===-- Implementation header for iswblank ----------------------*- 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_ISWBLANK_H
+#define LLVM_LIBC_SRC_WCTYPE_ISWBLANK_H
+
+#include "hdr/types/wint_t.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+int iswblank(wint_t c);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_WCTYPE_ISWBLANK_H
diff --git a/libc/test/src/wctype/iswblank_test.cpp b/libc/test/src/wctype/iswblank_test.cpp
index 137f8c218ee1a..62df76ed9bb1e 100644
--- a/libc/test/src/wctype/iswblank_test.cpp
+++ b/libc/test/src/wctype/iswblank_test.cpp
@@ -1,24 +1,23 @@
-//===-- Unittests for iswblank --------------------------------------------===//
-//
-// 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/__support/CPP/span.h"
-#include "src/wctype/iswblank.h"
-
-#include "test/UnitTest/Test.h"
-
-TEST(LlvmLibciswblank, SimpleTest) {
-  EXPECT_NE(LIBC_NAMESPACE::iswblank(' '), 0);
-  EXPECT_NE(LIBC_NAMESPACE::iswblank('\t'), 0);
-
-  EXPECT_EQ(LIBC_NAMESPACE::iswblank('a'), 0);
-  EXPECT_EQ(LIBC_NAMESPACE::iswblank('\n'), 0);
-  EXPECT_EQ(LIBC_NAMESPACE::iswblank('3'), 0);
-  EXPECT_EQ(LIBC_NAMESPACE::iswblank('?'), 0);
-  EXPECT_EQ(LIBC_NAMESPACE::iswblank('\0'), 0);
-  EXPECT_EQ(LIBC_NAMESPACE::iswblank(-1), 0);
-}
+//===-- Unittests for iswblank --------------------------------------------===//
+//
+// 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/iswblank.h"
+
+#include "test/UnitTest/Test.h"
+
+TEST(LlvmLibciswblank, SimpleTest) {
+  EXPECT_NE(LIBC_NAMESPACE::iswblank(' '), 0);
+  EXPECT_NE(LIBC_NAMESPACE::iswblank('\t'), 0);
+
+  EXPECT_EQ(LIBC_NAMESPACE::iswblank('a'), 0);
+  EXPECT_EQ(LIBC_NAMESPACE::iswblank('\n'), 0);
+  EXPECT_EQ(LIBC_NAMESPACE::iswblank('3'), 0);
+  EXPECT_EQ(LIBC_NAMESPACE::iswblank('?'), 0);
+  EXPECT_EQ(LIBC_NAMESPACE::iswblank('\0'), 0);
+  EXPECT_EQ(LIBC_NAMESPACE::iswblank(-1), 0);
+}



More information about the libc-commits mailing list