2564 Commits

Author SHA1 Message Date
michaelrj-google
ecdbffe59e
[libc] Support epoll_wait using epoll_pwait (#80224)
The epoll_wait syscall is equivalent to calling epoll_pwait with a null
sigset. This is useful to support systems that have epoll_pwait but not
epoll_wait.
2024-02-01 14:23:57 -08:00
Nick Desaulniers
edbd93d370
[libc][stdbit] fix return types (#80337)
All of the functions I've previously implemented return an unsigned int; not
the parameter type.
2024-02-01 13:09:33 -08:00
michaelrj-google
7a7d5481ad
[libc] add bazel support for most of unistd (#80078)
Much of unistd involves modifying files. The tests for these functions
need to use libc_make_test_file_path which didn't exist when they were
first implemented. This patch adds most of unistd to the bazel along
with the corresponding tests. Tests that modify directories had to be
disabled since bazel doesn't seem to handle them properly.
2024-02-01 12:54:01 -08:00
Nick Desaulniers
f883365cc7
[libc] fix stdbit include test when not all entrypoints are available (#80323)
The intent of the test is to check that: 1. The type generic macros are
defined. 2. Those macros dispatch to the correct underlying function.

The issue is that when new functionality is added to our stdbit.h without
rolling out the new entrypoint to all targets, this test breaks because our
generated stdbit.h will not contain declarations for the underlying function.
In that case, we should just declare the underlying functions first before
including our generated stdbit.h which just contains declarations. A definition
is a declaration, but redeclarations must match, hence the additions of
noexcept and extern "C".
2024-02-01 12:08:00 -08:00
Nick Desaulniers
6a3fde6d60
[libc] implement stdc_leading_ones (C23) (#80082) 2024-02-01 10:14:22 -08:00
lntue
94166c6ea1
[libc] Fix wrong errno number in tls_test. (#80312) 2024-02-01 12:31:35 -05:00
lntue
28699e3856
[libc] Update libc_errno to work correctly in both overlay and full build modes. (#80177) 2024-02-01 12:16:28 -05:00
lntue
548d132b94
[libc][NFC] Refactor FLAGS expansion using cmake_language(CALL ...). (#80156) 2024-02-01 11:57:52 -05:00
michaelrj-google
0e8eb445db
[libc] Fix read under msan (#80203)
The read function wasn't properly unpoisoning its result under msan,
causing test failures downstream when I tried to roll it out. This patch
adds the msan unpoison call that fixes the issue.
2024-01-31 16:14:49 -08:00
Nick Desaulniers
0e0d155f87
[libc][docs] fix stdbit.h docs (#80070)
Fix rst comment, add checks for recently implemented functions+macro.
2024-01-31 15:50:18 -08:00
michaelrj-google
22773e591f
[libc] Fix condition ordering in scanf (#80083)
The inf and nan string index bounds checks were after the index was
being used. This patch moves the index usage to the end of the
condition.

Fixes #79988
2024-01-31 13:25:49 -08:00
Nick Desaulniers
16c15b5f84
[libc] disable mlockall w/ MCL_ONFAULT (#80075)
I suspect this is a bug in linux 4.19, as the test passes as written on
my
linux 6.5 machine.

Let's revisit this after the build bots are upgraded.

Link: #80073
2024-01-30 15:16:32 -08:00
Schrodinger ZHU Yifan
24923214e7
[libc] implement mlock/mlock2/munlock/mlockall/munlockall (#79645)
fixes #79336

Co-authored-by: Sirui Mu <msrlancern@gmail.com>
2024-01-30 17:25:03 -05:00
michaelrj-google
576c4dfa06
[libc] disable epoll_pwait2 due to breakage (#80051)
It appears that sys_epoll_pwait2 isn't always available, so we need to
add some sort of condition to enable it. This patch disables it until
that happens.
2024-01-30 13:08:37 -08:00
Joseph Huber
5470ea4e36
[libc] Change the starting port index to use the SMID (#79200)
Summary:
The RPC interface uses several ports to provide parallel access. Right
now we begin the search at the beginning, which heavily contests the
early ports. Using the SMID allows us to stagger the starting index
based off of the cluster identifier that is executing the current warp.
Multiple warps can share an SM, but it will guaruntee that the
contention for the low indices is lower.

This also increases the maximum port size to around 4096, this is
because 512 isn't enough to cover the full hardare parallelism needed to
guarantee this doesdn't deadlock.
2024-01-30 13:06:58 -06:00
michaelrj-google
9f3854a01f
[reland][libc] add epoll_wait functions (#79635)
The epoll_wait functions are syscall wrappers that were requested by
upstream users. This patch adds them, as well as their header and types.

The tests are currently incomplete since they require epoll_create to
properly test epoll_wait. That will be added in a followup patch since
this one is already very large.
2024-01-30 10:07:47 -08:00
Nick Desaulniers
223025a614
[libc][docs] add page for stdbit.h (#79908)
To build libc docs:
- Configure with `-DLLVM_ENABLE_SPHINX=ON -DLIBC_INCLUDE_DOCS=ON`
- Build with `ninja docs-libc-html`
2024-01-30 08:24:28 -08:00
Joseph Huber
0129ff17a9 [libc] Fix running 'stdbit.h' tests if file is never generated
Summary:
This test was added to test the generated header. Unfortunately this
doesn't work if the header is never generated. Add a check to make sure
the user has included it in the list of headers.
2024-01-30 09:23:05 -06:00
Guillaume Chatelet
24a903c405
[libc][NFC] Move functions from FPBits to FPRep, make bits member private (#79974) 2024-01-30 15:25:18 +01:00
Guillaume Chatelet
ace383df52
[libc][NFC] Rename FPBits nan functions (#79998)
- [libc][NFC] Rename FPBits nan functions
- rename build_signaling_nan in signaling_nan
- rename build_quiet_nan to quiet_nan
2024-01-30 15:01:27 +01:00
Guillaume Chatelet
fd3edd4523
[libc] Add test to check all properties for all FPBit types. (#79851)
This test is platform agnostic, it runs all tests on all architectures.
2024-01-30 10:14:51 +01:00
Nick Desaulniers
6b330470df
[libc] add more arch entrypoints for stdc_leading_zeros (#79923)
Otherwise the include test fails on these targets.
2024-01-29 16:57:17 -08:00
Nick Desaulniers
5a7a8f73c7
[libc] fix type generic stdc_leading_zeros for GCC (#79917)
GCC does not support _Generic in C++ mode. Use inline function definitions with
function overloading in __cplusplus mode.
2024-01-29 16:40:03 -08:00
Joseph Huber
d29bb704cb
[libc][NFC] Remove inline assembly for PTX instructions (#79913)
Summary:
Recent patches have implemented builitin versions of these functions.
This patch simply removes uses of inline assembly to hopefully improve
optimizations in this area.
2024-01-29 18:18:04 -06:00
Nick Desaulniers
7bc5eaa02f
[libc] implement stdc_leading_zeros_u* for stdbit.h (#79669)
- stdbit.stdc_leading_zeros_uc
- stdbit.stdc_leading_zeros_us
- stdbit.stdc_leading_zeros_ui
- stdbit.stdc_leading_zeros_ul
- stdbit.stdc_leading_zeros_ull

Test via:
$ ninja libc-stdbit-tests libc_include_tests
2024-01-29 15:47:55 -08:00
Guillaume Chatelet
eb56bc2b10
[libc] Remove specific nan payload in math functions (#79165) 2024-01-29 15:28:46 +01:00
Joseph Huber
4a3d187075
[libc][NFC] Simplify AMDGPU constant frequency checks (#79653)
Summary:
The AMDGPU fixed frequency clock is fixed to a chip dependent frequency.
More modern chips have started to fix this at known values of 25 MHz or
100 MHz, so this function forwards those values. This was done using the
individual architectures. This patch simply uses the more concise
`__GFXn__` macro which indicates the major revision
2024-01-29 08:17:46 -06:00
Sirui Mu
720ade2504
[libc][CMake] fix CMake configure issues on openSUSE (#79751) 2024-01-28 10:56:43 -05:00
Schrodinger ZHU Yifan
517063e0f3
[libc] change PREFER_GENERIC to EXPLICIT_SIMD_OPT (#79486)
fixes #79474.
2024-01-27 14:32:22 -05:00
Schrodinger ZHU Yifan
2e1e27c7c3
[libc] adjust linux's mman.h definitions (#79652)
Use definitions from `<linux/mman.h>` to dispatch arch-specific flag
values.
For example, `MCL_CURRENT/MCL_FUTURE/MCL_ONFAULT` are different on
different architectures.
2024-01-26 19:29:28 -05:00
Caslyn Tonelli
6f97e6bcf7
[fuchsia][libc] Include missing macro definitions (#79639)
PR 79573 introduced `ASSERT_ERRNO_*` macros for use in libc tests.
Introduce these macro definitions to FuchsiaTest.h for string tests to
compile on Fuchsia.
2024-01-26 13:20:57 -08:00
Guillaume Chatelet
73874f7a39
[libc][NFC] Use specific ASSERT macros to test errno (#79573)
This patch provides specific test macros to deal with `errno`.
This will help abstract away the differences between unit test and integration/hermetic tests in #79319.
In one case we use `libc_errno` which is a struct, in the other case we deal directly with `errno`.
2024-01-26 15:18:22 +01:00
michaelrj-google
59e90609d2
Revert "[libc] add epoll_wait functions" (#79534)
Reverts llvm/llvm-project#79515

Some minor breakages. Will fix tomorrow.
2024-01-25 17:05:56 -08:00
michaelrj-google
edb720666f
[libc] add epoll_wait functions (#79515)
The epoll_wait functions are syscall wrappers that were requested by
upstream users. This patch adds them, as well as their header and types.

The tests are currently incomplete since they require epoll_create to
properly test epoll_wait. That will be added in a followup patch since
this one is already very large.
2024-01-25 17:03:18 -08:00
felixh5678
0b0cce8978
[libc] Add fminf128 and fmaxf128 implementations for Linux x86_64. (#79307)
Co-authored-by: Felix <felix@Dirks-MacBook-Pro.local>
2024-01-25 15:04:18 -05:00
michaelrj-google
8a0ff194e3
[libc] Fix type warning on gcc in float to str (#79482)
Minor cast warning that was missed in previous patch. Fixed with
explicit cast.
2024-01-25 10:39:11 -08:00
michaelrj-google
a621198a03
[libc] Move printf long double to simple calc (#75414)
The Ryu algorithm is very fast with its table, but that table grows too
large for long doubles. This patch adds a method of calculating the
digits of long doubles using just wide integers and fast modulo
operations. This results in significant performance improvements vs the
previous int calc mode, while taking up a similar amound of peak memory.
It will be slow in some %e/%g cases, but reasonable fast for %f with no
loss of accuracy.
2024-01-25 09:35:40 -08:00
lntue
e9355b1b3e
[libc] Use __SIZEOF_LONG__ to define LONG_WIDTH instead of sizeof(long). (#79391)
The standard requires `limits.h` constants to be used in preprocessors.
So we use `__SIZEOF_LONG__` instead of `sizeof(long)` to define
`LONG_WIDTH`. The macro `__SIZEOF_LONG__` seems to be available on both
clang and gcc since at least version 9.
2024-01-24 20:02:03 -05:00
lntue
3a92b20cb0
[libc] Add backup definition for LONG_WIDTH in limits-macros.h. (#79375) 2024-01-24 17:04:11 -05:00
lntue
72ce629415
[libc] Add C23 limits.h header. (#78887) 2024-01-24 16:08:56 -05:00
Schrodinger ZHU Yifan
22c22d6182
[libc][NFC] mark hashtable as resizable (#79354)
It is not fix-sized anymore.
2024-01-24 15:18:40 -05:00
Schrodinger ZHU Yifan
4a9b5aa116
[libc][NFC] remove TODO about AppProperties (#79356)
```
AppProperties app;
```
is marked as a weak symbol in header now. One can just use `&app !=
nullptr` to check if `app` is defined. There is no need to define it for
overlay mode.
2024-01-24 15:18:11 -05:00
Schrodinger ZHU Yifan
7b11c08c66
[libc] remove unstable mincore test for invalid vec (#79348)
The faults on invalid vec range in mincore seems to be handled
differently by the OS (it is an erroneous edge case after all). Remove
the tests for now.
2024-01-24 14:11:27 -05:00
Schrodinger ZHU Yifan
048041f197
[libc] reland mincore (#79309) 2024-01-24 13:47:56 -05:00
lntue
c1cb0b80f0
[libc][NFC] Fix -DSHOW_INTERMEDIATE_OBJECTS=DEPS to work properly for entry points and unit tests. (#79254) 2024-01-24 13:34:13 -05:00
felixh5678
777eb35614
[libc] Add sqrtf128 implementation for Linux x86_64. (#79195)
Co-authored-by: Tue Ly <lntue@google.com>
Co-authored-by: Felix <felix@Dirks-MacBook-Pro.local>
2024-01-24 10:16:12 -05:00
Nick Desaulniers
6a3ace20c8
[libc] remove redundant call_once (#79226)
Missed cleanup from https://reviews.llvm.org/D134716.

Fixes: #79220
2024-01-23 15:38:12 -08:00
lntue
3a9ff32354
[libc] Fix implicit conversion in FEnvImpl for arm32 targets. (#79210) 2024-01-23 16:14:50 -05:00
lntue
d86a6eacf6
[libc] Fix aliasing function name got accidentally deleted in #79128. (#79203) 2024-01-23 14:19:34 -06:00
Roland McGrath
9122d19de4
Revert "[libc] Fix forward arm32 buildbot" (#79201)
Reverts llvm/llvm-project#79151, necessary to revert #79128, which broke
all production builds and landed without review.
2024-01-23 12:15:22 -08:00