Commit Graph

617 Commits

Author SHA1 Message Date
Зишан Мирза
000a3f0a54 [libc][c11] implement ctime (#107285)
This is an implementation of `ctime` and includes `ctime_r`.

According to documentation, `ctime` and `ctime_r` are defined as the
following:

```c
char *ctime(const time_t *timep);
char *ctime_r(const time_t *restrict timep, char buf[restrict 26]);
```

closes #86567
2024-09-16 11:27:11 -07:00
Joseph Huber
5c019bdb7a [libc] Add support for 'string.h' locale variants (#105719)
Summary:
This adds the locale variants of the string functions. As previously,
these do not use the locale information at all and simply copy the
non-locale version which expects the "C" locale.
2024-08-29 14:20:15 -05:00
Joseph Huber
a87105121d [libc] Implement locale variants for 'stdlib.h' functions (#105718)
Summary:
This provides the `_l` variants for the `stdlib.h` functions. These are
just copies of the same entrypoint and don't do anything with the locale
information.
2024-08-29 14:18:37 -05:00
Joseph Huber
b8f134faba [libc] Implement 'vfscanf' and 'vscanf' (#105293)
Summary:
These are simply forwarding the vlist to the existing helper.
2024-08-26 09:00:10 -05:00
Joseph Huber
856dadb33c [libc] Add ctype.h locale variants (#102711)
Summary:
This patch adds all the libc ctype variants. These ignore the locale
ingormation completely, so they're pretty much just stubs. Because these
use locale information, which is system scope, we do not enable building
them outisde of full build mode.
2024-08-22 13:51:54 -05:00
Joseph Huber
78d8ab2ab9 [libc] Initial support for 'locale.h' in the LLVM libc (#102689)
Summary:
This patch adds the macros and entrypoints associated with the
`locale.h` entrypoints.  These are mostly stubs, as we (for now and the
forseeable future) only expect to support the C and maybe C.UTF-8
locales in the LLVM libc.
2024-08-22 12:58:46 -05:00
Joseph Huber
2f4232db0b Revert " [libc] Add ctype.h locale variants (#102711)"
This reverts commit 8f005f8306.
2024-08-22 12:45:16 -05:00
Joseph Huber
8f005f8306 [libc] Add ctype.h locale variants (#102711)
Summary:
This patch adds all the libc ctype variants. These ignore the locale
ingormation completely, so they're pretty much just stubs. Because these
use locale information, which is system scope, we do not enable building
them outisde of full build mode.
2024-08-22 12:41:20 -05: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
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
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
lntue
eddfd504f8 [libc][math][c23] Add ddivl C23 math function. (#102468) 2024-08-08 11:41:17 -04: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
aae7c38827 [libc][math][c23] Add entrypoints and tests for setpayloadsig{,f,l,f128} and setpayloadl. (#102413) 2024-08-08 00:17:20 -04:00
Sylvestre Ledru
0ac9a65900 libc: remove trailing whitespaces 2024-08-07 23:23:39 +02: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
OverMighty
59338ad8c5 [libc][math][c23] Add exp10f16 C23 math function (#101588)
Part of #95250.
2024-08-07 15:54:06 +02:00
Job Henandez Lara
e3778a5d0e [libc][math] Add getpayloadl function. (#102214) 2024-08-07 08:27:45 -04: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
aaryanshukla
0395bf7636 [libc][math][c23] Add ffma{,l,f128} and fdiv{,l,f128} C23 math functions #101089 (#101253)
- added all variations of ffma and fdiv 
- will add all new headers into yaml  for next patch 
- only fsub is left then all basic operations for float is complete

---------

Co-authored-by: OverMighty <its.overmighty@gmail.com>
2024-08-06 10:19:54 -07:00
Mikhail R. Gadelha
92a01683cb [libc] Enable more entrypoints for riscv (#102055)
This patch enables more entrypoints for riscv. The changes to the test cases are introduced to support rv32 which has long double but doesn't have int128
2024-08-06 12:16:40 -03:00
OverMighty
936515c7a5 [libc][math][c23] Add exp2f16 C23 math function (#101217)
Part of #95250.
2024-08-06 14:44:01 +02:00
lntue
9f6b440adf [libc][math] Implement fast pass for double precision pow function with up to 1ULP error. (#101926) 2024-08-05 13:08:59 -04:00
Schrodinger ZHU Yifan
b024fd267b [libc] disable strfroml entrypoint on aarch64 (#101854)
Disable `strfroml` entrypoint on aarch64 to please clang-11 buildbots.
Detailed in https://github.com/llvm/llvm-project/issues/101846. This is
not a fix for #101846 so I will keep the issue open until our buildbot
is updated or other mitigation is applied.
2024-08-03 22:28:13 -04:00
Schrodinger ZHU Yifan
8252d4d468 [libc] enable most of the entrypoints on aarch64 (#101797)
This is a non-feature change that enables most of the entrypoints for
aarch64 based runtime builds. It fixes an additional problem that some
compiler-rt targets are not defined at the time of dependency checking
thus leading to false-negatives.
2024-08-03 12:22:38 -07:00
Schrodinger ZHU Yifan
301db3dee5 [libc] add simplified tid cache (#101620)
According to discussions on monthly meeting, we probably don't want to
cache `getpid` anymore. glibc removes their cache. bionic is hesitating
whether such cache is to be removed. `getpid` is async-signal-safe, so
we must make sure it always work.

However, for `gettid`, we have more freedom. Moreover, we are using
`gettid` to examine deadlock such that the performance penalty is not
negligible here. Thus, this patch is separated from previous patch to
provide only `tid` caching. It is much more simplified. Hopefully,
previous build issues can be resolved easily.
2024-08-02 10:27:49 -07:00
aaryanshukla
7471387b3d [libc][math][C23] removing daddl from arm32 (#101567) 2024-08-01 15:08:45 -07:00
aaryanshukla
8f33f1d829 [libc][math][c23] Add dadd{l,f128} and ddiv{l,f128} C23 math functions (#100456)
- fadd removed because I need to add for different input types
- finishing rest of basic operations
- noticed duplicates will remove

---------

Co-authored-by: OverMighty <its.overmighty@gmail.com>
2024-08-01 13:36:50 -07:00
Tsz Chan
a5e67fba8a [libc] Implement vasprintf and asprintf (#98824)
[libc] Implement vasprintf and asprintf

---------

Co-authored-by: Izaak Schroeder <izaak.schroeder@gmail.com>
2024-08-01 11:52:36 -05:00
Job Henandez Lara
ed12f80ff0 [libc][math][c23] add entrypoints and tests for getpayload{,f,f128} (#101285) 2024-07-31 23:16:42 -04:00
aaryanshukla
74f9579443 [libc][math][c23] removed dsubl for 32 arm (#101423) 2024-07-31 15:24:08 -07:00
Joseph Huber
38ef6929a3 [libc] Add vsscanf function (#101402)
Summary:
Adds support for the `vsscanf` function similar to `sscanf`.
Based off of https://github.com/llvm/llvm-project/pull/97529.
2024-07-31 16:53:25 -05:00
aaryanshukla
30b5d4a763 [libc][math][c23] Add dfma{l,f128} and dsub{l,f128} C23 math functions (#101089)
Co-authored-by: OverMighty <its.overmighty@gmail.com>
2024-07-31 13:07:03 -07:00
Simon Tatham
2a6268d8f9 [libc][AArch64] Add an AArch64 setjmp/longjmp. (#101177)
Previously, building libc for AArch64 in `LLVM_LIBC_FULL_BUILD` mode
would fail because no implementation of setjmp/longjmp was available.
This was the only obstacle, so now a full AArch64 build of libc is
possible.

This implementation automatically supports PAC and BTI if compiled with
the appropriate options. I would have liked to do the same for MTE stack
tagging, but as far as I can see there's currently no predefined macro
that allows detection of `-fsanitize=memtag-stack`, so I've left that
one as a TODO.

AAPCS64 delegates the x18 register to individual platform ABIs, and
allows them to choose what it's used for, which may or may not require
setjmp and longjmp to save and restore it. To accommodate this, I've
introduced a libc configuration option. The default is on, because the
only use of x18 I've so far encountered uses it to store information
specific to the current stack frame (so longjmp does need to restore
it), and this is also safe behavior in the default situation where the
platform ABI specifies no use of x18 and it becomes a temporary register
(restoring it to its previous value is no worse than any _other_ way for
a function call to clobber it). But if a platform ABI needs to use x18
in a way that requires longjmp to leave it alone, they can turn the
option off.
2024-07-31 09:09:52 -07:00
Job Henandez Lara
546e4a210c [libc][math][c23] Add entrypoints and tests for setpayload{,f,f128} (#101122) 2024-07-30 19:52:47 -04:00
Job Henandez Lara
0813260aa8 [libc][math][c23] Add entrypoints and tests for totalorder{,f,f128} (#100593) 2024-07-30 18:58:44 +02:00
OverMighty
c3f7f2886b [libc][math][c23] Temporarily disable expf16 on AArch64 (#101203)
See Buildbot failure:
https://lab.llvm.org/buildbot/#/builders/104/builds/3378.
2024-07-30 18:48:01 +02:00
OverMighty
971a1ac445 [libc][math][c23] Add expf16 C23 math function (#100632)
Part of #95250.
2024-07-30 18:38:03 +02:00
Schrodinger ZHU Yifan
64199bf332 [libc] make aarch64 libm entrypoints consistent w/ x86-64 (#100963)
Test passes locally.
2024-07-29 08:18:29 -07:00
Eric977
44df89cc30 [libc] add pthread_rwlock_clockrdlock and pthread_rwlock_clockwrlock … (#100543) 2024-07-28 11:58:09 -07:00
Schrodinger ZHU Yifan
3db5c1eeb0 revert all tid changes (#100915) 2024-07-27 22:29:21 -07:00
lntue
ca8b14de51 [libc][math] Implement fast pass for double precision atan2 with 1 ULP errors. (#100648) 2024-07-26 09:56:46 -04:00
Job Henandez Lara
7b51777ed8 [libc][math][c23] add entrypoints and tests for totalordermag{f,l,f128} (#100159)
Fixes https://github.com/llvm/llvm-project/issues/100139
2024-07-24 19:53:23 -04:00
Mikhail R. Gadelha
6c23f974d6 [libc] Enable bind test for riscv (#100132)
The bind test was failing in the rv32 build bot because of how the build bot was set to run the tests: we were using shared directories between the host and qemu and the bind function was trying to create a file in this directory, thus creating it in the host machine.

The OS was returning "-1 ENXIO (No such device or address)", so we changed the rv32 buildbot to copy the binaries to qemu and dropped the shared directories feature.
2024-07-24 11:26:15 -03:00
Michael Jones
173514ff12 [libc] Disable epoll_pwait2 for now. (#99967)
This patch reverts #99781 and part of #99771 since `epoll_pwait2` is not
in fact available on all supported systems. It is my opinion that we
shouldn't provide a version of a function that doesn't perform as
expected, which is why this revert needs to happen.

The `epoll_pwait2` function can be reenabled when we have a way to check
if it is available on the target system, tracking bug for that is #80060
2024-07-22 15:34:24 -07:00
Mikhail R. Gadelha
28e6095082 [libc] Add working entrypoints to riscv (#99885)
Added new fsqrt entrypoints and updated headers.txt, which I missed in PR #99771
2024-07-22 12:06:28 -03:00
Mikhail R. Gadelha
eaa07c00b1 [libc] Fix statvfs test case when SYS_statfs64 is used (#99827)
When SYS_statfs64 is used, struct statfs64 is used instead of struct statfs. This patch adds a define to select the appropriate struct, similar to how it's done internally.

This patch also enables fstatvfs and statvfs on riscv, which would not be compiled without this change.
2024-07-21 21:21:05 -03:00
lntue
74a1ca504b [libc][math] Update getpayload and fmul/fadd/fsub/ffma with NaN inputs. (#99812) 2024-07-21 19:27:06 -04:00