Skip to content

Commit 77f1c39

Browse files
committed
[libc] add wctype.h header
Add basic configurations to generate wctype.h header file. To begin with this header file just exposes one function iswalpha.
1 parent ae3bba4 commit 77f1c39

File tree

8 files changed

+94
-0
lines changed

8 files changed

+94
-0
lines changed

libc/config/baremetal/arm/entrypoints.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,9 @@ set(TARGET_LIBC_ENTRYPOINTS
278278
libc.src.wchar.wcslen
279279
libc.src.wchar.wctob
280280

281+
# wctype.h entrypoints
282+
libc.src.wctype.iswalpha
283+
281284
# internal entrypoints
282285
libc.startup.baremetal.init
283286
libc.startup.baremetal.fini

libc/include/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,15 @@ add_header_macro(
720720
.llvm-libc-types.wchar_t
721721
)
722722

723+
add_header_macro(
724+
wctype
725+
../libc/include/wctype.yaml
726+
wctype.h
727+
DEPENDS
728+
.llvm_libc_common_h
729+
.llvm-libc-types.wint_t
730+
)
731+
723732
add_header_macro(
724733
locale
725734
../libc/include/locale.yaml

libc/include/wctype.h.def

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//===-- C standard library header network.h -------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIBC_WCTYPE_H
10+
#define LLVM_LIBC_WCTYPE_H
11+
12+
#include "__llvm-libc-common.h"
13+
14+
%%public_api()
15+
16+
#endif // LLVM_LIBC_WCTYPE_H

libc/include/wctype.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
header: wctype.h
2+
header_template: wctype.h.def
3+
macros: []
4+
types:
5+
- type_name: wint_t
6+
enums: []
7+
objects: []
8+
functions:
9+
- name: iswalpha
10+
standards:
11+
- stdc
12+
return_type: int
13+
arguments:
14+
- type: wint_t

libc/src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ add_subdirectory(strings)
1717
add_subdirectory(time)
1818
add_subdirectory(unistd)
1919
add_subdirectory(wchar)
20+
add_subdirectory(wctype)
2021

2122
if(${LIBC_TARGET_OS} STREQUAL "linux")
2223
add_subdirectory(dirent)

libc/src/wctype/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
add_entrypoint_object(
2+
iswalpha
3+
SRCS
4+
iswalpha.cpp
5+
HDRS
6+
iswalpha.h
7+
DEPENDS
8+
libc.src.__support.wctype_utils
9+
)

libc/src/wctype/iswalpha.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//===-- Implementation of wctob -------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "src/wctype/iswalpha.h"
10+
#include "src/__support/common.h"
11+
#include "src/__support/wctype_utils.h"
12+
13+
#include "hdr/types/wint_t.h"
14+
15+
namespace LIBC_NAMESPACE_DECL {
16+
17+
LLVM_LIBC_FUNCTION(bool, iswalpha, (wint_t c)) {
18+
return internal::iswalpha(c);
19+
}
20+
21+
} // namespace LIBC_NAMESPACE_DECL

libc/src/wctype/iswalpha.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//===-- Implementation header for iswalpha ----------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIBC_SRC_WCHAR_WCTOB_H
10+
#define LLVM_LIBC_SRC_WCHAR_WCTOB_H
11+
12+
#include "hdr/types/wint_t.h"
13+
#include "src/__support/common.h"
14+
15+
namespace LIBC_NAMESPACE_DECL {
16+
17+
bool iswalpha(wint_t c);
18+
19+
} // namespace LIBC_NAMESPACE_DECL
20+
21+
#endif // LLVM_LIBC_SRC_WCHAR_WCTOB_H

0 commit comments

Comments
 (0)