Skip to content

Commit 6828233

Browse files
committed
[libc] Add ctype.h locale variants
Summary: This patch adds all the libc ctype variants. These ignore the locale ingormation completely, so they're pretty much just stubs. Because these use locale information, which is system scope, we do not enable building them outisde of full build mode.
1 parent a475351 commit 6828233

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+948
-29
lines changed

libc/config/gpu/entrypoints.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,35 @@ set(TARGET_LIBC_ENTRYPOINTS
44

55
# ctype.h entrypoints
66
libc.src.ctype.isalnum
7+
libc.src.ctype.isalnum_l
78
libc.src.ctype.isalpha
9+
libc.src.ctype.isalpha_l
810
libc.src.ctype.isascii
911
libc.src.ctype.isblank
12+
libc.src.ctype.isblank_l
1013
libc.src.ctype.iscntrl
14+
libc.src.ctype.iscntrl_l
1115
libc.src.ctype.isdigit
16+
libc.src.ctype.isdigit_l
1217
libc.src.ctype.isgraph
18+
libc.src.ctype.isgraph_l
1319
libc.src.ctype.islower
20+
libc.src.ctype.islower_l
1421
libc.src.ctype.isprint
22+
libc.src.ctype.isprint_l
1523
libc.src.ctype.ispunct
24+
libc.src.ctype.ispunct_l
1625
libc.src.ctype.isspace
26+
libc.src.ctype.isspace_l
1727
libc.src.ctype.isupper
28+
libc.src.ctype.isupper_l
1829
libc.src.ctype.isxdigit
30+
libc.src.ctype.isxdigit_l
1931
libc.src.ctype.toascii
2032
libc.src.ctype.tolower
33+
libc.src.ctype.tolower_l
2134
libc.src.ctype.toupper
35+
libc.src.ctype.toupper_l
2236

2337
# string.h entrypoints
2438
libc.src.string.bcmp

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,22 @@ endif()
781781

782782
if(LLVM_LIBC_FULL_BUILD)
783783
list(APPEND TARGET_LIBC_ENTRYPOINTS
784+
# ctype.h entrypoints
785+
libc.src.ctype.isalnum_l
786+
libc.src.ctype.isalpha_l
787+
libc.src.ctype.isblank_l
788+
libc.src.ctype.iscntrl_l
789+
libc.src.ctype.isdigit_l
790+
libc.src.ctype.isgraph_l
791+
libc.src.ctype.islower_l
792+
libc.src.ctype.isprint_l
793+
libc.src.ctype.ispunct_l
794+
libc.src.ctype.isspace_l
795+
libc.src.ctype.isupper_l
796+
libc.src.ctype.isxdigit_l
797+
libc.src.ctype.tolower_l
798+
libc.src.ctype.toupper_l
799+
784800
# assert.h entrypoints
785801
libc.src.assert.__assert_fail
786802

libc/include/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ add_header_macro(
4545
ctype.h
4646
DEPENDS
4747
.llvm_libc_common_h
48+
.llvm-libc-types.locale_t
4849
)
4950

5051
add_header_macro(

libc/include/ctype.h.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define LLVM_LIBC_CTYPE_H
1111

1212
#include "__llvm-libc-common.h"
13+
#include "llvm-libc-types/locale_t.h"
1314

1415
%%public_api()
1516

libc/newhdrgen/yaml/ctype.yaml

Lines changed: 98 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,101 @@ functions:
100100
return_type: int
101101
arguments:
102102
- type: int
103-
functions: null
103+
- name: isalnum_l
104+
standards:
105+
- stdc
106+
return_type: int
107+
arguments:
108+
- type: int
109+
- type: locale_t
110+
- name: isalpha_l
111+
standards:
112+
- stdc
113+
return_type: int
114+
arguments:
115+
- type: int
116+
- type: locale_t
117+
- name: isblank_l
118+
standards:
119+
- stdc
120+
return_type: int
121+
arguments:
122+
- type: int
123+
- type: locale_t
124+
- name: iscntrl_l
125+
standards:
126+
- stdc
127+
return_type: int
128+
arguments:
129+
- type: int
130+
- type: locale_t
131+
- name: isdigit_l
132+
standards:
133+
- stdc
134+
return_type: int
135+
arguments:
136+
- type: int
137+
- type: locale_t
138+
- name: isgraph_l
139+
standards:
140+
- stdc
141+
return_type: int
142+
arguments:
143+
- type: int
144+
- type: locale_t
145+
- name: islower_l
146+
standards:
147+
- stdc
148+
return_type: int
149+
arguments:
150+
- type: int
151+
- type: locale_t
152+
- name: isprint_l
153+
standards:
154+
- stdc
155+
return_type: int
156+
arguments:
157+
- type: int
158+
- type: locale_t
159+
- name: ispunct_l
160+
standards:
161+
- stdc
162+
return_type: int
163+
arguments:
164+
- type: int
165+
- type: locale_t
166+
- name: isspace_l
167+
standards:
168+
- stdc
169+
return_type: int
170+
arguments:
171+
- type: int
172+
- type: locale_t
173+
- name: isupper_l
174+
standards:
175+
- stdc
176+
return_type: int
177+
arguments:
178+
- type: int
179+
- type: locale_t
180+
- name: isxdigit_l
181+
standards:
182+
- stdc
183+
return_type: int
184+
arguments:
185+
- type: int
186+
- type: locale_t
187+
- name: tolower_l
188+
standards:
189+
- stdc
190+
return_type: int
191+
arguments:
192+
- type: int
193+
- type: locale_t
194+
- name: toupper_l
195+
standards:
196+
- stdc
197+
return_type: int
198+
arguments:
199+
- type: int
200+
- type: locale_t

libc/spec/stdc.td

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ def StdC : StandardSpec<"stdc"> {
44
PtrType StructTmPtr = PtrType<StructTmType>;
55
PtrType TimeTTypePtr = PtrType<TimeTType>;
66
NamedType ClockT = NamedType<"clock_t">;
7+
<<<<<<< HEAD
78
NamedType LocaleT = NamedType<"locale_t">;
9+
=======
10+
NamedType LocaleT : NamedType<"locale_t">;
11+
>>>>>>> a805b5fe17fa ([libc] Add `ctype.h` locale variants)
812

913
NamedType DivTType = NamedType<"div_t">;
1014
NamedType LDivTType = NamedType<"ldiv_t">;
@@ -108,6 +112,76 @@ def StdC : StandardSpec<"stdc"> {
108112
RetValSpec<IntType>,
109113
[ArgSpec<IntType>]
110114
>,
115+
FunctionSpec<
116+
"isalnum_l",
117+
RetValSpec<IntType>,
118+
[ArgSpec<IntType>, ArgSpec<LocaleT>]
119+
>,
120+
FunctionSpec<
121+
"isalpha_l",
122+
RetValSpec<IntType>,
123+
[ArgSpec<IntType>, ArgSpec<LocaleT>]
124+
>,
125+
FunctionSpec<
126+
"isblank_l",
127+
RetValSpec<IntType>,
128+
[ArgSpec<IntType>, ArgSpec<LocaleT>]
129+
>,
130+
FunctionSpec<
131+
"iscntrl_l",
132+
RetValSpec<IntType>,
133+
[ArgSpec<IntType>, ArgSpec<LocaleT>]
134+
>,
135+
FunctionSpec<
136+
"isdigit_l",
137+
RetValSpec<IntType>,
138+
[ArgSpec<IntType>, ArgSpec<LocaleT>]
139+
>,
140+
FunctionSpec<
141+
"isgraph_l",
142+
RetValSpec<IntType>,
143+
[ArgSpec<IntType>, ArgSpec<LocaleT>]
144+
>,
145+
FunctionSpec<
146+
"islower_l",
147+
RetValSpec<IntType>,
148+
[ArgSpec<IntType>, ArgSpec<LocaleT>]
149+
>,
150+
FunctionSpec<
151+
"isprint_l",
152+
RetValSpec<IntType>,
153+
[ArgSpec<IntType>, ArgSpec<LocaleT>]
154+
>,
155+
FunctionSpec<
156+
"ispunct_l",
157+
RetValSpec<IntType>,
158+
[ArgSpec<IntType>, ArgSpec<LocaleT>]
159+
>,
160+
FunctionSpec<
161+
"isspace_l",
162+
RetValSpec<IntType>,
163+
[ArgSpec<IntType>, ArgSpec<LocaleT>]
164+
>,
165+
FunctionSpec<
166+
"isupper_l",
167+
RetValSpec<IntType>,
168+
[ArgSpec<IntType>, ArgSpec<LocaleT>]
169+
>,
170+
FunctionSpec<
171+
"isxdigit_l",
172+
RetValSpec<IntType>,
173+
[ArgSpec<IntType>, ArgSpec<LocaleT>]
174+
>,
175+
FunctionSpec<
176+
"tolower_l",
177+
RetValSpec<IntType>,
178+
[ArgSpec<IntType>, ArgSpec<LocaleT>]
179+
>,
180+
FunctionSpec<
181+
"toupper_l",
182+
RetValSpec<IntType>,
183+
[ArgSpec<IntType>, ArgSpec<LocaleT>]
184+
>,
111185
]
112186
>;
113187

0 commit comments

Comments
 (0)