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
Petr Hosek
b3e71ec9f7
[libc] Provide __libc_{init,fini}_array for baremetal ( #90828 )
...
These are provided by newlib and many baremetal projects assume they're
available rather than providing their own implementation.
2024-05-21 15:46:04 -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
David CARLIER
418212089e
[libc] adding linux SYS_fchmodat2 syscall. ( #89819 )
2024-04-23 22:58:00 +01: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
OverMighty
41ff91e143
Reapply "[libc][math][c23] Add remaining linux/* entrypoints for {,u}fromfp{,x}* ( #86692 )" ( #88567 )
...
This reverts commit 8a071678a9091d536eae29912ca7be6238105956.
The test failure on 32-bit Arm should have been fixed by #86892 .
cc @nickdesaulniers @lntue
2024-04-12 16:01:36 -04: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
Vinayak Dev
3b961d113e
[libc] Implement roundeven C23 math functions ( #87678 )
...
Implements the functions `roundeven()`, `roundevenf()`, `roundevenl()`
from the roundeven family of functions introduced in C23. Also
implements `roundevenf128()`.
2024-04-05 08:36:12 -04: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
Joseph Huber
6335de4a23
[libc] Disable '_exit' on the GPU build
...
Summary:
There are other dependencies to enable `unistd.h` on the GPU which
prevented the header from being generated. This is a POSIX extension and
isn't part of the core `libc`, so we can just disable this for now to
get the bots gree.
2024-04-02 15:24:06 -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
55b74030a4
[libc][POSIX] implement fseeko, ftello ( #86928 )
...
Fixes : #85287
2024-04-01 10:09:28 -07:00
Schrodinger ZHU Yifan
a8b0ecd260
[libc] enable stack protectors and frame pointers on default ( #86288 )
2024-03-29 20:17:11 -04:00
Nick Desaulniers
8a071678a9
Revert "[libc][math][c23] Add remaining linux/* entrypoints for {,u}fromfp{,x}* ( #86692 )"
...
This reverts commit cd17082b24079a31eff0057abe407da5cfb7b0fc because the newly
added tests fail on 32b ARM.
Link: #86692
Link: https://lab.llvm.org/buildbot/#/builders/229/builds/24458
2024-03-27 13:28:26 -07:00
OverMighty
cd17082b24
[libc][math][c23] Add remaining linux/* entrypoints for {,u}fromfp{,x}* ( #86692 )
2024-03-27 12:28:27 -07: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
OverMighty
85b6af198f
[libc][math][c23] Add linux/* entrypoints for nextup* and nextdown* ( #85803 )
...
See
https://github.com/llvm/llvm-project/pull/85484#discussion_r1526971653 .
There already were entrypoints for linux/x86_64. I haven't tested on the other
targets and will rely on the buildbots.
2024-03-19 12:47:01 -07:00
Joseph Huber
cf835b96b1
[libc] Remove fileno from GPU entrypoints
2024-03-18 14:52:46 -05:00
Nick Desaulniers
27d7bb8616
[libc] fix up fileno tests ( #85660 )
...
Fixes #85628
2024-03-18 13:35:44 -04:00
Shourya Goel
ca04b56a8b
[libc] Implement fileno ( #85628 )
...
fixes : #85150
2024-03-18 09:26:30 -07:00
Schrodinger ZHU Yifan
f6f42af06f
[libc] Add shm_open/shm_unlink
( #84974 )
2024-03-18 11:40:07 -04:00
Petr Hosek
5a75242bc8
[libc] Include empty remove in baremetal stdio.h ( #85336 )
...
This is required to avoid compilation error in libc++.
See #85335 for more details.
2024-03-16 23:17:19 -07:00
Petr Hosek
6666b3fca8
[libc] Match baremetal stdlib.h entrypoints with types
...
To match the entrypoints and types we need to exclude __atexithandler_t
and __qsortrcompare_t, as well as qsort_r, which is a GNU extension.
This is a reland of llvm/llvm-project#85030 .
2024-03-16 22:29:11 -07:00
Petr Hosek
8f878c5018
[libc] Include time.h in baremetal targets ( #85026 )
...
These types and conversion functions are used in embedded development.
Note that we cannot yet include other entrypoints such as asctime
because `src/time/time_utils.h` unconditionally uses `EOVERFLOW`, which
is only defined in POSIX and not in C standard. This issue is tracked by
#85556 .
2024-03-16 16:11:04 -07:00
OverMighty
a2bad75879
[libc][math][c23] Add nextupl and nextdownl functions ( #85484 )
...
Fixes #85283 .
cc @lntue
2024-03-16 17:21:07 -04:00
Paul Kirth
6c3049cd68
Revert "[libc] Match stdlib.h baremetal entrypoints with types" ( #85490 )
...
Reverts llvm/llvm-project#85030
This patch causes build failures when building runtimes for armv6m
```
FAILED: /b/s/w/ir/x/w/llvm_build/include/armv6m-unknown-eabi/stdlib.h
cd /b/s/w/ir/x/w/llvm-llvm-project/libc/include && /b/s/w/ir/x/w/llvm_build/bin/libc-hdrgen -o /b/s/w/ir/x/w/llvm_build/include/armv6m-unknown-eabi/stdlib.h --header stdlib.h --def /b/s/w/ir/x/w/llvm-llvm-project/libc/include/stdlib.h.def -I /b/s/w/ir/x/w/llvm-llvm-project/libc --e=__assert_fail --e=isalnum --e=isalpha --e=isascii --e=isblank --e=iscntrl --e=isdigit --e=isgraph --e=islower --e=isprint --e=ispunct --e=isspace --e=isupper --e=isxdigit --e=toascii --e=tolower --e=toupper --e=__stack_chk_fail --e=errno --e=bcmp --e=bcopy --e=bzero --e=index --e=memccpy --e=memchr --e=memcmp --e=memcpy --e=memmem --e=memmove --e=mempcpy --e=memrchr --e=memset --e=memset_explicit --e=rindex --e=stpcpy --e=stpncpy --e=strcasecmp --e=strcasestr --e=strcat --e=strchr --e=strchrnul --e=strcmp --e=strcoll --e=strcpy --e=strcspn --e=strerror --e=strerror_r --e=strlcat --e=strlcpy --e=strlen --e=strncasecmp --e=strncat --e=strncmp --e=strncpy --e=strnlen --e=strpbrk --e=strrchr --e=strsep --e=strspn --e=strstr --e=strtok --e=strtok_r --e=strxfrm --e=imaxabs --e=imaxdiv --e=strtoimax --e=strtoumax --e=sprintf --e=snprintf --e=vsprintf --e=vsnprintf --e=stdc_leading_zeros_uc --e=stdc_leading_zeros_us --e=stdc_leading_zeros_ui --e=stdc_leading_zeros_ul --e=stdc_leading_zeros_ull --e=stdc_leading_ones_uc --e=stdc_leading_ones_us --e=stdc_leading_ones_ui --e=stdc_leading_ones_ul --e=stdc_leading_ones_ull --e=stdc_trailing_zeros_uc --e=stdc_trailing_zeros_us --e=stdc_trailing_zeros_ui --e=stdc_trailing_zeros_ul --e=stdc_trailing_zeros_ull --e=stdc_trailing_ones_uc --e=stdc_trailing_ones_us --e=stdc_trailing_ones_ui --e=stdc_trailing_ones_ul --e=stdc_trailing_ones_ull --e=stdc_first_leading_zero_uc --e=stdc_first_leading_zero_us --e=stdc_first_leading_zero_ui --e=stdc_first_leading_zero_ul --e=stdc_first_leading_zero_ull --e=stdc_first_leading_one_uc --e=stdc_first_leading_one_us --e=stdc_first_leading_one_ui --e=stdc_first_leading_one_ul --e=stdc_first_leading_one_ull --e=stdc_first_trailing_zero_uc --e=stdc_first_trailing_zero_us --e=stdc_first_trailing_zero_ui --e=stdc_first_trailing_zero_ul --e=stdc_first_trailing_zero_ull --e=stdc_first_trailing_one_uc --e=stdc_first_trailing_one_us --e=stdc_first_trailing_one_ui --e=stdc_first_trailing_one_ul --e=stdc_first_trailing_one_ull --e=stdc_count_zeros_uc --e=stdc_count_zeros_us --e=stdc_count_zeros_ui --e=stdc_count_zeros_ul --e=stdc_count_zeros_ull --e=stdc_count_ones_uc --e=stdc_count_ones_us --e=stdc_count_ones_ui --e=stdc_count_ones_ul --e=stdc_count_ones_ull --e=stdc_has_single_bit_uc --e=stdc_has_single_bit_us --e=stdc_has_single_bit_ui --e=stdc_has_single_bit_ul --e=stdc_has_single_bit_ull --e=stdc_bit_width_uc --e=stdc_bit_width_us --e=stdc_bit_width_ui --e=stdc_bit_width_ul --e=stdc_bit_width_ull --e=stdc_bit_floor_uc --e=stdc_bit_floor_us --e=stdc_bit_floor_ui --e=stdc_bit_floor_ul --e=stdc_bit_floor_ull --e=stdc_bit_ceil_uc --e=stdc_bit_ceil_us --e=stdc_bit_ceil_ui --e=stdc_bit_ceil_ul --e=stdc_bit_ceil_ull --e=abort --e=abs --e=atoi --e=atof --e=atol --e=atoll --e=bsearch --e=div --e=labs --e=ldiv --e=llabs --e=lldiv --e=qsort --e=qsort_r --e=rand --e=srand --e=strtod --e=strtof --e=strtol --e=strtold --e=strtoll --e=strtoul --e=strtoull --e=feclearexcept --e=fedisableexcept --e=feenableexcept --e=fegetenv --e=fegetexcept --e=fegetexceptflag --e=fegetround --e=feholdexcept --e=fesetenv --e=fesetexceptflag --e=fesetround --e=feraiseexcept --e=fetestexcept --e=feupdateenv --e=acosf --e=acoshf --e=asinf --e=asinhf --e=atanf --e=atanhf --e=ceil --e=ceilf --e=ceill --e=copysign --e=copysignf --e=copysignl --e=cosf --e=coshf --e=erff --e=exp --e=exp10 --e=exp10f --e=exp2 --e=exp2f --e=expf --e=expm1 --e=expm1f --e=fabs --e=fabsf --e=fabsl --e=fdim --e=fdimf --e=fdiml --e=floor --e=floorf --e=floorl --e=fma --e=fmaf --e=fmax --e=fmaxf --e=fmaxl --e=fmin --e=fminf --e=fminl --e=fmod --e=fmodf --e=fmodl --e=frexp --e=frexpf --e=frexpl --e=hypot --e=hypotf --e=ilogb --e=ilogbf --e=ilogbl --e=ldexp --e=ldexpf --e=ldexpl --e=llogb --e=llogbf --e=llogbl --e=llrint --e=llrintf --e=llrintl --e=llround --e=llroundf --e=llroundl --e=log --e=log10 --e=log10f --e=log1p --e=log1pf --e=log2 --e=log2f --e=logb --e=logbf --e=logbl --e=logf --e=lrint --e=lrintf --e=lrintl --e=lround --e=lroundf --e=lroundl --e=modf --e=modff --e=modfl --e=nan --e=nanf --e=nanl --e=nearbyint --e=nearbyintf --e=nearbyintl --e=nextafter --e=nextafterf --e=nextafterl --e=nexttoward --e=nexttowardf --e=nexttowardl --e=powf --e=remainder --e=remainderf --e=remainderl --e=remquo --e=remquof --e=remquol --e=rint --e=rintf --e=rintl --e=round --e=roundf --e=roundl --e=scalbn --e=scalbnf --e=scalbnl --e=sincosf --e=sinf --e=sinhf --e=sqrt --e=sqrtf --e=sqrtl --e=tanf --e=tanhf --e=trunc --e=truncf --e=truncl --e=abshk --e=abshr --e=absk --e=absr --e=abslk --e=abslr --e=exphk --e=expk --e=roundhk --e=roundhr --e=roundk --e=roundr --e=roundlk --e=roundlr --e=rounduhk --e=rounduhr --e=rounduk --e=roundur --e=roundulk --e=roundulr --e=sqrtuhk --e=sqrtuhr --e=sqrtuk --e=sqrtur --e=sqrtulr --e=uhksqrtus --e=uksqrtui /b/s/w/ir/x/w/llvm-llvm-project/libc/config/baremetal/api.td
error: __qsortrcompare_t not found in any standard spec.
```
Original failure:
https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8753376051397217137/overview
I've tested that reverting this commit would make the build green again.
29c31064b1/+/build.proto
2024-03-15 17:42:04 -07: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
Petr Hosek
d717e7f7be
[libc] Include double_t and float_t in math.h on baremetal ( #85028 )
...
This matches other targets.
2024-03-15 11:00:19 -07:00
Petr Hosek
500e05f5a2
[libc] Match stdlib.h baremetal entrypoints with types ( #85030 )
...
To match the entrypoints and types for baremetal, we need to include
__qsortrcompare_t and omit __atexithandler_t.
2024-03-15 10:58:14 -07:00