2176 Commits

Author SHA1 Message Date
wldfngrs
ecf4f95c4f
[libc][math][c23] Add tanf16 function (#121018)
- Implementation of tan for 16-bit floating point inputs.
- Exhaustive tests across the 16-bit input range
2025-01-12 23:46:53 -05: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
Joseph Huber
0acdba83ae
[libc] Remove leftover 'gpu/' source directory (#122368)
Summary:
This isn't used anymore, I moved the GPU extensions into `offload/`.
2025-01-09 14:46:34 -06:00
Alexey Samsonov
b30f9d74d6
[libc] Fix return value of __cxa_thread_atexit_impl function. (#122171)
This has been added in 0071a79532e8d664b734956a431d8c8c942cc25e to
support TLS destructors. Return value of __cxa_thread_atexit is supposed
to be the same as std::atexit - zero on success, non-zero on failure.
Update the code to do just that (also be consistent with llvm-libc's
existing atexit / at_quick_exit implementations).
2025-01-08 21:47:58 -08:00
Jack Huang
c6b7bd42d5
[libc] Support _IONBF buffering for read_unlocked (#120677)
Support _IONBF buffering for read_unlocked. Add the functions
read_unlocked_nbf() and read_unlocked_fbf().

Fixes: #120155
2025-01-09 11:24:16 +08:00
Alexey Samsonov
508398021d
[libc] Add hardening for FixedVector data structure and fix exposed bug. (#122159)
Add LIBC_ASSERT statements to FixedVector implementation, and zero out
the memory when the elements are removed to flag out-of-bound access and
dangling pointer/reference access.

This change unmasks the bug in one of FixedVector uses for atexit
handlers: dangling reference use, which was actually led to crashes in
the wild (with prod blockstore implementation). Fix it in this CL.
2025-01-08 13:03:59 -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
Joseph Huber
ac604b2fa6
[libc] Switch to using the generic <gpuintrin.h> implementations (#121810)
Summary:
This patch switches the GPU utility helpers to wrapping around the
gpuintrin.h ones with a C++ flavor.
2025-01-07 13:08:39 -06:00
Nick Desaulniers
0a58a1c9a2 [libc] update todo with bug link 2025-01-07 08:55:14 -08:00
JoelWee
f0247081fa
Fix after #121482 (#121764) 2025-01-06 13:17:37 +00:00
Lukas Bergdoll
a738d81cd2
[libc] Improve qsort (with build fix) (#121482) 2025-01-05 06:10:41 +08:00
Alexey Samsonov
9a95c097d0
[libc] Remove some unused includes from headers under src/math/generic. (#121632)
These were indicated by Clang include-cleaner.
2025-01-04 10:02:48 -08:00
Mikhail R. Gadelha
82c0f68c04 [libc] Remove assert to fix rv32 buildbot 2025-01-03 22:03:30 -03:00
Roland McGrath
62cd050b63
[libc] Move hdrgen yaml files into include/ (#121443)
The .yaml files should live next to the corresponding .h.def
files in libc/include/, rather than next to the implementation of
the tool in libc/utils/hdrgen/.  As with the .h.def files, there
is no need for a yaml/ subdirectory under include/.  This simpler
layout is more natural for maintenance and also simplifies build
integration outside the LLVM CMake build.
2025-01-01 17:03:35 -08:00
Tristan Ross
1d0f40ba05
[libc] fix generic __stack_check_fail for fuchsia (#121401) 2024-12-31 19:36:24 -05:00
Tristan Ross
6f3d1d3018
[libc] add __stack_chk_guard to generic (#121121) 2024-12-31 02:34:16 -05:00
Roland McGrath
9abcca5e25
[libc] Move hdrgen into utils/ subdirectory (#121256) 2024-12-30 15:36:53 -08:00
Schrodinger ZHU Yifan
0b96f1cf68
Revert "[libc] Improve qsort" (#121303)
Reverts llvm/llvm-project#120450
2024-12-29 16:03:53 -05:00
Lukas Bergdoll
d2e71c92b8
[libc] Improve qsort (#120450) 2024-12-29 14:55:44 -05:00
Shourya Goel
abd9102344
[libc][complex] add cfloat16 and cfloat128 compiler flags (#121140)
Proper fix for the temporary fix in #114696
2024-12-26 12:50:07 +05:30
Joseph Huber
3bbd53ce97
[libc] Remove old RPC host call extension for GPU (#120800)
Summary:
This was originally a hacked together function that served to just
implement some features for OpenMP. That has been moved into OpenMP
itself now that we have exported RPC properly. This can now be deleted.
2024-12-20 19:34:05 -06:00
Joseph Huber
958de20b30
[libc] Enable 'timespec_get' for the GPU build (#120304)
Summary:
Currently fails to build libc++ because this is missing.
2024-12-17 15:31:07 -06:00
Shourya Goel
c98e79d856
[libc][complex] Implement different flavors of the cproj function (#119722)
Refer section 7.3.9.5 of ISO/IEC 9899:2023
2024-12-18 02:04:50 +05:30
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
Petr Hosek
7bf3137c39
[libc] Breakup freelist_malloc into separate files (#119806)
This better matches the structure we use for the rest of libc.
2024-12-16 10:30:27 -08:00
Schrodinger ZHU Yifan
f75c84674c
[libc] fix atomic and apply an explicit check on unique object representations (#119715) 2024-12-16 12:04:52 -05:00
wldfngrs
6a865b6d3d
[libc][math][c23] Add cosf16 function (#118785) 2024-12-15 18:58:54 +01:00
lntue
4eec286b51
[libc] Add MPFR testing infra for float128. (#119499) 2024-12-13 09:32:38 -05:00
Petr Hosek
379cc44f56
Revert "[libc] Breakup freelist_malloc into separate files" (#119749)
Reverts llvm/llvm-project#98784 which broke libc builders.
2024-12-12 13:28:30 -08:00
Petr Hosek
4e2a9e50f6
[libc] Breakup freelist_malloc into separate files (#98784)
This better matches the structure we use for the rest of libc.
2024-12-12 11:24:36 -08:00
Nick Desaulniers
1d7d0051f9
[libc] move src/network to src/arpa/inet (#119273)
So that docgen can find our implementations.

Fixes: #119272
2024-12-10 08:59:39 -08: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
Shourya Goel
ca88a0e6f2
[libc][complex] fix guard for cfloat128 and float128 (#119330) 2024-12-10 11:38:40 +05:30
Shourya Goel
52da2db489
[libc][complex] check that cfloat128 is not defined as _Complex long double (#119324)
Fix buildbot errors in #118671
2024-12-10 11:18:29 +05:30
Shourya Goel
78c2b6d483
[libc][complex] Implement different flavors of the conj function (#118671)
Refer section 7.3.9.4 of ISO/IEC 9899:2023
2024-12-10 10:05:11 +05:30
Schrodinger ZHU Yifan
9a06fb7e5c
[libc][time][windows] implement clock_getres (#118931) 2024-12-09 22:00:01 -05: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
Louis Dionne
b9a209725b
[libc] Remove unused target conditionals for Apple platforms (#119030)
It seems that LIBC_TARGET_OS_IS_MACOS and LIBC_TARGET_OS_IS_IPHONE were
never actually used in the code, so these definitions can be removed.

I came across these because libc++ now depends on llvm-libc to build
(for from_chars), and the unguarded use of TargetConditionals.h broke
some of our downstream configurations. There are some platforms for
which `__APPLE__` is defined but that don't provide TargetConditionals.h.

If there is a need to keep defining those, the compiler also provides
some uglier macro definitions like __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
that do not require including any header.
2024-12-09 09:09:47 -05:00
Schrodinger ZHU Yifan
f91a5fee53
[libc] fix woa64 fenv implementation (#119155)
Changing name type to match x86-64. This resolves definition conflicts
with `core_crt` headers.

fix #119154
2024-12-08 20:24:57 -05:00
Joseph Huber
7ff89294b6
[libc] Update fence to use scoped fence now that it's supported (#119018)
Summary:
Adds support for scoped fences now that the NVPTX backend doesn't break
on them.
2024-12-06 15:20:07 -06:00
Schrodinger ZHU Yifan
39451e45f5
[libc][CPP] clean up and generalize atomic implementation (#118996) 2024-12-06 12:47:19 -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
Schrodinger ZHU Yifan
245f26a3d3
[libc] revert all process_mrelease changes (#118650)
Revert as its test is unstable.
https://github.com/llvm/llvm-project/issues/118057
2024-12-05 11:58:37 -05:00
lntue
a7da702377
[libc][math] Add small code size options for atan2f. (#118532) 2024-12-04 16:37:51 -05:00
Nick Desaulniers
06c831d7fb
[libc] rename newhdrgen to just hdrgen (#118545)
Link: #117208
Fixes: #117254
2024-12-04 08:48:12 -08:00
Michael Jones
a0c4f854ca
[libc] Change ctype to be encoding independent (#110574)
The previous implementation of the ctype functions assumed ASCII.
This patch changes to a switch/case implementation that looks odd, but
actually is easier for the compiler to understand and optimize.
2024-12-03 12:36:04 -08:00
wldfngrs
cd04653c4e
[libc][math][c23] Add sinf16 C23 math function (#116674)
Co-authored-by: OverMighty <its.overmighty@gmail.com>
2024-12-03 21:08:46 +01:00