629 Commits

Author SHA1 Message Date
Mohamed Emad
1bb03026b6
[libc][math][c23] implement double-precision asinpi (#188158)
Implement the double precision version of the asinpi c23 math function
2026-03-29 10:18:07 -04:00
Shikhar Soni
f0ce26d06d
[libc][math][c23] Add log2p1f16 C23 math function (#186754)
Signed-off-by: Shikhar Soni <shikharish05@gmail.com>
2026-03-28 11:34:42 -04:00
Alexey Samsonov
ae63230c23
[libc] Remove more header template files (#189066)
Get rid of several .h.def files which were used to ensure that the
macro definitions from llvm-libc-macro would be included in the public
header. Replace this logic with YAML instead - add entries to the
"macros" list that point to the correct "macro_header" to ensure it
would be included.

For C standard library headers, list several standard-define macros
to document their availability. For POSIX/Linux headers, only reference
a handful of macro, since more planning is needed to decide how to
represent platform-specific macro in YAML.
2026-03-27 16:06:39 -07:00
Jeff Bailey
0aba82eb70
[libc] Add missing POSIX macros to cpio.h (#188840)
Define the POSIX cpio.h header and its standard macros in the libc build
system. Configure the macros directly in the YAML specification to allow
automated header generation without a custom definition template.
2026-03-27 22:08:13 +00:00
Alexey Samsonov
ead9ac8331
[libc] Remove header templates from several C standard headers. (#188878)
Switches the following headers to hdrgen-produced ones by referencing
some macro from C standard and the file containing the declarations in
corresponding YAML files:

* limits.h (referenced _WIDTH / _MAX / _MIN families).
* locale.h (referenced LC_ family).
* time.h (referenced CLOCKS_PER_SEC).
* wchar.h (referenced WEOF).
2026-03-27 17:55:37 +00:00
Michael Jones
166f996c44
[libc][bazel] Add generation for public headers (#184889)
Previously there was a single rule for stdbit, this PR adds generated
header targets for the rest of the linux headers. It also adds a
cc_library
for all of the public headers which also includes the types and macros
headers.
2026-03-27 09:44:32 -07:00
Anonmiraj
e06b5e53a2
[libc][math] Implement C23 half precision erfc function (#180930)
Add support for the half-precision complementary error function
`erfcf16``, using a Sollya generated polynomial implementation with
proper handling of special cases.

Extend the MPFR utilities with erfc support to allow tests.

closes: #180927
2026-03-27 10:42:03 -04:00
Zorojuro
a9c6f38e8d
[libc] Fixes all guard comments of libc (#188701)
This PR intends to fix ALL the wrong guard comments for libc


Script used:
[guard_checker](https://github.com/Sukumarsawant/guard_checker/blob/main/check_headers.py)
2026-03-26 15:23:49 -04:00
Victor Campos
2baa2cdce9
[libc] Follow up on Annex K's rsize_t (#187707)
- Fix header guard name.
- Define `__STDC_WANT_LIB_EXT1__` in `hdr/types/rsize_t.h` so that the
type is available for internal use.
- In accordance to the standard, make `stdio.h`, `stdlib.h`, `string.h`,
`time.h` and `wchar.h` define the type. It should already be available
in `stddef.h` as it's provided by Clang, not LLVM libc.
2026-03-25 13:16:34 +00:00
Victor Campos
27ba9e2a44
[libc] Define Annex K's errno_t in specified headers (#187700)
- Change `errno.h.def` to include a placeholder where hdrgen emits the
public API, which contains the `errno_t` definition.
- Make headers `stdio.h`, `stdlib.h`, `string.h` and `time.h` also
define `errno_t` as specified in the standard.
2026-03-25 12:30:19 +00:00
Fabio D'Urso
5999c53e32
[libc] Declare free_sized and free_aligned_sized in stdlib.h / malloc.h (#188364) 2026-03-25 11:48:07 +01:00
Jeff Bailey
4c4c1db7c6
[libc] Add utimensat syscall wrapper and entrypoint (#188347)
Implemented the utimensat syscall for Linux and added the entrypoint to
sys/stat.h.

* Added utimensat syscall wrapper to OSUtil
* Updated utimes to use the utimensat wrapper
* Added utimensat unit tests to sys/stat
* Configured entrypoints for x86_64, riscv, and aarch64
2026-03-25 07:53:29 +00:00
Alexey Samsonov
a60b3a83cf
[libc] Fix function prototypes for <threads.h> C11 header. (#187808)
Fix return types and/or function arguments of several functions:
* mtx_destroy
* tss_delete
* thrd_exit
2026-03-20 16:17:29 -07:00
Muhammad Bassiouni
a2615482d1
[libc][annex_k] Add constraint_handler_t. (#163239)
RFC https://discourse.llvm.org/t/rfc-bounds-checking-interfaces-for-llvm-libc/87685

Add `constraint_handler_t` type required by Annex K interface in LLVM libc.
2026-03-21 00:19:21 +02:00
Daniel Thornburgh
7efcd6198c
[libc] Modular printf option (float only) (#147426)
This adds LIBC_CONF_PRINTF_MODULAR, which causes floating point support
(later, others) to be weakly linked into the implementation.
__printf_modular becomes the main entry point of the implementaiton, an
printf itself wraps __printf_modular. printf it also contains a
BFD_RELOC_NONE relocation to bring in the float aspect.

See issue #146159 for context.
2026-03-19 14:22:03 -07:00
neonetizen
adbb122717
[libc] Implement iswprint entrypoint (#185251)
Implemented the iswprint entrypoint and tests for issue #185136
2026-03-19 12:36:56 -07:00
Pengxiang Huang
bed9fa2de5
[libc][sys/sem] Add sys v sem headers and syscall wrapper implementation (#185914)
Fix #182161
Based on the last PR #182700 implementing sys/ipc.
2026-03-19 10:12:06 -04:00
Muhammad Bassiouni
80034dd582
[libc][annex_k] Add rsize_t (#163238)
RFC
https://discourse.llvm.org/t/rfc-bounds-checking-interfaces-for-llvm-libc/87685

Add `rsize_t` type required by Annex K interface in LLVM libc.
2026-03-19 01:59:30 +02:00
Muhammad Bassiouni
8e06210559
[libc][annex_k] Add errno_t (#163094)
RFC
https://discourse.llvm.org/t/rfc-bounds-checking-interfaces-for-llvm-libc/87685

Add `errno_t` type required by Annex K interface in LLVM libc.
2026-03-18 23:58:27 +02:00
kubikusik
6b2e347ae1
[libc]: implement 'iswpunct' entrypoint (#186968)
Added entrypoints:
- baremetal/arm
- baremetal/aarch64
- baremetal/riscv
- darwin/aarch64
- linux/aarch64
- linux/arm
- linux/riscv
- linux/x86_64
- windows

Also added the unit test for iswpunct.

Part of the issue: #185136
2026-03-17 12:53:03 -07:00
csxplorer
c5e305c66b
[libc] Implement entrypoint and test of iswupper function (#185215)
Implement entrypoint and test of iswupper function (#185136)
2026-03-13 07:23:06 -07:00
Anonmiraj
785581213c
[libc][math] Implement C23 half precision erf function (#179251)
The implementation reuses the approach in `erff`


Closes #133112
2026-03-13 10:16:59 -04:00
Shikhar Soni
a7d1a87b30
[libc][math][c23] Add log10p1f16 C23 math function (#184739)
Closes #133202

---------

Signed-off-by: Shikhar Soni <shikharish05@gmail.com>
2026-03-13 09:59:26 -04:00
Xinlong Chen
fe2537a4ee
[libc] Add missing iswdigit to wctype.yaml and Windows entrypoints (#186023)
`iswdigit` was implemented
(https://github.com/llvm/llvm-project/pull/181635) but not declared in
the generated wctype.h (wctype.yaml) and was missing from the Windows
config entrypoints.

This pr declares iswdigit in wctype.h and enables it for the Windows
config.

also is part of https://github.com/llvm/llvm-project/issues/185136.
2026-03-12 14:55:37 -07:00
Mir Immad
1f2a3bfd40
[libc]: implement 'iswalnum' entrypoint (#185581)
- Added entry points for `iswalnum`  for the following platforms: 
  - baremetal/arm
  - baremetal/riscv
  - dawin/aarch64
  - linux/x86_64
  - linux/arm
  - linux/aarch64
  - linux/riscv
  - windows
- Added a unit test for `iswalnum`
 
part of #185136
2026-03-12 07:02:28 -07:00
Zorojuro
49d9ba9572
[libc] Add entrypoint for iswxdigit (#185574)
This PR intends to add entrypoints and some smoke tests for `iswxdigit`
function

Changes made are :-
- Added entrypoint for `iswxdigit` in wctype.yaml
- Added CMake entrypoint object for `iswxdigit`
- Added Header and implementation in `iswxdigit.h` and `iswxdigit.cpp`
- Added test for `iswxdigit` in iswxdigit_test.cpp
- Added `iswxdigit` in entrypoints.txt for available platforms 

Tested using = `ninja libc.test.src.wctype.iswxdigit_test.__unit__`
passes all tests

part of #185136
2026-03-11 14:08:36 -07:00
alowqie
4fcdf5254d
[libc] add iswblank entrypoint (#185272)
Implement iswblank entrypoint and test for #185136
2026-03-11 11:18:29 -07:00
Xinlong Chen
4f76d16203
[libc] Implement iswgraph entrypoint (#185339)
part of https://github.com/llvm/llvm-project/issues/185136;

This PR adds public entrypoints for the wide character classification
function iswgraph in LLVM libc, using the same pattern as the existing
iswalpha entrypoint.

using bellow cmd to test:

```shell
ninja libc.test.src.wctype.iswgraph_test.__unit__
```
2026-03-11 08:04:37 -07:00
bkuhls
ea9f8b7746
[libc] Fix detection of cfloat128 (#185486)
Building compiler-rt with aarch64-buildroot-linux-gnu-gcc 15.2 causes a
build error:
```
compiler-rt-22.1.0/cmake/Modules/../../libc/src/__support/CPP/type_traits/is_complex.h:44:31:
 error: 'cfloat128' was not declared in this scope; did you mean 'float128'? [-Wtemplate-body]
```
According to
https://gcc.gnu.org/onlinedocs/gcc-15.2.0/gcc/Floating-Types.html
__float128 is not available on aarch64.

Analyzing the gcc defines for aarch64 seems to prove it:
```
$ aarch64-buildroot-linux-gnu-gcc -v
Target: aarch64-buildroot-linux-gnu
gcc version 15.2.0 (Buildroot 2026.02-114-gdadec9da56)

$ echo | aarch64-buildroot-linux-gnu-gcc -dM -E - | grep __GCC_IEC_559_COMPLEX
  #define __GCC_IEC_559_COMPLEX 2

$ echo | aarch64-buildroot-linux-gnu-gcc -dM -E - | grep __STDC_IEC_60559_COMPLEX__
  #define __STDC_IEC_60559_COMPLEX__ 201404L

$ echo | aarch64-buildroot-linux-gnu-gcc -dM -E - | grep -i float128
$
```
In contrast gcc for x86_64:
```
$ x86_64-buildroot-linux-gnu-gcc -v
Target: x86_64-buildroot-linux-gnu
gcc version 15.2.0 (Buildroot 2026.02-112-gd12ac02486)

$ echo | x86_64-buildroot-linux-gnu-gcc -dM -E - | grep __GCC_IEC_559_COMPLEX
  #define __GCC_IEC_559_COMPLEX 2

$ echo | x86_64-buildroot-linux-gnu-gcc -dM -E - | grep __STDC_IEC_60559_COMPLEX__
  #define __STDC_IEC_60559_COMPLEX__ 201404L

$ echo | x86_64-buildroot-linux-gnu-gcc -dM -E - | grep -i float128
  #define __SIZEOF_FLOAT128__ 16
```
This patch changes the or-condition to an and-condition for
    \_\_STDC_IEC_60559_COMPLEX\_\_ and \_\_SIZEOF_FLOAT128\_\_.

Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
2026-03-11 10:12:23 -04:00
Jiří Filek
56e19de931
[libc] Implement iswspace entrypoint (#185269)
Implement entrypoint for iswspace function and related test
Part of #185136
2026-03-11 06:56:54 -07:00
Alexey Samsonov
bbb1c831d1
[libc] Add missing const qualifiers to a few functions in <time.h> (#185311)
`asctime_r`, `gmtime`, and `gmtime_r` were missing const-qualifiers for
a first function argument. Add them to fix generated `<time.h>` header.

Implementation headers / source files are declaring arguments correctly.
2026-03-10 10:08:55 -07:00
valium007
375357eeaf
[libc] implement iswcntrl entrypoint (#185273)
Implement iswcntrl entrypoint and test for #185136
2026-03-10 08:29:44 -07:00
albertbolt1
c79034abb6
[libc] 185136 - added iswlower entry point (#185221)
Changes include:
- Added iswlower entrypoint in wctype.yaml to expose the function
- Created iswlower.h header and iswlower.cpp implementation
- Added CMake entrypoint object for iswlower
- Created unit test in iswlower_test.cpp
- Added test entry to wctype CMakeLists.txt

this PR helps in exposing iswlower which internally calls islower on
wide character

built using :  ninja -C build libc 
tested using : ninja libc_wctype_unittests and all the 3 tests passed 

resolves issue #185136
2026-03-10 07:20:23 -07:00
Alexey Samsonov
6a6564cd14
[libc] Add more macro/type declarations to Elf headers. (#185348)
* Add several `AT_` macro values from `<sys/auxv.h>`. In particular,
this allows to make internal Linux auxv header parsing more hermetic by
removing one of Linux header includes.
* Add constants between `DT_ADDRNGLO` and `DT_ADDRNGHI`, in particular
`DT_GNU_HASH`, which is de-facto standard on many platforms.
* Add `Elf32_auxv_t` and `Elf64_auxv_t` types which define the auxv
entries and can be used by VDSO parsing code. Note that this PR doesn't
yet update libc's own Linux auxv header support (in
`src/__support/OSUtil/linux/auxv.h`).

This fixes some of the missing definitions when building code working
with Elf files, such as Abseil's debugging support in

https://github.com/abseil/abseil-cpp/tree/master/absl/debugging/internal.
2026-03-09 15:12:54 -07:00
Alexey Samsonov
3fb55b6872
[libc] Add <sys/un.h> header. (#182622)
`sockaddr_un` structure is supposed to be provided by the `<sys/un.h>`
header. Add this header to llvm-libc, and move the declaration of
`sockaddr_un` there from `<sys/socket.h>`. See
https://man7.org/linux/man-pages/man0/sys_un.h.0p.html

Add proxy headers for the `<sys/socket.h>` macro (like `AF_UNIX`) and
for the `struct sockaddr_un` so that the tests can be more hermetic and
avoid system header inclusion.
2026-03-08 06:22:36 +00:00
Pengxiang Huang
5b976c9301
[libc][sys] add header and functions for sys ipc (#182700)
Split from a larger change. This PR contains the base impl for sys ipc,
sys sem will come after this. @SchrodingerZhu

this PR implements for:
https://github.com/llvm/llvm-project/issues/182161

see the last PR for more detail:
https://github.com/llvm/llvm-project/pull/182683
2026-03-03 09:48:18 -05:00
Roland McGrath
5156147824
[libc] Declare reallocarray in stdlib.h / malloc.h (#184223)
Scudo now provides reallocarray, so declare it.
2026-03-02 13:47:43 -08:00
Muhammad Bassiouni
e3735ce4b3
[libc][math] Disable float16 on Clang 11 and older (#183574)
This also reverts
c5d6feb315
2026-02-26 20:47:29 +02:00
Alexey Samsonov
8cbbd5b561
[libc] Add backwards-compatibility macro to struct stat. (#182601)
Older code may use `st_atime` which recorded timestamps with one-second
precision, instead of `struct timespec st_atim` that is available in
later POSIX versions.

Add `#define st_atime` (& friends) to type declaration as suggested in
https://man7.org/linux/man-pages/man3/stat.3type.html
2026-02-24 22:28:30 +00:00
Jeff Bailey
d1e29a4bf1
[libc] Enable ifunc support in static startup (#182841)
Resolves ifunc targets before `main()` runs in static libc

This enables static binaries to use ifunc-based dispatch during early
process startup, so optimized implementations can be selected based on
CPU features. Without this relocation step in startup, those targets are
not ready when program code begins executing.

This change:
- adds IRELATIVE relocation handling for x86_64, AArch64, ARMv7 and RISC-V,
- reads `AT_HWCAP` / `AT_HWCAP2` from auxv and passes them to resolvers
where required (notably AArch64),
- runs IRELATIVE processing after base-address discovery and before TLS
setup,
- adds integration tests for both the ifunc path and the no-ifunc path,
- Changed the load bias type for ptrdiff_t to intptr_t to align with
IRELATIVE handling, which uses intptr_t for load bias calculations.
2026-02-24 21:03:05 +00:00
fineg74
ab3d742f6f
[libc] Add basic support for building SPIR-V libraries (#181049)
This is to add support to build libc for building with spirv backend,
for use with OpenMP kernels
2026-02-16 20:27:39 -06:00
Roland McGrath
73dc25c1b6
[libc] Add pthread_getattr_np declaration (#178549)
Add header declaration and implementation header for the GNU
extension function pthread_getattr_np.  An actual implementation
can come later.
2026-01-29 10:33:19 -08:00
Roland McGrath
dbce14f0d6
[libc] Clean up pthread.yaml (#178327)
Remove pthread.h.def and use pure generation.  Fix YAML records
for standards to correct syntax and remove redundancies.

Don't declare NULL, which is not specified for <pthread.h>.
Do declare PTHREAD_NULL.
2026-01-28 12:30:54 -08:00
Jakob Koschel
dc55e20483
[libc] Add Elf32_Xword type (#177915)
In a recent PR (https://github.com/llvm/llvm-project/pull/174772), we
introduced GnuPropertySection using ElfW(Xword). Since we are currently
missing Elf32_Xword, this is failing on 32bit architectures.

This commit adds the missing Elf32_Xword type that should always hold
64bit even on 32bit architectures.
2026-01-26 14:48:35 -08:00
Jakob Koschel
6574918875
[libc][linux] add support to parse PT_GNU_PROPERTY (#174772)
In order to add Control-flow Enforcement Technology (CET) Shadow Stack
(SHSTK) support, we need to parse the `PT_GNU_PROPERTY` program header
and the corresponding section to evaluate if the binary being started
was compiled with the necessary support.

PS: This is my first PR to llvm-libc, I might have made obvious styling
mistakes so I'd appreciate any feedback or suggestions to improve it.

I have a prototype branch using this change to enable SHSTK support:
https://github.com/jakos-sec/llvm-project/tree/add-shstk-support
2026-01-20 14:33:01 -08:00
Petr Hosek
9007f1dd45
[libc] Fix a typo in DT_BIND_NOW macro name (#175619)
This was accidentally introduced in #172766.
2026-01-12 19:18:34 +00:00
Petr Hosek
5db5782da1
[libc] Provide a minimal implementation of elf.h (#172766)
Some of the baremetal users of libc use elf.h to generate coredumps and
we would like to support this use case without needing Linux elf.h.
2026-01-12 10:56:49 -08:00
Roland McGrath
10d6a02016
[libc] Add stub pthread_attr_getschedparam / pthread_attr_setschedparam (#173440)
Add the boilerplate for declaring these POSIX functions and
providing implementations.  So far the only implementations are
just stubs that fail with ENOTSUP, and they are neither tested
nor included in any CMake entrypoints lists.  More work is still
required to add the actual fields to the pthread_attr_t and
implement the support in the Linux pthread_create et al, but that
is not done here.  It's not an especially large amount of work,
but more than just trivial.

The scaffolding here paves the way for that later work, but is
also immediately useful for filling out the subset of POSIX
pthread_attr_* functions that Fuchsia's libc already supports.
2025-12-23 19:55:18 -08:00
Connector Switch
12e5bd1e30
[libc] Add IN6_IS_ADDR_V4COMPAT (#172646)
This patch adds the `IN6_IS_ADDR_V4COMPAT` macro, which checks whether
an address is IPv4-compatible.
2025-12-18 23:13:54 +08:00
Connector Switch
e071e43589
[libc] Add IN6_IS_ADDR_V4MAPPED (#172645)
This patch adds the `IN6_IS_ADDR_V4MAPPED` macro, which checks whether
an address is IPv4 mapped address.
2025-12-18 23:12:49 +08:00