50 Commits

Author SHA1 Message Date
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
Robin Caloudis
561c42df57
[libc][errno] Use macro instead of system header (#91150)
## Why
Currently, the system header `errno.h` is included in `libc_errno.h`,
which is supposed to be consumed by internal implementations only. As
unit and hermetic tests should never use `#include <errno.h>` but
instead use `#include "src/errno/libc_errno.h"`, we do not want to
implicitly include `errno.h`. In order to have a clear seperation
between those two, we want to pull out the definitions of errno numbers
from `errno.h`.

## What
* Extract the definitions of errno numbers from
[include/errno.h.def](https://github.com/llvm/llvm-project/pull/91150/files#diff-ed38ed463ed50571b498a5b69039cab58dc9d145da7f751a24da9d77f07781cd)
and place it under
[include/llvm-libc-macros/linux/error-number-macros.h](https://github.com/llvm/llvm-project/pull/91150/files#diff-d6192866629690ebb7cefa1f0a90b6675073e9642f3279df08a04dcdb05fd892)
* Provide mips-specific errno numbers in
[include/llvm-libc-macros/linux/mips/error-number-macros.h](https://github.com/llvm/llvm-project/pull/91150/files#diff-3fd35a4c94e0cc359933e497b10311d857857b2e173e8afebc421b04b7527743)
* Find definition of mips errno numbers in glibc
[here](ea73eb5f58/sysdeps/unix/sysv/linux/mips/bits/errno.h (L32-L50))
(equally defined in the Linux kernel)
* Provide sparc-specific errno numbers in
[include/llvm-libc-macros/linux/sparc/error-number-macros.h](https://github.com/llvm/llvm-project/pull/91150/files#diff-5f16ffb2a51a6f72ebd4403aca7e1edea48289c99dd5978a1c84385bec4f226b)
* Find definition of sparc errno numbers in glibc
[here](ea73eb5f58/sysdeps/unix/sysv/linux/sparc/bits/errno.h (L33-L51))
(equally defined in the Linux kernel)
* Include proxy header `errno_macros.h` instead of the system header
`errno.h` in `libc_errno.h`/`libc_errno.cpp`

Closes https://github.com/llvm/llvm-project/issues/80172
2024-05-13 17:56:01 -04:00
Schrodinger ZHU Yifan
d8e73752a5
Reland "[libc][NFC] adjust time related implementations"" (#91687)
Reverts llvm/llvm-project#91657 and Relands #91485
2024-05-10 15:32:04 -04:00
Schrodinger ZHU Yifan
5a0e0b659f
Revert "[libc][NFC] adjust time related implementations" (#91657)
Reverts llvm/llvm-project#91485. It breaks GPU and fuchisa.
2024-05-09 17:27:59 -04:00
Schrodinger ZHU Yifan
8ac928fea8
[libc][NFC] adjust time related implementations (#91485) 2024-05-09 16:34:45 -04:00
lntue
e37bd6c68b
[libc][fenv] Add missing FE_* definitions for some environment. (#91519) 2024-05-08 17:32:05 -04:00
Joseph Huber
873431a68a
[libc] Add __FE_DENORM to the fenv macros (#91353)
Summary:
Some targets support denormals as floating point exceptions. This is
provided as an extension in the GNU headers as __FE_DENORM.

This provides it in our headers, however I'm unsure if we should make it
internal or external. I do not think it should be in all exception as it
doesn't represent an exceptional behavior as far as the standard is
concerned, but I'm not an expert.
2024-05-07 12:57:54 -05:00
Vinayak Dev
aca511734f
[libc] Implement fcntl() function (#89507)
Fixes #84968. 

Implements the `fcntl()` function defined in the `fcntl.h` header.
2024-05-01 11:18:44 -07:00
Michael Jones
b1385dbd98
[libc][NFC] fix typo in fenv type proxy headers (#88982)
libc.incude.fenv ->
libc.include.fenv
2024-04-16 14:39:43 -07:00
Job Henandez Lara
75bbf4dd7c
[libc] Add proxy headers for fenv types. (#88467)
Fixes #88187
2024-04-15 11:45:16 -07:00
Michael Jones
5fb821560a
[libc] add remaining epoll functions, pipe (#84587)
The epoll_wait functions need the rest of the epoll functions (create,
ctl) to be available to actually test them, as well as pipe to create a
usable file descriptor. This patch adds epoll_create, epoll_create1,
epoll_ctl, and pipe. These have tests, and the tests for epoll_wait,
epoll_pwait, and epoll_pwait2 (currently disabled) are updated to use
these newly available functions.
2024-04-11 16:26:49 -07:00
Nick Desaulniers
f626a35086
[libc] Codify header inclusion policy (#87017)
When supporting "overlay" vs "fullbuild" modes, "what ABI are you
using?" becomes a fundamental question to have concrete answers for.
Overlay mode MUST match the ABI of the system being overlayed onto;
fullbuild more flexible (the only system ABI relevant is the OS kernel).

When implementing llvm-libc we generally prefer the include-what-you use
style of avoiding transitive dependencies (since that makes refactoring
headers more painful, and slows down build times). So what header do you
include for any given type or function declaration? For any given
userspace program, the answer is straightforward. But for llvm-libc
which is trying to support multiple ABIs (at least one per
configuration), the answer is perhaps less clear.

This proposal seeks to add one layer of indirection relative to what's
being done today.

It then converts users of sigset_t and struct epoll_event and the epoll
implemenations over to this convention as an example.
2024-04-11 10:11:58 -07:00
Nick Desaulniers
8cfa72ade9 [libc] fix typo in hdr/CMakeLists
Fixes #87896
2024-04-10 13:51:23 -07:00
Job Henandez Lara
49561181bd
[libc] Add proxy header for fenv.h macro constants. #87863 (#87896)
Hello, this addresses #87863.
2024-04-09 12:55:10 -04:00
lntue
7248c9feb9
[libc] Adding FP_INT_* macro constants if missing in overlay mode. (#87880) 2024-04-06 17:38:47 -04:00
lntue
5748ad84e5
[libc] Add proxy header math_macros.h. (#87598)
Context: https://github.com/llvm/llvm-project/pull/87017

- Add proxy header `libc/hdr/math_macros.h` that will:
  - include `<math.h>` in overlay mode,
- include `"include/llvm-libc-macros/math-macros.h"` in full build mode.
- Its corresponding CMake target `libc.hdr.math_macros` will only depend
on `libc.include.math` and `libc.include.llvm-libc-macros.math_macros`
in full build mode.
- Replace all `#include "include/llvm-libc-macros/math-macros.h"` with
`#include "hdr/math_macros.h"`.
- Add dependency to `libc.hdr.math_macros` CMake target when using
`add_fp_unittest`.
- Update the remaining dependency.
- Update bazel overlay: add `libc:hdr_math_macros` target, and replacing
all dependency on `libc:llvm_libc_macros_math_macros` with
`libc:hdr_math_macros`.
2024-04-05 18:21:16 -04:00