85 Commits

Author SHA1 Message Date
Aiden Grossman
605f652cba
[libc] Add struct_sched_param proxy header (#151722)
This enables cleaning up the remaining sched.h includes littered around
the code base.
2025-08-01 11:34:06 -07:00
Uzair Nawaz
a1aba84c2b
[libc] Reland #148948 "Implement barriers for pthreads" (#151021)
Fixed build dependencies for pthread_barrier_t (add __barrier_type to
cmake dependencies)
2025-07-29 16:39:40 +00:00
Uzair Nawaz
a4a0832899
Revert "[libc] Implement barriers for pthreads" (#151014)
Reverts llvm/llvm-project#148948
2025-07-28 11:37:23 -07:00
Uzair Nawaz
7ca23754c4
[libc] Implement barriers for pthreads (#148948)
Implemented barrier synchronization for pthreads
- Uses condition variables internally for platform independence
(platform-specific work is handled by the condition variable
implementation)
- Does NOT currently handle barrierattr pshared, this is a goal for a
future patch
2025-07-28 11:22:38 -07:00
William Huynh
becde6d62e
[libc] Fix issue with sigjmp_buf.h not being found (#150439)
When trying to use <setjmp.h>, it will try to include
llvm-libc-types/sigjmp_buf.h due to the way that headergen works. This
commit creates a dummy file, as the real implementation is found in
llvm-libc-types/jmp_buf.h.
2025-07-24 19:50:50 +01:00
lntue
66603dd1f1
[libc][NFC] Add stdint.h proxy header to fix dependency issue with <stdint.h> includes. (#150303)
https://github.com/llvm/llvm-project/issues/149993
2025-07-23 20:19:52 -04:00
lntue
023566ab38
[libc] Add missing full build dependency for mbstate. (#150030) 2025-07-22 10:39:03 -04:00
sribee8
4c97a91dc0
[libc] Added closing quote (#145101)
Error message was missing a closing quote, added it.

Co-authored-by: Sriya Pratipati <sriyap@google.com>
2025-06-20 21:00:56 +00:00
sribee8
d078ce7c98
[libc] mbrtowc implementation (#144760)
implemented the internal and public mbrtowc as well as tests for the
public function.

---------

Co-authored-by: Sriya Pratipati <sriyap@google.com>
2025-06-20 20:00:59 +00:00
Uzair Nawaz
38daa6d4ef
[libc] build fix: always use our char8_t headers even in overlay mode (#144433)
Build fix caused by certain platforms not providing char8_t when
expected
Temporary fix to just always use our own definition, even in overlay
mode.
2025-06-16 21:28:51 +00:00
Uzair Nawaz
6311f039b2
[libc] Build fixes for widechar characterconverter (#143805)
Build fixes for wchar CharacterConverter class
2025-06-12 17:34:45 +00:00
W. Turner Abney
4039fdb7ba
[libc] add ioctl (#141393)
Closes #85275
Closes #90317
Updates #97191

---------

Co-authored-by: Joseph Huber <huberjn@outlook.com>
Co-authored-by: Michael Jones <michaelrj@google.com>
2025-06-12 09:20:32 -07:00
Uzair Nawaz
52583b3ed7
[libc] Character converter skeleton class (#143619)
Made CharacterConverter class skeleton
2025-06-11 13:11:31 -07:00
lntue
b994299e59
[libc] Also remove _FORTIFY_SOURCE before including <stdlib.h> in overlay mode. (#142647) 2025-06-03 14:25:46 -04:00
lntue
79e8e27bfe
[libc] Add proxy header for ACTION type. (#139796)
https://github.com/llvm/llvm-project/issues/139561
2025-05-13 17:50:02 -04:00
lntue
e581f1cc9a
[libc] Add proxy header for ENTRY type. (#139746)
https://github.com/llvm/llvm-project/issues/139561
2025-05-13 14:07:21 -04:00
Schrodinger ZHU Yifan
6695976d16
Reland "[libc] build fix for sigsetjmp (#137047)" (#137214)
Reland `sigsetjmp` patches with build fixes.

We wrap every target replying on the epilogue library into conditional
checks.

---------

Co-authored-by: Petr Hosek <phosek@google.com>
2025-04-29 09:28:42 -04:00
gulfemsavrun
0d00b6bc3b
Revert "[libc] build fix for sigsetjmp (#137047)" (#137077)
This reverts commit f07511a0e0d2ac9bee9ae12a9ad68e279e352634.

This reverts commit 5bb4cf9d9189c41de50adffd960eb2188140eb9c.

It caused a CMake configuration issue.
2025-04-23 15:49:55 -07:00
Schrodinger ZHU Yifan
5bb4cf9d91
[libc] implement sigsetjmp/siglongjmp for x86-64 (#136072) 2025-04-23 14:19:47 -04:00
Tsz Chan
f5c5f9f926
[libc] Implement getitimer and setitimer, add proxy headers for itimerval (#134773)
#133983
2025-04-14 13:39:42 -07:00
Krishna Pandey
bda87e0a09
[libc][sched] Implement CPU_ZERO, CPU_ISSET, CPU_SET macros (#131524)
This PR implements the following macros for `sched.h`:
- `CPU_ZERO`
- `CPU_ISSET`
- `CPU_SET`

Fixes #124642

---------

Signed-off-by: krishna2803 <kpandey81930@gmail.com>
2025-03-19 13:44:41 -04:00
Roland McGrath
123c0040d4
[libc] Define (stub) dl_iterate_phdr (#131436)
This fleshes out the <link.h> a little more, including the
`struct dl_phdr_info` type and declaring the dl_iterate_phdr
function.  There is only a no-op implementation without tests, as
for the existing dlfcn functions.
2025-03-18 11:38:33 -07:00
Connector Switch
bde2636fb5
[libc][NFC] Add the missing angle bracket in wchar.h (#131161) 2025-03-14 11:14:52 +08:00
Connector Switch
426caf1182
[libc] add locale proxy header (#130621)
Address review comments in #130407.

This patch is already covered by existing locale test cases.
2025-03-11 08:46:29 +08:00
Nick Desaulniers
e566313a1f
[libc][signal] clean up usage of sighandler_t (#125745)
`man 3 signal`'s declaration has a face _only a mother could love_.

sighandler_t and __sighandler_t are not defined in the C standard, or POSIX.

They are helpful typedefs provided by glibc and the Linux kernel UAPI headers
respectively since working with function pointers' syntax can be painful. But
we should not rely on them; in C++ we have `auto*` and `using` statements.

Remove the proxy header, and only include a typedef for sighandler_t when
targeting Linux, for compatibility with glibc.

Fixes: #125598
2025-02-07 10:43:56 -08:00
Nick Desaulniers
8e35b3d29b
[libc][POSIX][poll.h] implement poll (#125118)
Simple syscall.

Fixes: #124647
2025-02-05 13:24:39 -08:00
Schrodinger ZHU Yifan
73dd730fb9
[libc] implement sys/uio/writev (#122233)
implement sys/uio/writev according to POSIX standard. This vectorized IO
API is needed by many logging libraries to achieve atomic logging
multiple strings.
2025-01-10 12:49:00 +08:00
Michael Jones
f9c2377fb6
[libc][NFC] Cleanup time.h (#122027)
While working on strftime I noticed some constants were being defined in
unexpected places. One thing led to another, and I ended up doing a
major cleanup of the time functions.

What's included:
All uses of <time.h> in /src and /test removed (except for LibcTest.cpp)
The various time constants have been moved to time_constants.h, and the
`time_constants` namespace.
struct tm gets its own type indirection header now.
2025-01-08 12:28:50 -08:00
Tristan Ross
7477b61b24
[libc] Add unistd overlay (#119312)
Reverts the revert #119295 of #118882 by expanding #118882 with
additional fixes which made CI unhappy.
2024-12-17 10:40:22 -08:00
Joseph Huber
bd40421ad9
[libc] Stop installing sys/types.h when not requested (#119765)
Summary:
This is installed unconditionally because of the dependency in the
`hdr/` directory. Remove this so it's only used on the systems that need
it.
2024-12-12 15:39:10 -06:00
Nick Desaulniers
431ea2d076
[libc] move bcmp, bzero, bcopy, index, rindex, strcasecmp, strncasecmp to strings.h (#118899)
docgen relies on the convention that we have a file foo.cpp in
libc/src/\<header\>/. Because the above functions weren't in libc/src/strings/
but rather libc/src/string/, docgen could not find that we had implemented
these.

Rather than add special carve outs to docgen, let's fix up our sources for
these 7 functions to stick with the existing conventions the rest of the
codebase follows.

Link: #118860
Fixes: #118875
2024-12-10 08:58:45 -08:00
Michael Jones
2c05e69066
Revert "[libc] Add unistd overlay" (#119295)
Reverts llvm/llvm-project#118882

Several functions are now missing necessary types in fullbuild, e.g.
`off_t`, `ssize_t`. Reverting for now.
2024-12-09 16:09:50 -08:00
Tristan Ross
7db970fe4a
[libc] Add unistd overlay (#118882)
Fixes failures like this which I experienced:
```
FAILED: src/unistd/linux/CMakeFiles/libc.src.unistd.linux.read.dir/read.cpp.o
/nix/store/2r2xi5pbg29bsmqywsm5zgl8l7adky4i-gcc-wrapper-13.3.0/bin/g++ -DLIBC_NAMESPACE=__llvm_libc -D_DEBUG -I/build/libc-src-20.0.0-unstable-2024-12-05/libc -isystem /build/libc-src-20.0.0-unstable-2024-12-05/libc/build/include -g -std=gnu++17 -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -DLIBC_COPT_PUBLIC_PACKAGING -MD -MT src/unistd/linux/CMakeFiles/libc.src.unistd.linux.read.dir/read.cpp.o -MF src/unistd/linux/CMakeFiles/libc.src.unistd.linux.read.dir/read.cpp.o.d -o src/unistd/linux/CMakeFiles/libc.src.unistd.linux.read.dir/read.cpp.o -c /build/libc-src-20.0.0-unstable-2024-12-05/libc/src/unistd/linux/read.cpp
次のファイルから読み込み:  /build/libc-src-20.0.0-unstable-2024-12-05/libc/src/__support/OSUtil/linux/syscall.h:13,
         次から読み込み:  /build/libc-src-20.0.0-unstable-2024-12-05/libc/src/__support/OSUtil/syscall.h:15,
         次から読み込み:  /build/libc-src-20.0.0-unstable-2024-12-05/libc/src/unistd/linux/read.cpp:11:
/build/libc-src-20.0.0-unstable-2024-12-05/libc/src/unistd/linux/read.cpp:20:29: エラー: ‘ssize_t __llvm_libc::read(int, void*, size_t)’ が外部シンボル ‘read’ の別名となっています
   20 | LLVM_LIBC_FUNCTION(ssize_t, read, (int fd, void *buf, size_t count)) {
      |                             ^~~~
/build/libc-src-20.0.0-unstable-2024-12-05/libc/src/__support/common.h:46:34: 備考: in definition of macro ‘LLVM_LIBC_FUNCTION_IMPL’
   46 |   decltype(LIBC_NAMESPACE::name) name [[gnu::alias(#name)]];                   \
      |                                  ^~~~
/build/libc-src-20.0.0-unstable-2024-12-05/libc/src/unistd/linux/read.cpp:20:1: 備考: in expansion of macro ‘LLVM_LIBC_FUNCTION’
   20 | LLVM_LIBC_FUNCTION(ssize_t, read, (int fd, void *buf, size_t count)) {
      | ^~~~~~~~~~~~~~~~~~
```
2024-12-09 15:59:34 -08:00
lntue
44c645fcc9
[libc] Fix overlay mode inclusion for fcntl.h header. (#119159) 2024-12-08 22:14:32 -05:00
Schrodinger ZHU Yifan
e6cf5d2863
Reapply "[libc][windows] start time API implementation (#117775)" (#118886) 2024-12-05 18:21:03 -05:00
Joseph Huber
9fd052a122 Revert "[libc][windows] start time API implementation (#117775)"
This reverts commit 0adff0af20c7d9bae8bd8bdf402506c10369ead1.

Breaks the GPU build
2024-12-05 14:43:06 -06:00
Schrodinger ZHU Yifan
0adff0af20
[libc][windows] start time API implementation (#117775)
Add a `clock_gettime` emulation layer and use it to implement the `time`
entrypoint.

For windows, the monotonic clock is emulated using `QPC`.
The realtime clock is emulated using `GetSystemTimePreciseAsFileTime`.
2024-12-05 14:08:27 -05:00
Job Henandez Lara
c980cc0869
[libc] Remove _Exit proxy func header and use LIBC_NAMESPACE::_Exit in tests (#114904)
This improves/fixes this pr
https://github.com/llvm/llvm-project/pull/114718. In this PR we removed
the _Exit proxy func because it was not needed. Instead we used
`LIBC_NAMESPACE::_Exit`
2024-11-07 09:10:22 -08:00
Job Henandez Lara
915b910d80
[libc] Fix typos in proxy type headers (#114717) 2024-11-03 14:12:27 -08:00
Job Henandez Lara
2afc562d5d
[libc] add stdlib.h header to the _Exit func proxy in full build (#114718) 2024-11-03 13:40:45 -08:00
Job Henandez Lara
9cfe3028ca
[libc] Add proxy headers to handle memory allocation associated with the header `#include <stdlib.h> (#114690)
This finishes the work from
https://github.com/llvm/llvm-project/pull/114453 by adding proxy headers
for `malloc`, `realloc`, `free` and `aligned_alloc`.
2024-11-03 11:28:24 -08:00
Job Henandez Lara
33bdb53d86
[libc] Remove the #include <stdlib.h> header (#114453) 2024-11-01 21:49:57 -07:00
lntue
5cb730594a
[libc] Remove FE_ALL_EXCEPT check in hdr/fenv_macros.h. (#114446)
FE_ALL_EXCEPT macro might not be a valid preprocessor constant
expression in some environment.
Moreover, FE_ALL_EXCEPT might not be defined as int.
2024-10-31 22:24:06 -04:00
Michael Jones
0b2b87bf34
[libc] Fix path to fcntl_overlay in cmake (#114464)
The proxy header definition for mode_t was using an incorrect form for
its dependency on fcntl_overlay. The relative paths for dependencies can
only go down, not up so "../" doesn't work. This patch fixes it to be
absolute.
2024-10-31 14:03:02 -07:00
Job Henandez Lara
abc49cc194
[libc] remove #include <fcntl.h> and add proxy or type (#113836) 2024-10-28 13:29:16 -07:00
Job Henandez Lara
cf4442e6b1
[libc] temporaliy disable __USE_EXTERN_INLINES and set __USE_FORITFY_LEVEL to 1 before including in overlay mode (#113012) 2024-10-18 19:41:22 -07:00
lntue
c63112a911
[libc][stdio] Use proxy headers of stdio.h in src and test folders. (#110067)
https://github.com/llvm/llvm-project/issues/60481
2024-10-01 11:48:07 -04:00
Michael Jones
e7d68c903b
[libc] Fix errno_macros.h include paths. (#110057)
The proxy header errno_macros.h should include relative to `libc/` but
it
was instead including relative to `libc/include/`. This patch fixes this
by adding the `include` to the paths.
2024-09-25 15:46:29 -07:00
lntue
95d4c97a20
[libc][wchar] Move wchar's types to proxy headers. (#109334)
Also protect against extern inline function definitions added when
building with gcc: https://github.com/llvm/llvm-project/issues/60481.
2024-09-19 22:23:51 -04:00
Michael Jones
f6b4c34d4f
[libc] Add functions to send/recv messages (#106467)
This patch adds the necessary functions to send and receive messages
over a socket. Those functions are: recv, recvfrom, recvmsg, send,
sendto, sendmsg, and socketpair for testing.
2024-09-19 14:43:00 -07:00