Skip to content

Commit 856dadb

Browse files
committed
[libc] Add ctype.h locale variants (#102711)
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 a7c8f41 commit 856dadb

Some content is hidden

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

48 files changed

+950
-31
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
@@ -782,6 +782,22 @@ endif()
782782

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

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/newhdrgen/yaml/ctype.yaml

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

libc/spec/stdc.td

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ def StdC : StandardSpec<"stdc"> {
3535
HeaderSpec CType = HeaderSpec<
3636
"ctype.h",
3737
[], // Macros
38-
[], // Types
38+
[
39+
LocaleT
40+
], // Types
3941
[], // Enumerations
4042
[
4143
FunctionSpec<
@@ -108,6 +110,76 @@ def StdC : StandardSpec<"stdc"> {
108110
RetValSpec<IntType>,
109111
[ArgSpec<IntType>]
110112
>,
113+
FunctionSpec<
114+
"isalnum_l",
115+
RetValSpec<IntType>,
116+
[ArgSpec<IntType>, ArgSpec<LocaleT>]
117+
>,
118+
FunctionSpec<
119+
"isalpha_l",
120+
RetValSpec<IntType>,
121+
[ArgSpec<IntType>, ArgSpec<LocaleT>]
122+
>,
123+
FunctionSpec<
124+
"isblank_l",
125+
RetValSpec<IntType>,
126+
[ArgSpec<IntType>, ArgSpec<LocaleT>]
127+
>,
128+
FunctionSpec<
129+
"iscntrl_l",
130+
RetValSpec<IntType>,
131+
[ArgSpec<IntType>, ArgSpec<LocaleT>]
132+
>,
133+
FunctionSpec<
134+
"isdigit_l",
135+
RetValSpec<IntType>,
136+
[ArgSpec<IntType>, ArgSpec<LocaleT>]
137+
>,
138+
FunctionSpec<
139+
"isgraph_l",
140+
RetValSpec<IntType>,
141+
[ArgSpec<IntType>, ArgSpec<LocaleT>]
142+
>,
143+
FunctionSpec<
144+
"islower_l",
145+
RetValSpec<IntType>,
146+
[ArgSpec<IntType>, ArgSpec<LocaleT>]
147+
>,
148+
FunctionSpec<
149+
"isprint_l",
150+
RetValSpec<IntType>,
151+
[ArgSpec<IntType>, ArgSpec<LocaleT>]
152+
>,
153+
FunctionSpec<
154+
"ispunct_l",
155+
RetValSpec<IntType>,
156+
[ArgSpec<IntType>, ArgSpec<LocaleT>]
157+
>,
158+
FunctionSpec<
159+
"isspace_l",
160+
RetValSpec<IntType>,
161+
[ArgSpec<IntType>, ArgSpec<LocaleT>]
162+
>,
163+
FunctionSpec<
164+
"isupper_l",
165+
RetValSpec<IntType>,
166+
[ArgSpec<IntType>, ArgSpec<LocaleT>]
167+
>,
168+
FunctionSpec<
169+
"isxdigit_l",
170+
RetValSpec<IntType>,
171+
[ArgSpec<IntType>, ArgSpec<LocaleT>]
172+
>,
173+
FunctionSpec<
174+
"tolower_l",
175+
RetValSpec<IntType>,
176+
[ArgSpec<IntType>, ArgSpec<LocaleT>]
177+
>,
178+
FunctionSpec<
179+
"toupper_l",
180+
RetValSpec<IntType>,
181+
[ArgSpec<IntType>, ArgSpec<LocaleT>]
182+
>,
111183
]
112184
>;
113185

0 commit comments

Comments
 (0)