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/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.h.def b/libc/include/wctype.h.def new file mode 100644 index 0000000000000..8d9ff521e66be --- /dev/null +++ b/libc/include/wctype.h.def @@ -0,0 +1,16 @@ +//===-- C standard library header network.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_WCTYPE_H +#define LLVM_LIBC_WCTYPE_H + +#include "__llvm-libc-common.h" + +%%public_api() + +#endif // LLVM_LIBC_WCTYPE_H diff --git a/libc/include/wctype.yaml b/libc/include/wctype.yaml new file mode 100644 index 0000000000000..bb7f0cab551c1 --- /dev/null +++ b/libc/include/wctype.yaml @@ -0,0 +1,14 @@ +header: wctype.h +header_template: wctype.h.def +macros: [] +types: + - type_name: wint_t +enums: [] +objects: [] +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..920ce70e23eff --- /dev/null +++ b/libc/src/wctype/iswalpha.cpp @@ -0,0 +1,21 @@ +//===-- Implementation of wctob -------------------------------------------===// +// +// 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..6a6d5eaa791e5 --- /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_WCHAR_WCTOB_H +#define LLVM_LIBC_SRC_WCHAR_WCTOB_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_WCHAR_WCTOB_H