Skip to content

Commit 72ce629

Browse files
authored
[libc] Add C23 limits.h header. (#78887)
1 parent fe9f390 commit 72ce629

Some content is hidden

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

43 files changed

+318
-39
lines changed

libc/cmake/modules/LLVMLibCLibraryRules.cmake

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,17 @@ function(create_header_library fq_target_name)
173173
target_sources(${fq_target_name} INTERFACE ${ADD_HEADER_HDRS})
174174
if(ADD_HEADER_DEPENDS)
175175
add_dependencies(${fq_target_name} ${ADD_HEADER_DEPENDS})
176-
target_link_libraries(${fq_target_name} INTERFACE ${ADD_HEADER_DEPENDS})
176+
177+
# `*.__copied_hdr__` is created only to copy the header files to the target
178+
# location, not to be linked against.
179+
set(link_lib "")
180+
foreach(dep ${ADD_HEADER_DEPENDS})
181+
if (NOT dep MATCHES "__copied_hdr__")
182+
list(APPEND link_lib ${dep})
183+
endif()
184+
endforeach()
185+
186+
target_link_libraries(${fq_target_name} INTERFACE ${link_lib})
177187
endif()
178188
if(ADD_HEADER_COMPILE_OPTIONS)
179189
target_compile_options(${fq_target_name} INTERFACE ${ADD_HEADER_COMPILE_OPTIONS})

libc/config/darwin/arm/headers.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set(TARGET_PUBLIC_HEADERS
44
libc.include.fenv
55
libc.include.float
66
libc.include.inttypes
7+
libc.include.limits
78
libc.include.math
89
libc.include.stdlib
910
libc.include.string

libc/config/darwin/x86_64/headers.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set(TARGET_PUBLIC_HEADERS
55
#libc.include.fenv
66
libc.include.float
77
libc.include.inttypes
8+
libc.include.limits
89
libc.include.math
910
libc.include.stdlib
1011
libc.include.string

libc/config/gpu/headers.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set(TARGET_PUBLIC_HEADERS
44
libc.include.string
55
libc.include.float
66
libc.include.inttypes
7+
libc.include.limits
78
libc.include.math
89
libc.include.fenv
910
libc.include.time

libc/config/linux/aarch64/headers.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ set(TARGET_PUBLIC_HEADERS
66
libc.include.fenv
77
libc.include.float
88
libc.include.inttypes
9+
libc.include.limits
910
libc.include.math
1011
libc.include.pthread
1112
libc.include.signal

libc/config/linux/riscv/headers.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ set(TARGET_PUBLIC_HEADERS
88
libc.include.fenv
99
libc.include.float
1010
libc.include.inttypes
11+
libc.include.limits
1112
libc.include.math
1213
libc.include.pthread
1314
libc.include.sched

libc/config/linux/x86_64/headers.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ set(TARGET_PUBLIC_HEADERS
88
libc.include.fenv
99
libc.include.float
1010
libc.include.inttypes
11+
libc.include.limits
1112
libc.include.math
1213
libc.include.pthread
1314
libc.include.sched

libc/include/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ add_gen_header(
8383
.llvm-libc-macros.float_macros
8484
)
8585

86+
add_gen_header(
87+
limits
88+
DEF_FILE limits.h.def
89+
GEN_HDR limits.h
90+
DEPENDS
91+
.llvm-libc-macros.limits_macros
92+
)
93+
8694
add_gen_header(
8795
math
8896
DEF_FILE math.h.def

libc/include/limits.h.def

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//===-- C standard library header limits.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_LIMITS_H
10+
#define LLVM_LIBC_LIMITS_H
11+
12+
#include <llvm-libc-macros/limits-macros.h>
13+
14+
#endif // LLVM_LIBC_LIMITS_H

libc/include/llvm-libc-macros/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ add_macro_header(
7373
float-macros.h
7474
)
7575

76+
add_macro_header(
77+
limits_macros
78+
HDR
79+
limits-macros.h
80+
)
81+
7682
add_macro_header(
7783
math_macros
7884
HDR

0 commit comments

Comments
 (0)