Skip to content

Commit

Permalink
[libc] Provide an implementation of the 'stdint.h' header (#83353)
Browse files Browse the repository at this point in the history
Summary:
I've noticed one problem is that the user includes `stdint.h` the
compiler will do `#include_next <stdint.h>` potentially into a
conflicting implementation on systems with multiple headers installed.
The `clang` header is standards compliant and works with `clang` and
`gcc` which are both of our targets, so I simply copied it here. This
has the effect of including `stdint.h` on clang / LLVM libc behaving the
same as `-ffreestanding`.
  • Loading branch information
jhuber6 authored Mar 4, 2024
1 parent 5675447 commit c996023
Show file tree
Hide file tree
Showing 15 changed files with 923 additions and 0 deletions.
1 change: 1 addition & 0 deletions libc/config/baremetal/arm/headers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set(TARGET_PUBLIC_HEADERS
libc.include.fenv
libc.include.errno
libc.include.float
libc.include.stdint
libc.include.inttypes
libc.include.math
libc.include.stdio
Expand Down
1 change: 1 addition & 0 deletions libc/config/baremetal/riscv/headers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set(TARGET_PUBLIC_HEADERS
libc.include.fenv
libc.include.errno
libc.include.float
libc.include.stdint
libc.include.inttypes
libc.include.math
libc.include.stdio
Expand Down
1 change: 1 addition & 0 deletions libc/config/darwin/arm/headers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set(TARGET_PUBLIC_HEADERS
libc.include.errno
libc.include.fenv
libc.include.float
libc.include.stdint
libc.include.inttypes
libc.include.limits
libc.include.math
Expand Down
1 change: 1 addition & 0 deletions libc/config/darwin/x86_64/headers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set(TARGET_PUBLIC_HEADERS
# Fenv is currently disabled.
#libc.include.fenv
libc.include.float
libc.include.stdint
libc.include.inttypes
libc.include.limits
libc.include.math
Expand Down
1 change: 1 addition & 0 deletions libc/config/gpu/headers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set(TARGET_PUBLIC_HEADERS
libc.include.ctype
libc.include.string
libc.include.float
libc.include.stdint
libc.include.inttypes
libc.include.limits
libc.include.math
Expand Down
1 change: 1 addition & 0 deletions libc/config/linux/aarch64/headers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set(TARGET_PUBLIC_HEADERS
libc.include.features
libc.include.fenv
libc.include.float
libc.include.stdint
libc.include.inttypes
libc.include.limits
libc.include.math
Expand Down
1 change: 1 addition & 0 deletions libc/config/linux/arm/headers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set(TARGET_PUBLIC_HEADERS
libc.include.fenv
libc.include.errno
libc.include.float
libc.include.stdint
libc.include.inttypes
libc.include.math
libc.include.stdckdint
Expand Down
1 change: 1 addition & 0 deletions libc/config/linux/riscv/headers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set(TARGET_PUBLIC_HEADERS
libc.include.features
libc.include.fenv
libc.include.float
libc.include.stdint
libc.include.inttypes
libc.include.limits
libc.include.math
Expand Down
1 change: 1 addition & 0 deletions libc/config/linux/x86_64/headers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set(TARGET_PUBLIC_HEADERS
libc.include.features
libc.include.fenv
libc.include.float
libc.include.stdint
libc.include.inttypes
libc.include.limits
libc.include.math
Expand Down
8 changes: 8 additions & 0 deletions libc/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ add_gen_header(
.llvm-libc-macros.float_macros
)

add_gen_header(
stdint
DEF_FILE stdint.h.def
GEN_HDR stdint.h
DEPENDS
.llvm-libc-macros.stdint_macros
)

add_gen_header(
limits
DEF_FILE limits.h.def
Expand Down
6 changes: 6 additions & 0 deletions libc/include/llvm-libc-macros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ add_macro_header(
file-seek-macros.h
)

add_macro_header(
stdint_macros
HDR
stdint-macros.h
)

add_macro_header(
float_macros
HDR
Expand Down
Loading

0 comments on commit c996023

Please sign in to comment.