347 Commits

Author SHA1 Message Date
OverMighty
0eb9e021b1
[libc][math][c23] Add fabsf16 C23 math function (#93567)
cc @lntue
2024-05-30 15:37:15 -04:00
Hendrik Hübner
485f9f5895
Reland: [libc][POSIX][pthreads] implemented missing pthread_rwlockattr functions (#93622)
New pull request for https://github.com/llvm/llvm-project/issues/89443

The previous PR was reverted after breaking fullbuild due to a missing
struct declaration, which I forgot to commit.

Reverts revert and adds the missing pthread_rwlockattr_getkind_np /
pthread_rwlockattr_setkind_np functions and tests respecitvely.
2024-05-30 11:27:50 -07:00
Schrodinger ZHU Yifan
27595c4bef
Revert "[libc][POSIX][pthreads] implemented missing pthread_rwlockattr functions" (#91966)
Reverts llvm/llvm-project#90249

Fullbuild is broken:
https://lab.llvm.org/buildbot/#/builders/163/builds/56501
2024-05-13 09:43:14 -04:00
Hendrik Hübner
d2676a7333
[libc][POSIX][pthreads] implemented missing pthread_rwlockattr functions (#90249)
Closes #89443

I added the two missing functions and respective test cases. Let me know
if anything needs changing.
2024-05-13 09:35:17 -04:00
Vinayak Dev
aca511734f
[libc] Implement fcntl() function (#89507)
Fixes #84968. 

Implements the `fcntl()` function defined in the `fcntl.h` header.
2024-05-01 11:18:44 -07:00
Fabian Keßler
cd7a7a56fc
Add basic char*_t support for libc (partial WG14 N2653) (#90360)
This PR implements a part of WG14 N2653:
 - Define C23 char8_t
 - Define C11 char16_t
 - Define C11 char32_t
 
 Missing goals are:
- The type of UTF-8 character literals is changed from unsigned char to
char8_t. (Since UTF-8 character literals already have type unsigned
char, this is not a semantic change).
- New mbrtoc8() and c8rtomb() functions declared in <uchar.h> enable
conversions between multibyte characters and UTF-8.
    - A new ATOMIC_CHAR8_T_LOCK_FREE macro.
    - A new atomic_char8_t typedef name.
2024-04-30 15:08:38 -07:00
Michael Flanders
5e9937d1b3
[libc][math] Adds entrypoint and tests for nearbyintf128,scalbnf128 (#88443)
Closes #84689.

Adding @lntue for review.

I was curious about the implementation of
`round_using_current_rounding_mode` used for the `nearbyint` functions.
It has one of the rounding modes as unreachable
([here](https://github.com/llvm/llvm-project/blob/main/libc/src/__support/FPUtil/NearestIntegerOperations.h#L243)),
and I was wondering if this was okay for the `nearbyint` functions.

---------

Co-authored-by: Michael Flanders <mkf727@cs.washington.edu>
2024-04-29 19:25:45 -04:00
Nick Desaulniers
dd7963239e
[libc][POSIX][pthreads] implement pthread_rwlockattr_t functions (#89322)
Implement:
- pthread_rwlockattr_destroy
- pthread_rwlockattr_getpshared
- pthread_rwlockattr_init
- pthread_rwlockattr_setpshared
2024-04-22 12:03:27 -07:00
Nick Desaulniers
06947b9f8d
[libc][POSIX][pthreads] implement pthread_condattr_t functions (#88987)
Implement:
- pthread_condattr_destroy
- pthread_condattr_getclock
- pthread_condattr_getpshared
- pthread_condattr_init
- pthread_condattr_setclock
- pthread_condattr_setpshared

Fixes: #88581
2024-04-17 09:31:29 -07:00
Robin Caloudis
b854a23233
[libc][c23][fenv] Implement fetestexceptflag (#87828)
Provide C23 `fetestexceptflag` function according to 7.6.4.6 in the
latest [revision of the C
standard](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf)
from 2023-04-02.

Closes https://github.com/llvm/llvm-project/issues/87565.
2024-04-17 08:38:47 -07:00
Michael Jones
5fb821560a
[libc] add remaining epoll functions, pipe (#84587)
The epoll_wait functions need the rest of the epoll functions (create,
ctl) to be available to actually test them, as well as pipe to create a
usable file descriptor. This patch adds epoll_create, epoll_create1,
epoll_ctl, and pipe. These have tests, and the tests for epoll_wait,
epoll_pwait, and epoll_pwait2 (currently disabled) are updated to use
these newly available functions.
2024-04-11 16:26:49 -07:00
lntue
3c2feab7d1
Revert "[libc] implement ioctl" (#88226)
Reverts llvm/llvm-project#85890

This fails in full build mode:

https://lab.llvm.org/buildbot/#/builders/163/builds/54478/steps/4/logs/stdio
2024-04-09 23:48:09 -04:00
Nhat Nguyen
289a2c380e
[libc] implement ioctl (#85890)
This PR is to work on the issue #85275
2024-04-09 23:38:23 -04:00
aniplcc
8ee6ab7f69
[libc][c23][fenv] implement fesetexcept (#87603)
Closes #87564
2024-04-05 13:52:57 -07:00
Shourya Goel
9f0758405b
reland: [libc] Added transitive bindings for OffsetType (#87680)
Followup to issues addressed here: #87397
2024-04-05 12:11:44 -07:00
OverMighty
a8c59750d9
[libc][math][c23] Add exp2m1f C23 math function (#86996)
Fixes #86502.

cc @lntue
2024-04-04 08:22:45 -04:00
Gulfem Savrun Yeniceri
e8aaa3eaed Revert "[libc] Added transitive bindings for OffsetType (#87397)"
This reverts commit 3ee93f486293420852fb9ec95af9c5f54cecdb08
because it broke Fuchsia Clang toolchain builders:
https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket/8751633430491432833/+/u/clang/build/stdout
2024-04-04 04:12:36 +00:00
Shourya Goel
3ee93f4862
[libc] Added transitive bindings for OffsetType (#87397)
Adding OffTType to fcntl.h and stdio.h 's Macro lists in libc/spec/posix.td as
mentioned here: #87266
2024-04-03 14:16:57 -07:00
Joseph Huber
7327014b49
[libc] Implement temporary printf on the GPU (#85331)
Summary:
This patch adds a temporary implementation that uses a struct-based
interface in lieu of varargs support. Once varargs support exists we
will move this implementation to the "real" printf implementation.

Conceptually, this patch has the client copy over its format string and
arguments to the server. The server will then scan the format string
searching for any specifiers that are actually a string. If it is a
string then we will send the pointer back to the server to tell it to
copy it back. This copied value will then replace the pointer when the
final formatting is done.

This will require a built-in extension to the varargs support to get
access to the underlying struct. The varargs used on the GPU will simply
be a struct wrapped in a varargs ABI.
2024-04-02 16:25:18 -05:00
aniplcc
82be6e186b
[libc][posix] implement _exit (#87185)
Fixes  #87126.
2024-04-02 10:37:42 -07:00
lntue
2be722587f
[libc][math] Implement atan2f correctly rounded to all rounding modes. (#86716)
We compute atan2f(y, x) in 2 stages:
- Fast step: perform computations in double precision , with relative
errors < 2^-50
- Accurate step: if the result from the Fast step fails Ziv's rounding
test, then we perform computations in double-double precision, with
relative errors < 2^-100.

On Ryzen 5900X, worst-case latency is ~ 200 clocks, compared to average
latency ~ 60 clocks, and average reciprocal throughput ~ 20 clocks.
2024-04-01 13:31:07 -04:00
Shourya Goel
19ca79e867
[libc][math][c23] Implement canonicalize functions (#85940)
Fixes: #85286
2024-03-26 08:28:22 -04:00
Job Henandez Lara
3e3f0c3175
[libc][math][c23] add c23 floating point fmaximum and fminimum functions. (#86016)
Fixes https://github.com/llvm/llvm-project/issues/85496.

---------

Co-authored-by: Job Hernandez <h93@protonmail.com>
2024-03-25 15:19:10 -04:00
Schrodinger ZHU Yifan
05dc5d927b
[libc] add statvfs/fstatvfs (#86169)
fixes #86449
2024-03-25 13:37:50 -04:00
OverMighty
b282259711
[libc][math][c23] Add {,u}fromfp{,x}{,f,l,f128} functions (#86003)
Fixes #85279.

cc @lntue
2024-03-25 10:26:22 -04:00
Vinayak Dev
83e96977cd
[libc] Implement strfromd() and strfroml() (#86113)
Follow up to #85438.

Implements the functions `strfromd()` and `strfroml()` introduced in
C23, and unifies the testing framework for `strfrom*()` functions.
2024-03-22 11:39:53 -07:00
aniplcc
c04807c84e
[libc][c11] Add stdio.h's rename() function (#85068)
Adds stdio.h's rename() function as defined in n3096. Fixes  #84980.
2024-03-21 08:21:06 -07:00
Vinayak Dev
5ea152033e
[libc]: Implement strfromf() and shared utilities (#85438)
Fixes #84244.

Implements the function `strfromf()` introduced in C23, and adds shared
utilities for implementation of other `strfrom*()` functions, including
`strfromd()` and `strfroml()`.
2024-03-20 10:47:35 -07:00
Shourya Goel
715a931864
[libc] Added tablegen definition for fileno (#85682)
This was missed in the previous PR. Updating tablegen definition with this PR.
2024-03-18 15:48:47 -07:00
Schrodinger ZHU Yifan
f6f42af06f
[libc] Add shm_open/shm_unlink (#84974) 2024-03-18 11:40:07 -04:00
OverMighty
a2bad75879
[libc][math][c23] Add nextupl and nextdownl functions (#85484)
Fixes #85283.

cc @lntue
2024-03-16 17:21:07 -04:00
OverMighty
8ff96eb100
[libc][math][c23] Add nextup{,f,f128} and nextdown{,f,f128} functions (#85431)
See https://github.com/llvm/llvm-project/issues/85283.

I had a test for `nextdownl` that was failing and I thought I should add
`nextupl` and `nextdownl` later and first make a PR for the other
functions.

cc @lntue
2024-03-15 16:46:48 -04:00
Michael Flanders
b43965adac
[libc][math][c23] adds nanf128 (#85201)
Continuing #84689, this one required more changes than the others, so I
am making it a separate PR.

Extends some stuff in `str_to_float.h`, `str_to_integer.h` to work on
types wider than `unsigned long long` and `uint64_t`.

cc @lntue for review.
2024-03-15 13:31:50 -04:00
Petr Hosek
e25bf70d50
[libc] Add an empty definition of mbstate_t (#84993)
We expect to eventually provide a complete implementation, but having an
empty definition is necessary to unblock the use of libc++ in embedded
environments.

See #84884 for more details.
2024-03-12 21:26:58 -07:00
Michael Flanders
15a55486a5
[libc][math] Adds entrypoint and test for nextafterf128 (#84882) 2024-03-12 23:25:05 -04:00
Petr Hosek
34cf684775
[libc] Move struct timespec from POSIX to StdC (#85010)
`struct timespec` is actually defined in the C standard, not POSIX.
2024-03-12 22:33:16 -04:00
Nick Desaulniers
392436383a
[libc] fix typo in stdbit.h macro spec files (#84780) 2024-03-12 08:39:50 -07:00
Nick Desaulniers
f0c0ddae45
[libc] implement the final macros for stdbit.h support (#84798)
Relevant sections of n3096:
- 7.18.1p1
- 7.18.2
2024-03-12 08:39:17 -07:00
lntue
4d21e75210
[libc][math][c23] Add fmodl and fmodf128 math functions. (#84600)
- Allow `FMod` template to have different computational types and make
it work for 80-bit long double.
- Switch to use `uint64_t` as the intermediate computational types for
`float`, significantly reduce the latency of `fmodf` when the exponent
difference is large.
2024-03-11 16:27:42 -04:00
Schrodinger ZHU Yifan
fe1645e25c
[libc][mman] Implement msync (#84700)
Implement `msync` as specified in:

1. https://www.man7.org/linux/man-pages/man2/msync.2.html
2. https://pubs.opengroup.org/onlinepubs/9699919799/
2024-03-10 19:01:54 -04:00
Michael Flanders
75b0d384fb
[libc][stdbit][c23] adds implementation of stdc_bit_ceil functions (#84657)
Closes #84652.

Based on #84233.
2024-03-10 12:53:28 -04:00
lntue
99f5e9634b
[libc][math][c23] Add modff128 C23 math function. (#84532) 2024-03-09 11:47:22 -05:00
lntue
60d7bf3dbe
[libc][math][c23] Add (l|ll)rintf128 and (l|ll)roundf128 math functions. (#84504) 2024-03-08 12:15:02 -05:00
Schrodinger ZHU Yifan
29afd64615
[libc][c23] make inttypes.h compat with c23 (#84493) 2024-03-08 10:36:22 -05:00
lntue
14171b87a3
[libc][stdfix] Add exp function for short _Accum and _Accum types. (#84391) 2024-03-07 17:58:28 -05:00
lntue
d0b7022798
[libc] Refactor stdfix extension from llvm_libc_ext.td to llvm_libc_stdfix_ext.td. (#84365)
This fixes runtime build for armv6 baremetal targets:
https://github.com/llvm/llvm-project/pull/83959#issuecomment-1984221249
2024-03-07 15:23:37 -05:00
Schrodinger ZHU Yifan
57a337378f
[libc][c23] add memset_explicit (#83577) 2024-03-07 14:57:35 -05:00
Nick Desaulniers
101a13df71
[libc][stdbit] implement stdc_bit_floor (C23) (#84233) 2024-03-07 08:38:04 -08:00
lntue
6fc5dc3ebb
[libc] Fix a typo in llvm_libc_ext.td. (#84259) 2024-03-06 15:51:47 -08:00
lntue
ad33fe1281
[libc][stdfix] Add integer square root with fixed point output functions. (#83959)
Fix https://github.com/llvm/llvm-project/issues/83924.
2024-03-06 18:35:44 -05:00