3477 Commits

Author SHA1 Message Date
Joseph Huber
0ca0d55c14 [libc] Fix 'float type' incorrectly being used as the return type 2024-08-14 12:56:52 -05:00
OverMighty
80c5ccd867
[libc][math] Fix missing const in hdrgen signatures for totalordermag* (#103935) 2024-08-14 17:00:26 +02:00
wldfngrs
f53e355063
[libc] Add definitions for totalordermag(,f, l, f128), dsqrt(l, f128), fsqrt(, l, f128) to math.yaml. (#103494)
Added auto function hdrgen specification for functions:  totalordermag(,f, l, f128), dsqrt(l, f128), fsqrt(, l, f128)
2024-08-14 08:22:15 -04:00
Joseph Huber
101acff2e5
[libc] Define 'size_t' in time.h and uchar.h (#103441)
Summary:
The standard says the following: The <time.h> header shall define the
clock_t, size_t, time_t, types as described in <sys/types.h>. I couldn't
find one for `uchar.h` but it needs it once we define things like
`mbrtoc8`.
2024-08-13 16:02:43 -05:00
Joseph Huber
6cd37eb5de
[libc] Fix INFINITY being defined as a double (#103445)
Summary:
If the implementation supports floating-point infinities, the macro
INFINITY expands to constant expression of type float which evaluates to
positive or unsigned infinity.

Currently this is a double, this makes it a float.
2024-08-13 16:02:18 -05:00
OverMighty
b4c4c799ab
[libc][math] Fix missing LIBC_INLINE on exp_range_reduction() function (#103305)
See Buildbot failure:
https://lab.llvm.org/buildbot/#/builders/73/builds/3669.
2024-08-13 18:26:36 +02:00
Schrodinger ZHU Yifan
4371c79d45
[libc] Reapply ELF/LINK header changes (#102765)
This is based on @izaakschroeder previous patch but I only select macro
definitions for now. We need these definitions for VDSO work, which has
been delayed for a very long time.

Co-authored-by: Izaak Schroeder <izaak.schroeder@gmail.com>
2024-08-13 08:20:37 -07:00
OverMighty
560ed8ce3d
[libc][math][c23] Add expm1f16 C23 math function (#102387)
Part of #95250.
2024-08-13 16:48:28 +02:00
Joseph Huber
0889809c70
[libc] Fix warning on 'extern "C" int main' in test suite (#102973)
Summary:
According to the C++ standard, The main function shall not be declared
with a linkage-specification. after some changes in
https://github.com/llvm/llvm-project/pull/101853 this started emitting
warnings when building / testing the C library. This source file is
shared with the overlay tests as well as the full build tests. The full
build tests are compiled with `-ffreestanding`, as are all the startup /
integration files. The standard says freestanding environment are all
implementation defined, so this is valid in those cases. This patch
simply prevents adding the linkage when we are compiling unit tests,
which are hosted. This is a continuation on
https://github.com/llvm/llvm-project/pull/102825.
2024-08-12 17:57:16 -05:00
Joseph Huber
ee5d572718 [libc] Undo accidental changes to dsubl that were leftoever 2024-08-12 13:16:38 -05:00
Joseph Huber
dc2f39e96c
[libc] Enable all supported math functions on the GPU (#102563)
Summary:
Simply copies the x64 versions to the GPU directory. Ignoring f128 for
now, but adding long double entrypoints which are identical to `double`
on the target.
2024-08-12 13:12:44 -05:00
Mark de Wever
1cbd25f882
[NFC][libc] Clarifies underscores in n-char-sequence. (#102193)
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.
2024-08-12 18:59:24 +02:00
Schrodinger ZHU Yifan
b7c7dbd473
Revert "libc: Remove extern "C" from main declarations" (#102827)
Reverts llvm/llvm-project#102825
2024-08-11 13:40:50 -07:00
David Blaikie
1b71c471c7
libc: Remove extern "C" from main declarations (#102825)
This is invalid in C++, and clang recently started warning on it as of
#101853
2024-08-11 13:17:27 -07:00
Joseph Huber
59f7a80618 [libc] Fix scablnf16 using float16 instead of _Float16 2024-08-10 07:48:54 -05:00
RoseZhang03
1d8d5d6529
[libc] Moved range_reduction_double ifdef statement (#102659)
Sin/cos/tan fuzzers were having issues with ONE_TWENTY_EIGHT_OVER_PI, so
the LIBC_TARGET_CPU_HAS_FMA ifdef statement got moved from the
sin/cos/tan .cpp files to the range_reduction_double_common.cpp file.
2024-08-09 23:04:29 +00:00
Michael Jones
7299c7f654
[libc] Fix CFP long double and add tests (#102660)
The previous patch removing the fenv requirement for str to float had an
error that got missed due to a lack of tests. This patch fixes the issue
and adds tests, as well as updating the existing tests.
2024-08-09 19:53:17 -03:00
Roland McGrath
6e8a751ef1
[libc] Clean up remaining use of *_WIDTH macros in printf (#102679)
The previous change missed the second spot doing the same thing.

Bug: https://issues.fuchsia.dev/358196552
2024-08-09 13:46:49 -07:00
Roland McGrath
a21cf5663c
[libc] Fix use of cpp::numeric_limits<...>::digits (#102674)
The previous change replaced INT_WIDTH with
cpp::numberic_limits<int>::digits, but these don't have the same
value.  While INT_WIDTH == UINT_WIDTH, not so for ::digits, so
use cpp::numberic_limits<unsigned int>::digits et al instead for
the intended effects.

Bug: https://issues.fuchsia.dev/358196552
2024-08-09 13:09:23 -07:00
Roland McGrath
2f6a879790
[libc] Use cpp::numeric_limits in preference to C23 <limits.h> macros (#102665)
This updates some code to consistently use cpp::numeric_limits,
the src/__support polyfill for std::numeric_limits, rather than
the C <limits.h> macros.  This is in keeping with the general
C++-oriented style in libc code, and also sidesteps issues about
the new C23 *_WIDTH macros that the compiler-provided header does
not define outside C23 mode.

Bug: https://issues.fuchsia.dev/358196552
2024-08-09 12:44:40 -07:00
aaryanshukla
b6cbd014b9
[libc][newhdrgen]sorted function names in yaml (#102544) 2024-08-09 11:27:36 -07:00
aaryanshukla
8c81fb6167
[libc][math][c23] Add fadd{l,f128} C23 math functions (#102531)
Co-authored-by: OverMighty <its.overmighty@gmail.com>
2024-08-09 10:26:09 -07:00
Job Henandez Lara
ff1cc5b97c
[libc][math][c23] Add totalorderl function. (#102564) 2024-08-09 10:18:00 -04:00
Job Henandez Lara
9788368c37
[libc][math][c23] Fix setpayloadsig smoke test on RV32 (#102538) 2024-08-08 21:58:59 -03:00
Michael Jones
d851b5c12c
[libc] Make str_to_float independent of fenv (#102369)
The str_to_float conversion code doesn't need the features provided by
fenv and the dependency is creating a blocker for hand-in-hand. This
patch uses a workaround to remove this dependency.
2024-08-08 14:39:07 -07:00
aaryanshukla
d0fe470fd2
[libc][math] Add scalbln{,f,l,f128} math functions (#102219)
Co-authored-by: OverMighty <its.overmighty@gmail.com>
2024-08-08 14:33:50 -07:00
jameshu15869
2b592b16c1
[libc][gpu] Add Sinf Benchmarks (#102532)
This PR adds benchmarking for `sinf()` using the same set up as `sin()`
but with a smaller range for floats.
2024-08-08 16:26:26 -05:00
jameshu15869
1248698e9b
[libc] [gpu] Fix Minor Benchmark UI Issues (#102529)
Previously, `AmdgpuSinTwoPow_128` and others were too large for their
table cells. This PR shortens the name to `AmdSin...`

There were also some `-` missing in the separator. This PR instead
creates the separator string using the length of the headers.
2024-08-08 15:32:20 -05:00
aaryanshukla
86cf67ffc1
[libc][newhdrgen] add_function by alphabetical order (#102527)
- add_function now adds the function by alphabetical order
2024-08-08 13:26:45 -07:00
jameshu15869
9a070d6d0f
[libc] [gpu] Add Generic, NvSin, and OcmlSinf64 Throughput Benchmark (#101917)
This PR implements
2a158426d4
to provide better throughput benchmarking for libc `sin()` and
`__nv_sin()`.

These changes have not been tested on AMDGPU yet, only compiled.
2024-08-08 15:05:34 -05:00
lntue
eddfd504f8
[libc][math][c23] Add ddivl C23 math function. (#102468) 2024-08-08 11:41:17 -04:00
Simon Tatham
722c066c59
[libc] Make use of 32-bit time_t a config option (#102012)
The 32-bit Arm builds of libc define time_t to be `__INTPTR_TYPE__`,
i.e. a 32-bit integer. This is commented in the commit introducing it
(75398f28ebdb600) as being for compatibility with glibc. But in the near
future not even every AArch32 build of glibc will have a 32-bit time_t:
Debian is planning that their next release (trixie) will have switched
to 64-bit. And non-Linux builds of this libc (e.g. baremetal) have no
reason to need glibc compatibility in the first place – and every reason
_not_ to want to start using a 32-bit time_t in 2024 or later.

So I've replaced the `#ifdef` in `llvm-libc-types/time_t.h` with two
versions of the header file, chosen in `CMakeLists.txt` via a new
configuration option. This involved adding an extra parameter to the
cmake `add_header` function to specify different names for the header
file in the source and destination directories.
2024-08-08 16:36:05 +01:00
Joseph Huber
1a92cc5a0a
[libc] Implement 'getenv' on the GPU target (#102376)
Summary:
This patch implements 'getenv'. I was torn on how to implement this,
since realistically we only have access to this environment pointer in
the "loader" interface. An alternative would be to use an RPC call every
time, but I think that's overkill for what this will be used for. A
better solution is just to emit a common `DataEnvironment` that contains
all of the host visible resources to initialize. Right now this is the
`env_ptr`, `clock_freq`, and `rpc_client`.

I did this by making the `app.h` interface that Linux uses more general,
could possibly move that into a separate patch, but I figured it's
easier to see with the usage.
2024-08-08 06:45:42 -05:00
Job Henandez Lara
bb4f9c6ad4
[libc][math] fix yaml indentation bug (#102421) 2024-08-08 00:35:49 -04:00
Job Henandez Lara
aae7c38827
[libc][math][c23] Add entrypoints and tests for setpayloadsig{,f,l,f128} and setpayloadl. (#102413) 2024-08-08 00:17:20 -04:00
Joseph Huber
cf416e0a1b
[libc] Use proxy headers for limits.h values (#102378)
Summary:
This defines some constants that may conflict with the system when in
overlay mode. Use the proxy header instead.

Fixes: https://github.com/llvm/llvm-project/issues/102368
2024-08-07 17:01:28 -05:00
aaryanshukla
3210bce90f
[libc][math] updated functionspec subf128 (#102372) 2024-08-07 14:29:08 -07:00
Sylvestre Ledru
0ac9a65900 libc: remove trailing whitespaces 2024-08-07 23:23:39 +02:00
RoseZhang03
2d95dee0c0
[libc] math fuzzing MPFR include statement (#102358)
Updated the include statement for MPFR
2024-08-07 21:12:40 +00:00
aaryanshukla
4974257bad
[libc][math] fixing build broke for remainderf128 (#102362) 2024-08-07 13:16:00 -07:00
aaryanshukla
2c74237c0f
[libc][math][c23] Add fsub{,l,f128} and remainderf128 C23 math functions (#101576)
Co-authored-by: OverMighty <its.overmighty@gmail.com>
2024-08-07 13:03:58 -07:00
Joseph Huber
f126bc984c [libc] Fix conflict values from internal limits.h when used externally 2024-08-07 10:09:02 -05:00
Joseph Huber
06a808c4f4 [libc] Fix bot accidentally picking up conflicting MB_LEN_MAX 2024-08-07 09:19:53 -05:00
OverMighty
59338ad8c5
[libc][math][c23] Add exp10f16 C23 math function (#101588)
Part of #95250.
2024-08-07 15:54:06 +02:00
Joseph Huber
3645ca58f4
[libc] Enable quick_exit routines on the GPU (#102242)
Summary:
We should be able to use these on the GPU just like exit.
2024-08-07 08:01:11 -05:00
Joseph Huber
3c391a640d
[libc] Add *_HAS_SUBNORM to float.h (#102182)
Summary:
These should be defined, since we provide `float.h` it will override the
Clang resource dir and not provide it.
2024-08-07 08:00:43 -05:00
Joseph Huber
b209eda621
[libc] Define MB_LEN_MAX in limits.h (#102246)
Summary:
This is supposed to define the maximum bytes required to store a char in
any locale. There's some question about what this should be set to. I
believe because the proposed solution for `locale.h` is to only support
the default locale, we should do what `musl` does and set it to `4`
which covers up to UTF-32.

Fixes https://github.com/llvm/llvm-project/issues/79358
2024-08-07 07:59:44 -05:00
Job Henandez Lara
e3778a5d0e
[libc][math] Add getpayloadl function. (#102214) 2024-08-07 08:27:45 -04:00
Simon Tatham
efd71d9213
[libc] Allow time conversions to compile on bare metal (#102014)
The `<time.h>` functions `asctime`, `gmtime`, `mktime` and their `_r`
variants are purely computational functions which convert between well
defined time representations and/or strings. There's no reason these
shouldn't be available in bare-metal builds of the library as well as
hosted ones: even if the library has no way to find out the time in
POSIX format, it might still see POSIX-style `time_t` values in input
data (e.g. network protocols) and need to interpret them.

The only obstacle to this was that the `out_of_range()` helper function
set `errno` to `EOVERFLOW`, which fails in a bare-metal build because
the extra POSIX error values aren't defined, including `EOVERFLOW`. So
I've made that assignment conditional on `EOVERFLOW` being defined.

Fixes #85556.
2024-08-07 09:11:31 +01:00
Schrodinger ZHU Yifan
03841e7ab8
[libc] add spin lock family functions (#100509)
This PR:
- add entrypoints for `pthread_spin_*`
- additionally, the fixes a typo that has been disabling lock related
tests
2024-08-06 21:02:54 -07:00