| Age | Commit message (Collapse) | Author | Files | Lines |
|
Updated the math guide to reflect the recent refactor
closes #175371.
|
|
This was accidentally introduced in #172766.
|
|
Some of the baremetal users of libc use elf.h to generate coredumps and
we would like to support this use case without needing Linux elf.h.
|
|
Summary:
The Volta independent thread scheduling is very difficult to work with.
This is a first attempt to make the logic more sound when lanes execute
independently. This isn't all that's required, but it ends up improving
control flow for AMDGPU as well.
|
|
src/__support/math folder. (#175450)
Closes [#175346](https://github.com/llvm/llvm-project/issues/175346),
Part of #175344
|
|
|
|
Refactors log to a header-only shared math implementation.
Fixes #175369
|
|
This is a follow up to #174823 which adds build system integration.
|
|
src/__support/math folder. (#175200)
Part of #147386
in preparation for:
https://discourse.llvm.org/t/rfc-make-clang-builtin-math-functions-constexpr-with-llvm-libc-to-support-c-23-constexpr-math-functions/86450
|
|
src/__support/math folder. (#162132)
Part of #147386
in preparation for:
https://discourse.llvm.org/t/rfc-make-clang-builtin-math-functions-constexpr-with-llvm-libc-to-support-c-23-constexpr-math-functions/86450
|
|
This adds the --proxy switch to generate headers like go
into libc/src/hdr/foo-proxy.h instead of public headers.
|
|
This avoids the GOT slot being generated which is undesirable when using
static linking. A better solution would be to reorganize the code to
avoid the use of weak symbols altogether.
Fixes #173409
|
|
There was a typo introduced in #168637, this PR fixes it. Thanks to
Nikolas for pointing it out.
|
|
(#172042)
[#172040](https://github.com/llvm/llvm-project/issues/172040)
This patch implements the scripts for generating the lookup tables and
associated utils for wctype classification functions. Not all Unicode
properties are covered as not all need a lookup table, the rest will be
hardcoded. The size of the generated tables is 47,8KB.
|
|
teardown_main_tls is called right before the main process exit to unmap
the TLS but that's unnecesary since the process is terminating anyway,
this just introduces extra system call. This can be potentially harmful
in case one of the other threads tries the access the memory that has
been unmapped. Other C library implementations don't unmap TLS either so
this makes LLVM libc's behavior more consistent.
Fixes #173409
|
|
The previous checks will fail with
https://github.com/llvm/llvm-project/pull/174123.
See
https://github.com/llvm/llvm-project/pull/174290#issuecomment-3708052716
for the discussion.
|
|
I'm currently getting "Detected memory leaks" errors due to this. This
change should always delete the buffers after use.
|
|
(#173440)
Add the boilerplate for declaring these POSIX functions and
providing implementations. So far the only implementations are
just stubs that fail with ENOTSUP, and they are neither tested
nor included in any CMake entrypoints lists. More work is still
required to add the actual fields to the pthread_attr_t and
implement the support in the Linux pthread_create et al, but that
is not done here. It's not an especially large amount of work,
but more than just trivial.
The scaffolding here paves the way for that later work, but is
also immediately useful for filling out the subset of POSIX
pthread_attr_* functions that Fuchsia's libc already supports.
|
|
Adding `#include "src/__support/CPP/new.h"` due to align_val_t usage
within alloc-checker.h
|
|
This moves the libc-internal AllocChecker API out of
src/__support/CPP/new.h and updates CPP/README.md to state the
intent to keep src/__support/CPP and the LIBC_NAMESPACE::cpp
namespace a "pure" subset of standard C++ API polyfills.
|
|
(#172902)
This is to allow math function implementations to use system libc's
fenv.h instead of internal fenv implementations.
|
|
The LLVM-libc goals are updated to better reflect the strategy shared
at the LLVM dev meeting 2025.
|
|
src/__support/math folder. (#162131)
Part of #147386
in preparation for: https://discourse.llvm.org/t/rfc-make-clang-builtin-math-functions-constexpr-with-llvm-libc-to-support-c-23-constexpr-math-functions/86450
|
|
This patch adds the `IN6_IS_ADDR_V4COMPAT` macro, which checks whether
an address is IPv4-compatible.
|
|
This patch adds the `IN6_IS_ADDR_V4MAPPED` macro, which checks whether
an address is IPv4 mapped address.
|
|
This patch adds the `IN6_IS_ADDR_MC*` macro, which checks whether an
address is multicast node-local address, multicast link-local address,
multicast site-local address, multicast organization-local address and
multicast global address.
|
|
This patch adds the `IN6_IS_ADDR_MULTICAST` macro, which checks whether
an address is multicast address.
|
|
This patch adds the `IN6_IS_ADDR_LOOPBACK` macro, which checks whether
an address is loopback address.
|
|
This patch adds the `IN6_IS_ADDR_UNSPECIFIED` macro, which checks
whether an address is unspecified address.
|
|
The negative value represents an error and we already use cast in this
scenario elsewhere.
|
|
In a recent update to x86's fenv, we use `_MM_GET/SET_EXCEPTION_STATE`
macros from `<immintrin.h>` which turn out to do a bit more work than
just read and write the mxcsr register. In this PR we change those to a
direct read and write mxcsr intrinsics.
|
|
This change expands the stdio support on baremetal to support opaque
FILE*. This builds on top of the existing baremetal embedding API; we
treat the standard FILE* streams as pointers that point to the cookie
symbols which are a part of the embedding API. This also allows users to
define their own FILE* streams, but we don't (yet) support the API that
return FILE* such as fopen or fopencookie.
|
|
(#172562)
Similar to e85a9f5540f5
Somehow conflict with define in wingdi.h.
Fix build failures:
...FPUtil\x86_64\fenv_x86_common.h(78,29): error: expected member name
or
';' after declaration specifiers
78 | static constexpr uint16_t ERROR = 0xFFFF;
| ~~~~~~~~~~~~~~~~~~~~~~~~~ ^
c:\Program files (x86)\Windows
Kits\10\include\10.0.22000.0\um\wingdi.h(118,29):
note: expanded from macro 'ERROR'
118 | #define ERROR 0
|
|
|
This PR makes the string trap on OOM.
Previously, the `__builtin_unreachable` has made debugging tricky as it
makes the control flow of OOM as an undefined behavior.
We can run into OOM with testing configuration easily where memory is
statically bounded.
We did not settle with the best solution of this but making it trap is
at least better than UB
in this case.
|
|
Previously we only checked the long double value of the provided double.
This meant we didn't check any values near the edge of the long double
range, which meant we were missing several bugs. This patch adds a
second long double value to check which is generated separately from the
double value and can be anywhere in the range.
|
|
This patch implements the generic mutex and raw_mutex interfaces on
macOS. A new Futex class is provided that relies on os_sync_wait and
os_sync_wake to emulate futex‑like wait and wake semantics. The
OS‑specific part is moved into futex_utils, which now contains the
Darwin implementation.
|
|
|
|
implementation from LLVM libc. (#143959)" (#172325)
This reverts commit 4190d576823c18f45ee0632baee7d798448178ac.
See https://lab.llvm.org/buildbot/#/builders/181/builds/33524
```
from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/lib/Support/APFloat.cpp:32:
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/../libc/src/__support/math/asin_utils.h:548:1: in ‘constexpr’ expansion of ‘__llvm_libc::fputil::DyadicFloat<128>(__llvm_libc::Sign::POS, -127, __llvm_libc::BigInt<128, false, long unsigned int>(__llvm_libc::operator""_u128(((const char*)"0x80000000\'00000000\'00000000\'00000000"))))’
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/../libc/src/__support/FPUtil/dyadic_float.h:109:5: in ‘constexpr’ expansion of ‘((__llvm_libc::fputil::DyadicFloat<128>*)this)->__llvm_libc::fputil::DyadicFloat<128>::normalize()’
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/../libc/src/__support/FPUtil/dyadic_float.h:118:16: in ‘constexpr’ expansion of ‘((__llvm_libc::fputil::DyadicFloat<128>*)this)->__llvm_libc::fputil::DyadicFloat<128>::mantissa.__llvm_libc::BigInt<128, false, long unsigned int>::operator<<=(((size_t)shift_length))’
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/../libc/src/__support/big_int.h:829:52: in ‘constexpr’ expansion of ‘__llvm_libc::multiword::shift<__llvm_libc::multiword::LEFT, false, long unsigned int, 2>(((__llvm_libc::BigInt<128, false, long unsigned int>*)this)->__llvm_libc::BigInt<128, false, long unsigned int>::val, s)’
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/../libc/src/__support/big_int.h:264:35: error: ‘constexpr __llvm_libc::cpp::enable_if_t<((((sizeof (To) == sizeof (From)) && __llvm_libc::cpp::is_trivially_constructible<To>::value) && __llvm_libc::cpp::is_trivially_copyable<T>::value) && __llvm_libc::cpp::is_trivially_copyable<From>::value), To> __llvm_libc::cpp::bit_cast(const From&) [with To = __int128 unsigned; From = __llvm_libc::cpp::array<long unsigned int, 2>; __llvm_libc::cpp::enable_if_t<((((sizeof (To) == sizeof (From)) && __llvm_libc::cpp::is_trivially_constructible<To>::value) && __llvm_libc::cpp::is_trivially_copyable<T>::value) && __llvm_libc::cpp::is_trivially_copyable<From>::value), To> = __int128 unsigned]’ called in a constant expression
264 | auto tmp = cpp::bit_cast<type>(array);
| ~~~~~~~~~~~~~~~~~~~^~~~~~~
from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/lib/Support/APFloat.cpp:32:
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/../libc/src/__support/CPP/bit.h:48:1: note: ‘constexpr __llvm_libc::cpp::enable_if_t<((((sizeof (To) == sizeof (From)) && __llvm_libc::cpp::is_trivially_constructible<To>::value) && __llvm_libc::cpp::is_trivially_copyable<T>::value) && __llvm_libc::cpp::is_trivially_copyable<From>::value), To> __llvm_libc::cpp::bit_cast(const From&) [with To = __int128 unsigned; From = __llvm_libc::cpp::array<long unsigned int, 2>; __llvm_libc::cpp::enable_if_t<((((sizeof (To) == sizeof (From)) && __llvm_libc::cpp::is_trivially_constructible<To>::value) && __llvm_libc::cpp::is_trivially_copyable<T>::value) && __llvm_libc::cpp::is_trivially_copyable<From>::value), To> = __int128 unsigned]’ is not usable as a ‘constexpr’ function because:
48 | bit_cast(const From &from) {
| ^~~~~~~~
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/../libc/src/__support/CPP/bit.h:56:28: error: call to non-‘constexpr’ function ‘void __llvm_libc::cpp::inline_copy(const char*, char*) [with unsigned int N = 16]’
56 | inline_copy<sizeof(From)>(src, dst);
```
|
|
implementation from LLVM libc. (#143959)
Discourse RFC:
https://discourse.llvm.org/t/rfc-make-clang-builtin-math-functions-constexpr-with-llvm-libc-to-support-c-23-constexpr-math-functions/86450
- The implementation in LLVM libc is header-only.
- expf implementation in LLVM libc is correctly rounded for all rounding
modes.
- LLVM libc implementation will round to the floating point
environment's rounding mode.
- No cmake build dependency between LLVM and LLVM libc, only requires
LLVM libc source presents in llvm-project/libc folder.
|
|
This patch introduces two macros in `netinet/in.h`. The redundant tests
for macro values in the testcases have been removed.
|
|
In a previous PR I fixed one case where subnormal long doubles would
cause an infinite loop in printf. It was an improper fix though. The
problem was that a shift on the fixed point representation would
sometimes go negative, since the effective exponent of a subnormal is
lower than the minimum allowed exponent value. This patch extends the
fixed point representation to have space for subnormals, and adds an
assert to check that lshifts are always positive. The previous fix of
sometimes shifting right instead of left caused a loss of precision
which also sometimes caused infinite loops in the %e code.
|
|
Closes #170871
|
|
There are three flavors of WriteBuffer currently, all of which could be
passed into `printf_core::Writer` class. It's a tricky class, since it
chooses a flavor-specific logic either based on runtime dispatch (to
save code size and prevent generating three versions of the entirety of
printf_core), or based on template arguments (to avoid dealing with
function pointers in codegen for `FILL_BUFF_AND_DROP_OVERFLOW` path).
Refactor this somewhat convoluted logic to have three concrete
subclasses inheriting from the templated base class, and use static
polymorphism with `reinterpret_cast` to implement dispatching above. Now
we can actually have flavor-specific fields, constructors, and methods
(e.g. `flush_to_stream` is now a method of `FlushingBuffer`), and the
code on the user side is cleaner: the complexity of enabling/disabling
runtime-dispatch and using proper template arguments is now localized in
`writer.h`.
This code will need to be further templatized to support buffers of type
`wchar_t` to implement `swprintf()` and friends. This change would make
it (ever so slightly) easier.
|
|
As in the description.
|
|
overlay mode (#171691)
MacOS SDK defines certain functions as macros in its stdio header. This
leads to problems in overlay mode.
This patch add undefs to macros that may conflict with function names in
overlay header. We don't expect to import them via overlay macro headers
anyway.
```bash
FAILED: [code=1] libc/src/__support/File/CMakeFiles/libc.src.__support.File.file.dir/file.cpp.o
sccache /usr/bin/clang++ -DLIBC_NAMESPACE=__llvm_libc_22_0_0_git -D_DEBUG -I/Users/runner/work/llvm-project/llvm-project/libc -isystem /Users/runner/work/llvm-project/llvm-project/build/libc/include -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wno-pass-failed -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g -std=gnu++17 -arch arm64 -I /Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_COPT_STRING_LENGTH_IMPL=element -DLIBC_COPT_FIND_FIRST_CHARACTER_IMPL=element -DLIBC_ADD_NULL_CHECKS -DLIBC_ERRNO_MODE=LIBC_ERRNO_MODE_DEFAULT -DLIBC_THREAD_MODE=LIBC_THREAD_MODE_PLATFORM -DLIBC_COPT_RAW_MUTEX_DEFAULT_SPIN_COUNT=100 -fpie -ffixed-point -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -Wdeprecated -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wstrict-prototypes -Wthread-safety -Wglobal-constructors -MD -MT libc/src/__support/File/CMakeFiles/libc.src.__support.File.file.dir/file.cpp.o -MF libc/src/__support/File/CMakeFiles/libc.src.__support.File.file.dir/file.cpp.o.d -o libc/src/__support/File/CMakeFiles/libc.src.__support.File.file.dir/file.cpp.o -c /Users/runner/work/llvm-project/llvm-project/libc/src/__support/File/file.cpp
In file included from /Users/runner/work/llvm-project/llvm-project/libc/src/__support/File/file.cpp:9:
/Users/runner/work/llvm-project/llvm-project/libc/src/__support/File/file.h:260:8: error: expected member name or ';' after declaration specifiers
260 | void clearerr_unlocked() { err = false; }
| ~~~~ ^
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:495:30: note: expanded from macro 'clearerr_unlocked'
495 | #define clearerr_unlocked(p) __sclearerr(p)
| ^
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:383:26: note: expanded from macro '__sclearerr'
383 | #define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
| ^
In file included from /Users/runner/work/llvm-project/llvm-project/libc/src/__support/File/file.cpp:9:
/Users/runner/work/llvm-project/llvm-project/libc/src/__support/File/file.h:260:8: error: expected ')'
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:495:30: note: expanded from macro 'clearerr_unlocked'
495 | #define clearerr_unlocked(p) __sclearerr(p)
| ^
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:383:26: note: expanded from macro '__sclearerr'
383 | #define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
| ^
/Users/runner/work/llvm-project/llvm-project/libc/src/__support/File/file.h:260:8: note: to match this '('
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:495:30: note: expanded from macro 'clearerr_unlocked'
495 | #define clearerr_unlocked(p) __sclearerr(p)
| ^
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:383:25: note: expanded from macro '__sclearerr'
383 | #define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
| ^
In file included from /Users/runner/work/llvm-project/llvm-project/libc/src/__support/File/file.cpp:9:
/Users/runner/work/llvm-project/llvm-project/libc/src/__support/File/file.h:260:8: error: unknown type name '_flags'
260 | void clearerr_unlocked() { err = false; }
| ^
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:495:30: note: expanded from macro 'clearerr_unlocked'
495 | #define clearerr_unlocked(p) __sclearerr(p)
| ^
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:383:37: note: expanded from macro '__sclearerr'
383 | #define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
| ^
In file included from /Users/runner/work/llvm-project/llvm-project/libc/src/__support/File/file.cpp:9:
/Users/runner/work/llvm-project/llvm-project/libc/src/__support/File/file.h:260:8: error: a type specifier is required for all declarations
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:495:30: note: expanded from macro 'clearerr_unlocked'
495 | #define clearerr_unlocked(p) __sclearerr(p)
| ^
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:383:34: note: expanded from macro '__sclearerr'
383 | #define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
| ^
In file included from /Users/runner/work/llvm-project/llvm-project/libc/src/__support/File/file.cpp:9:
/Users/runner/work/llvm-project/llvm-project/libc/src/__support/File/file.h:260:8: error: expected ')'
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:495:30: note: expanded from macro 'clearerr_unlocked'
495 | #define clearerr_unlocked(p) __sclearerr(p)
| ^
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:383:44: note: expanded from macro '__sclearerr'
383 | #define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
| ^
/Users/runner/work/llvm-project/llvm-project/libc/src/__support/File/file.h:260:8: note: to match this '('
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:495:30: note: expanded from macro 'clearerr_unlocked'
495 | #define clearerr_unlocked(p) __sclearerr(p)
| ^
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:383:31: note: expanded from macro '__sclearerr'
383 | #define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
| ^
/Users/runner/work/llvm-project/llvm-project/libc/src/__support/File/file.cpp:426:23: error: out-of-line definition of 'mode_flags' does not match any declaration in '__llvm_libc_22_0_0_git::File'
426 | File::ModeFlags File::mode_flags(const char *mode) {
| ^~~~~~~~~~
6 errors generated.
```
|
|
As discussed in the monthly meeting, update the porting docs to clarify
what's needed for a target and add a policy for sunsetting targets.
|
|
This patch moves abs_timeout and monotonicity out of the linux dir into
common. Both of these functions depend on clock_gettime which is the
actual os-dependent component. As other features in `__support/threads`
may want to use these, it's better to share it in common.
|
|
(#170892)
|
|
fenv_t. (#165015)
|
|
|