Commit Graph

336 Commits

Author SHA1 Message Date
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 3ee93f4862
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
Nick Desaulniers
041638c429 [libc][stdbit] implement stdc_bit_width (C23) (#83892) 2024-03-05 09:49:41 -08:00
Joseph Huber
c996023f9a [libc] Provide an implementation of the 'stdint.h' header (#83353)
Summary:
I've noticed one problem is that the user includes `stdint.h` the
compiler will do `#include_next <stdint.h>` potentially into a
conflicting implementation on systems with multiple headers installed.
The `clang` header is standards compliant and works with `clang` and
`gcc` which are both of our targets, so I simply copied it here. This
has the effect of including `stdint.h` on clang / LLVM libc behaving the
same as `-ffreestanding`.
2024-03-04 12:23:11 -06:00
Guillaume Chatelet
75fb825bcc [libc][NFC] Rename LIBC_COMPILER_HAS_FLOAT128 to LIBC_TYPES_HAS_FLOAT128 (#83395)
Umbrella bug #83182
2024-02-29 21:59:58 +01:00
Nick Desaulniers
06bcd9da16 [libc][stdbit] implement stdc_has_single_bit (C23) (#83168) 2024-02-27 13:45:37 -08:00
lntue
aa95aa69b9 [libc][math][c23] Add C23 math functions ilogbf128, logbf128, and llogb(f|l|f128). (#82144) 2024-02-27 12:23:19 -05:00
lntue
ded4ea9752 [libc][stdfix] Add sqrt for fixed point types. (#83042) 2024-02-26 19:36:30 -05:00
Nick Desaulniers
d8406d48a8 [libc][stdbit] implement stdc_count_ones (C23) (#82444) 2024-02-26 09:25:24 -08:00
Nick Desaulniers
f70d5c0bc8 [libc][stdbit] implement stdc_count_zeros (C23) (#82437) 2024-02-26 09:23:15 -08:00
Joseph Huber
69c0b2febe [libc][NFC] Remove all trailing spaces from libc (#82831)
Summary:
There are a lot of random training spaces on various lines. This patch
just got rid of all of them with `sed 's/\ \+$//g'.
2024-02-23 16:34:00 -06:00
Schrodinger ZHU Yifan
96c5b8cbd1 [libc][c23] add definitions for stdckdint.h (#82059)
See docs at
- https://gustedt.gitlabpages.inria.fr/c23-library/#stdckdint
- https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3047.pdf (Ch7.10)

Compiler header:
-
450462cbac/clang/lib/Headers/stdckdint.h
- New version of GCC
(cd503b0616/gcc/ginclude/stdckdint.h)
also provides this.
2024-02-20 11:20:15 -05:00
lntue
f01ed3bc88 [libc][stdfix] Add round functions for fixed point types. (#81994) 2024-02-16 12:45:26 -05:00