Skip to content

Commit 7e88e26

Browse files
committed
[libc] Add GPU support for the 'inttypes.h' functions
Another low hanging fruit we can put on the GPU, this ports the tests over to the hermetic framework so we can run them on the GPU. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D154540
1 parent e90ab91 commit 7e88e26

File tree

5 files changed

+32
-9
lines changed

5 files changed

+32
-9
lines changed

libc/config/gpu/api.td

+4
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,7 @@ def StdIOAPI : PublicAPI<"stdio.h"> {
3030
];
3131
let Types = ["size_t", "FILE"];
3232
}
33+
34+
def IntTypesAPI : PublicAPI<"inttypes.h"> {
35+
let Types = ["imaxdiv_t"];
36+
}

libc/config/gpu/entrypoints.txt

+6
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ set(TARGET_LIBC_ENTRYPOINTS
9494
libc.src.stdio.stdout
9595
libc.src.stdio.stderr
9696

97+
# inttypes.h entrypoints
98+
libc.src.inttypes.imaxabs
99+
libc.src.inttypes.imaxdiv
100+
libc.src.inttypes.strtoimax
101+
libc.src.inttypes.strtoumax
102+
97103
# gpu/rpc.h entrypoints
98104
libc.src.gpu.rpc_reset
99105
)

libc/config/gpu/headers.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
set(TARGET_PUBLIC_HEADERS
22
libc.include.ctype
33
libc.include.string
4+
libc.include.inttypes
45
libc.include.math
56
libc.include.fenv
67
libc.include.errno

libc/docs/gpu/support.rst

+12
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,18 @@ strtoul |check|
104104
strtoull |check|
105105
============= ========= ============
106106

107+
inttypes.h
108+
--------
109+
110+
============= ========= ============
111+
Function Name Available RPC Required
112+
============= ========= ============
113+
imaxabs |check|
114+
imaxdiv |check|
115+
strtoimax |check|
116+
strtoumax |check|
117+
============= ========= ============
118+
107119
stdio.h
108120
--------
109121

libc/test/src/inttypes/CMakeLists.txt

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
add_custom_target(libc_inttypes_unittests)
1+
add_custom_target(libc_inttypes_tests)
22

3-
add_libc_unittest(
3+
add_libc_test(
44
strtoimax_test
55
SUITE
6-
libc_inttypes_unittests
6+
libc_inttypes_tests
77
SRCS
88
strtoimax_test.cpp
99
DEPENDS
1010
libc.src.inttypes.strtoimax
1111
libc.test.src.stdlib.strtol_test_support
1212
)
1313

14-
add_libc_unittest(
14+
add_libc_test(
1515
strtoumax_test
1616
SUITE
17-
libc_inttypes_unittests
17+
libc_inttypes_tests
1818
SRCS
1919
strtoumax_test.cpp
2020
DEPENDS
2121
libc.src.inttypes.strtoumax
2222
libc.test.src.stdlib.strtol_test_support
2323
)
2424

25-
add_libc_unittest(
25+
add_libc_test(
2626
imaxdiv_test
2727
SUITE
28-
libc_inttypes_unittests
28+
libc_inttypes_tests
2929
SRCS
3030
imaxdiv_test.cpp
3131
HDRS
@@ -35,10 +35,10 @@ add_libc_unittest(
3535
libc.src.inttypes.imaxdiv
3636
)
3737

38-
add_libc_unittest(
38+
add_libc_test(
3939
imaxabs_test
4040
SUITE
41-
libc_inttypes_unittests
41+
libc_inttypes_tests
4242
SRCS
4343
imaxabs_test.cpp
4444
HDRS

0 commit comments

Comments
 (0)