65 Commits

Author SHA1 Message Date
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
Schrodinger ZHU Yifan
d8e124dffa
[libc] implement vdso (#91572) 2024-09-11 12:51:11 -04:00
wldfngrs
3d7af093f3
[libc] Add proxy header for the jmp_buf type (#107712)
Added proxy header for the jmp_buf type and changed all use instances
from __jmp_buf * to the typedef alias jmp_buf , fixed the link to LLVM
in stack_t.h description
2024-09-08 20:55:00 -04:00
wldfngrs
056a1676cb
[libc] Add proxy header for the stack_t type (#107559)
added proxy header for the stack_t type and modified the corresponding
CMakeLists.txt files
2024-09-07 10:01:33 -04:00
lntue
876b0e60fe
[libc] Fix signal's dependency on the proxy header sighandler_t. (#107605) 2024-09-06 16:23:53 -04:00
wldfngrs
73514f6831
[libc] Add proxy header for __sighandler_t type (#107354)
Added proxy headers for __sighandler_t type, modified the corresponding
CMakeLists.txt files and test files
2024-09-05 18:04:35 -04:00
Joseph Huber
78d8ab2ab9
[libc] Initial support for 'locale.h' in the LLVM libc (#102689)
Summary:
This patch adds the macros and entrypoints associated with the
`locale.h` entrypoints.  These are mostly stubs, as we (for now and the
forseeable future) only expect to support the C and maybe C.UTF-8
locales in the LLVM libc.
2024-08-22 12:58:46 -05:00
Joseph Huber
2f4232db0b Revert " [libc] Add ctype.h locale variants (#102711)"
This reverts commit 8f005f8306dc52577b3b9482d271fb463f0152a5.
2024-08-22 12:45:16 -05:00
Joseph Huber
8f005f8306
[libc] Add ctype.h locale variants (#102711)
Summary:
This patch adds all the libc ctype variants. These ignore the locale
ingormation completely, so they're pretty much just stubs. Because these
use locale information, which is system scope, we do not enable building
them outisde of full build mode.
2024-08-22 12:41:20 -05:00
Nhat Nguyen
f8f5b17564
[libc] Create a separate proxy header for math-function-macros.h (#98430)
Fix #98393
2024-07-28 00:38:49 -04:00
Michael Jones
5aed6d67e3
Reland: [libc] Move off_t and stdio macros to proxy hdrs (#98384)
reland of https://github.com/llvm/llvm-project/pull/98215

Additionally adds proxy headers for FILE and the fopencookie types

The arm32 build has been failing due to redefinitions of the off_t type.
This patch fixes this by moving off_t to a proper proxy header. To do
this, it also moves stdio macros to a proxy header to hopefully avoid
including this proxy header alongside this public stdio.h.
2024-07-11 11:09:51 -07:00
Petr Hosek
d99efd53f5
[libc] Add a missing math-function-macros.h include (#98271)
This was accidentally omitted in #96008.
2024-07-09 22:25:40 -07:00
Michael Jones
3a744283f4
Revert "[libc] Move off_t and stdio macros to proxy hdrs" (#98242)
Reverts llvm/llvm-project#98215

Breaks linux bots
2024-07-09 16:22:38 -07:00
Michael Jones
240ec5a375
[libc] Move off_t and stdio macros to proxy hdrs (#98215)
The arm32 build has been failing due to redefinitions of the off_t type.
This patch fixes this by moving off_t to a proper proxy header. To do
this, it also moves stdio macros to a proxy header to hopefully avoid
including this proxy header alongside this public stdio.h.
2024-07-09 16:17:02 -07:00
Schrodinger ZHU Yifan
1b26bb0d12
[libc] fix aarch64 GCC build (#97932)
This PR fix several build errors on aarch64 targets when building with
gcc:
- uninitialized values leading to `Werrors`
- undefined builtin functions
- glibc header pollution
2024-07-07 12:12:47 -07:00
Nhat Nguyen
7f3c40a661
[libc] implement pathconf/fpathconf (#87165) 2024-07-07 11:20:49 -07:00
Schrodinger ZHU Yifan
133492fe18
[libc] add proxy header for struct_sigaction (#96224) 2024-06-26 12:46:15 -07:00
aaryanshukla
39d38d66ec
[libc] at_quick_exit function implemented (#94317)
- added at_quick_exit function 
- used helper file exit_handler which reuses code from atexit
- atexit now calls helper functions from exit_handler
- test cases and dependencies are added

---------

Co-authored-by: Aaryan Shukla <aaryanshukla@google.com>
2024-06-06 17:21:44 +00:00
Schrodinger ZHU Yifan
142afde0eb
[libc] rework mutex (#92168) 2024-05-31 18:57:18 -07:00
lntue
4486fcba75
[libc] Add proxy header for float.h. (#93504)
This is the continuation of
https://github.com/llvm/llvm-project/pull/88674.

Fixes #88433, #90496.

---------

Co-authored-by: aniplcc <aniplccode@gmail.com>
2024-05-28 19:14:26 -04:00
lntue
8960078765
[libc][errno] Include <linux/errno.h> for Linux in full build mode. (#92041) 2024-05-13 18:31:35 -04:00