| Age | Commit message (Collapse) | Author |
|
These functions should be declared in `stdlib.h`, not `wchar.h`, as
confusing as it is. Move them to the proper header file and matching
directories in src/ and test/ trees.
This was discovered while testing libc++ build against llvm-libc, which
re-declares functions like mbtowc in std-namespace in `<cstdlib>`
header, and then uses those functions in its locale implementation.
|
|
Reverts llvm/llvm-project#166355
|
|
_Exit(3) is a fairly simple syscall wrapper whereas exit(3) calls
atexit-registered functions + whole lot of stuff that require support
for sync primitives.
Splitting the tests allows testing the former easily (especially for new
port projects)
---------
Signed-off-by: Shreeyash Pandey <shreeyash335@gmail.com>
|
|
Looks like https://github.com/llvm/llvm-project/pull/166517 is breaking
libc-riscv32-qemu-yocto-fullbuild-dbg build due to failing overflow test
for strfrom.
https://lab.llvm.org/buildbot/#/changes/58668
```
int result = func(buff, sizeof(buff), "%.2147483647f", 1.0f);
EXPECT_LT(result, 0);
ASSERT_ERRNO_FAILURE();
```
```
[ RUN ] LlvmLibcStrfromdTest.CharsWrittenOverflow
/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/src/stdlib/StrfromTest.h:493: FAILURE
Expected: result
Which is: 0
To be less than: 0
Which is: 0
/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/src/stdlib/StrfromTest.h:494: FAILURE
Expected: 0
Which is: 0
To be not equal to: static_cast<int>(libc_errno)
Which is: 0
[ FAILED ] LlvmLibcStrfromdTest.CharsWrittenOverflow
Ran 8 tests. PASS: 7 FAIL: 1
```
At first glance it seem like there is some kind of overflow in
internal::strfromfloat_convert on 32bit archs because the other overflow
test case is passing for snprintf. Interestingly, it passes on all other
buildbots, including libc-arm32-qemu-debian-dbg.
This issue likely wasn't introduced by
https://github.com/llvm/llvm-project/pull/166517 and was probably
already present, so I'm not reverting the change just disabling the test
case on riscv32 until I can debug properly.
|
|
https://github.com/llvm/llvm-project/issues/159474
Another try of trying to land
https://github.com/llvm/llvm-project/pull/166382
- Fix some leftover tests checking for specific errnos
- Guard errno checking tests to not run on the GPU
@michaelrj-google
|
|
(#166225)
Functions like isalpha / tolower can operate on chars internally. This
allows us to get rid of unnecessary casts and open a way to creating
wchar_t overloads with the same names (e.g. for isalpha), that would
simplify templated code for conversion functions (see
315dfe5865962d8a3d60e21d1fffce5214fe54ef).
Add the int->char converstion to public entrypoints implementation
instead. We also need to introduce bounds check on the input argument
values - these functions' behavior is unspecified if the argument is
neither EOF nor fits in "unsigned char" range, but the tests we've had
verified that they always return false for small negative values. To
preserve this behavior, cover it explicitly.
|
|
|
|
https://github.com/llvm/llvm-project/issues/159474
Resubmitting https://github.com/llvm/llvm-project/pull/162876 with fixes
as it broke some buildbots:
- Fix comparisons of integer expressions of different signedness
- Not check for specific errnos in tests, as they might not be available
on all platforms
|
|
|
|
[#159474](https://github.com/llvm/llvm-project/issues/159474)
- All printf variants set errno and consistently return -1 on error,
instead of returning various predefined error codes
- Return value overflow handling is added
|
|
RE apply https://github.com/llvm/llvm-project/pull/133643/commits#top
|
|
Tests can be at top-level or inside an anonymous namespace,
doesn't matter. But putting their helper code inside anonymous
namespaces both makes the code compatible with compiling using
-Wmissing-declarations and might let the compiler optimize the
test good a bit better.
|
|
Reverts llvm/llvm-project#133643
|
|
* Relates to: https://github.com/llvm/llvm-project/issues/119281
|
|
<stdint.h> includes. (#150303)
https://github.com/llvm/llvm-project/issues/149993
|
|
This reverts commit 92a116c4ef822950f8c57eaa5164c844c73a1f7e with a fix
for fgets test - convert nullptr to fgets return type (char*), since the
matcher is pedantic.
|
|
(#144129)
Reverts llvm/llvm-project#143972 - matcher seems to be pedantic for
fgets tests, reverting to verify and fix.
|
|
This reverts commit a93e55e57ed00a55f822c64e3520c7c732b58480 and fixes
build and test failures:
* Proper include added to setvbuf_test.cpp
* fgetc/fgetc_unlocked/fgets tests are ported to ErrnoSetterMatcher and
are made more precise. This fixes inconsistencies between expectations
in regular and GPU builds - ErrnoSetterMatcher is configured to omit
errno matching on GPUs, as fgetc implementation on GPU doesn't set
errno, in contrast to Linux.
|
|
Reverts llvm/llvm-project#143802. Follow-up fix
3c7af175e51c3ab08ac3c442146c2b822f38c01e wasn't robust enough and itself
got reverted.
|
|
Reduce the direct use of libc_errno in stdio unit tests by adopting
ErrnoCheckingTest where appropriate.
Also removes the libc_errno.h inclusions from stdlib.h tests that were
accidentally added in d87eea35fac5a34a841c637db8908128409a184e
|
|
LIBC_ERRNO_MODE_SYSTEM to be header-only. (#143187)
This is the first step 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
|
|
(#143767)
* Get rid of libc_errno assignments in str_to_* __support tests, since
those API have been migrated to return error in a struct instead.
* Migrate tests for atof and to strto* functions from <stdlib.h> and for
strdup from <string.h> to use ErrnoCheckingTest harness.
|
|
Summary:
This is the big patch that implements an efficient device-side `malloc`
on the GPU. This is the first pass and many improvements will be made
later.
The scheme revolves around using a global reference counted pointer to
hand out access to a dynamically created and destroyed slab interface.
The slab is simply a large bitfield with one bit for each slab. All
allocations are the same size in a slab, so different sized allocations
are done through different slabs.
Allocation is thus searching for or creating a slab for the desired
slab, reserving space, and then searching for a free bit. Freeing is
clearing the bit and then releasing the space.
This interface allows memory to dynamically grow and shrink. Future
patches will have different modes to allow fast first-time-use as well
as a non-RPC version.
|
|
This patch adds the `memalignment` function to LLVM-libc, following its
description in [WG14 N3220,
§7.24.2.1](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf#page=387).
- [x] Add the implementation of `memalignment` in
[`/src/stdlib`](https://github.com/llvm/llvm-project/tree/main/libc/src/stdlib)
- [x] Add tests for `memalignment` in
[`/test/src/stdlib`](https://github.com/llvm/llvm-project/tree/main/libc/test/src/stdlib)
- [x] Add `memalignment` to
[`entrypoints.txt`](https://github.com/llvm/llvm-project/blob/main/libc/config/linux/x86_64/entrypoints.txt)
for at least x86_64 and whatever you're building on
- [x] Add `memalignment` to
[`include/stdlib.yaml`](https://github.com/llvm/llvm-project/blob/main/libc/include/stdlib.yaml)
Closes #132300
---------
Co-authored-by: Joseph Huber <huberjn@outlook.com>
|
|
|
|
* strcpy doesn't need to depend on memcpy
* qsort_test_helper has been generalized and doesn't need to depend on
qsort.
This is a small cleanup to unblock the work outlined in #130327.
|
|
Adds l64a, which generates the base 64 string expected by a64l.
|
|
Implement the posix function a64l.
Standard:
https://pubs.opengroup.org/onlinepubs/9799919799/functions/a64l.html
|
|
The existing options for bin→dec float conversion are all based on the
Ryū algorithm, which generates 9 output digits at a time using a table
lookup. For users who can't afford the space cost of the table, the
table-lookup subroutine is replaced with one that computes the needed
table entry on demand, but the algorithm is otherwise unmodified.
The performance problem with computing table entries on demand is that
now you need to calculate a power of 10 for each 9 digits you output.
But if you're calculating a custom power of 10 anyway, it's easier to
just compute one, and multiply the _whole_ mantissa by it.
This patch adds a header file alongside `float_dec_converter.h`, which
replaces the whole Ryū system instead of just the table-lookup routine,
implementing this alternative simpler algorithm. The result is accurate
enough to satisfy (minimally) the accuracy demands of IEEE 754-2019 even
in 128-bit long double. The new float128 test cases demonstrate this by
testing the cases closest to the 39-digit rounding boundary.
In my tests of generating 39 output digits (the maximum number supported
by this algorithm) this code is also both faster and smaller than the
USE_DYADIC_FLOAT version of the existing Ryū code.
|
|
Summary:
This is a blocker on another patch in the OpenMP runtime. The problem is
that NVIDIA truly doesn't handle RPC-based allocations very well. It
cannot reliably update the MMU while a kernel is running and it will
usually deadlock if called from a separate thread due to internal use of
TLS.
This patch just removes the definition of `malloc` and `free` for NVPTX.
The result here is that they will be undefined, which is the cue for the
`nvlink` linker to define them for us. So, as far as `libc` is concerned
it still implements malloc.
|
|
Summary:
This test uses too much stack and crashes, make the buffer `static` to
push it to `.bss`. This shouldn't change behavior because the tests are
all run single threaded.
|
|
Fix the build problem at
https://lab.llvm.org/buildbot/#/builders/131/builds/13255
|
|
|
|
Reverts llvm/llvm-project#120450
|
|
|
|
This better matches the structure we use for the rest of libc.
|
|
The a0c4f854cad2b97e44a1b58dc1fd982e1c4d60f3 change replaced the
local int_to_b36_char function returning `char` with uses of the
__support function of the same name that returns `int`. The uses
of the old local function lacked the casts that all other uses of
the shared function of the same name had. Add them.
|
|
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.
|
|
`long double` is haunted on most architectures, but it is especially so on
i386-linux-gnu. While have 80b of significant data, on i386-linux-gnu this type
has 96b of storage.
Fixes for supporting printf family of conversions for `long double` on
i386-linux-gnu. This allows the libc-stdlib-tests and libc_stdio_unittests
ninja target tests to pass on i386-linux-gnu.
Fixes: #110894
Link: #93709
Co-authored-by: Michael Jones <michaelrj@google.com>
|
|
`atexit_test.cpp` (#115351)
Hello, I merged this https://github.com/llvm/llvm-project/pull/114904 a
few mins ago and the tests failed because i did not add the header
`src/stdlib/_Exit.h` in `at_quick_exit_test.cpp` and `atexit_test.cpp`.
I ran both builds/tests and everything was good. thanks
|
|
(#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`
|
|
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`.
|
|
|
|
Dyadic floats were an existing option for float to string conversion,
but it had become stale. This patch fixes it up as well as adding proper
config options and test support. Due to the test changes this is a
followup to #110759
|
|
The C standard specifies
n-char-sequence:
digit
nondigit
n-char-sequence digit
n-char-sequence nondigit
nondigit is specified as one of:
_ a b c d e f g h i j k l m
n o p q r s t u v w x y z
A B C D E F G H I J K L M
N O P Q R S T U V W X Y Z
This means nondigit includes the underscore character. This patch
clarifies this status in the comments and the test.
Note C17 specifies n-char-sequence for NaN() as optional, and an empty
sequence is not a valid n-char-sequence. However the current comment has
the same effect as using the pedantic wording. So I left that part
unchanged.
|
|
|
|
This is a part of #97655.
|
|
declaration" (#98593)
Reverts llvm/llvm-project#98075
bots are broken
|
|
This is a part of #97655.
|
|
Summary:
Currently, we implement the `rand` function using thread-local storage.
This is somewhat problematic because not every target supports TLS, and
even more do not support non-zero initializers on TLS.
The C standard states that the `rand()` function need not be thread,
safe. However, many implementations provide thread-safety anyway.
There's some confusing language in the 'rationale' section of
https://pubs.opengroup.org/onlinepubs/9699919799/functions/rand.html,
but given that `glibc` uses a lock, I think we should make this thread
safe as well. it mentions that threaded behavior is desirable and can be
done in the two ways:
1. A single per-process sequence of pseudo-random numbers that is shared
by all threads that call rand()
2. A different sequence of pseudo-random numbers for each thread that
calls rand()
The current implementation is (2.) and this patch moves it to (1.). This
is beneficial for the GPU case and more generic support. The downside is
that it's slightly slower to do these atomic operations, the fast path
will be two atomic reads and an atomic write.
|