Commit Graph

655 Commits

Author SHA1 Message Date
Nick Desaulniers
e0ae7793fc [libc] delete hdrgen (#117220)
Thanks to the effort of @RoseZhang03 and @aaryanshukla under the
guidance of
@michaelrj-google and @amykhuang, we now have newhdrgen and no longer
have a
dependency on TableGen and thus LLVM in order to start bootstrapping a
full
build.

This PR removes:
- LIBC_HDRGEN_EXE; the in tree newhdrgen is the only hdrgen that can be
used.
- LIBC_USE_NEW_HEADER_GEN; newhdrgen is the default and only option.
- LIBC_HDRGEN_ONLY; there is no need to have a distinct build step for
old
  hdrgen.
- libc-api-test and libc-api-test-tidy build targets.
- Deletes all .td files.

It does not rename newhdrgen to just hdrgen. Will follow up with a
distinct PR
for that.

Link: #117209
Link: #117254
Fixes: #117208
2024-12-03 12:34:26 -08:00
wldfngrs
cd04653c4e [libc][math][c23] Add sinf16 C23 math function (#116674)
Co-authored-by: OverMighty <its.overmighty@gmail.com>
2024-12-03 21:08:46 +01:00
Petr Hosek
b8daa45a56 [libc] Implement timespec_get (#116102)
`timespec_get` is C standard counterpart to POSIX `clock_gettime`. On
Linux we simply use `clock_gettime`. On baremetal we introduce a new
external API `__llvm_libc_timespec_get_utc` that should be implemented
by the vendor.
2024-12-02 14:29:49 -08:00
Schrodinger ZHU Yifan
700d9ac9ef [libc] disable process_mrelease for riscv (#117956)
`process_mrelease` upsets the RV32 build bot. Disable it for now.
2024-11-27 21:17:38 -05:00
Omar Hossam
d2b482b0ef [libc] (reland #117503) Implement process_mrelease (#117851)
This PR implements process_mrelease.
A previous PR was merged #117503, but failed on merge due to an issue in
the tests. Namely the failing tests were comparing against return type
as opposed to errno. This is fixed in this PR.
2024-11-27 20:15:17 -05:00
lntue
3372303188 Revert "[libc] Implement process_mrelease." (#117807)
Reverts llvm/llvm-project#117503
2024-11-26 18:07:30 -05:00
Omar Hossam
36a46d85e7 [libc] Implement process_mrelease. (#117503)
This PR addresses #110124.
2024-11-26 17:40:06 -05:00
William Tran-Viet
13ced90b00 [libc] {u}lkbits broken on riscv32 (#115799)
- Re-enabled ulkbits and lkbits for Risc-V
- Bumped `int_lk_t` to a `signed long long` and a `uint_ulk_t` to an
`unsigned long long` to guarantee they both fit in 8 bytes, which `long
_Accum` and `unsigned long _Accum` are defaulted to on 32bit
architectures.

This is probably inconvenient on systems that have a word size larger
than 64 bits?

#115778
2024-11-12 10:38:08 -08:00
Nick Desaulniers
28cdebf7ba [libc][stdfix] disable ulkbits on riscv (#115781) (#115792)
I should have disabled this in #115781. Mea culpa.

Link: #114912
Link: #115778
Link: #115781
2024-11-11 16:18:55 -08:00
Nick Desaulniers
448d7da562 [libc][stdfix] disable lkbits on riscv (#115781)
Link: #114912
Link: #115778
2024-11-11 14:45:22 -08:00
Michael Jones
1ae0dae368 [libc] Clean up skipped and failing cmake (#115400)
I normally run my cmake with LIBC_CMAKE_VERBOSE_LOGGING set to ON so I
can debug build issues more easily. One of the effects of this is I see
which tests/entrypoints are skipped on my machine. This patch fixes up
the tests and entrypoints that were skipped, but easily fixed. These
were:

libc.src.pthread.pthread_spin_destroy
libc.src.pthread.pthread_spin_init
libc.src.pthread.pthread_spin_lock
libc.src.pthread.pthread_spin_trylock
libc.src.pthread.pthread_spin_unlock
(entrypoints were just missing)

libc.src.wchar.btowc
(I forgot to finish it)

libc.test.src.sys.statvfs.linux.statvfs_test
libc.test.src.sys.statvfs.linux.fstatvfs_test
(Incorrect includes for rmdir, needed some cleanup)

libc.test.integration.src.unistd.execve_test
(wrong dep for errno)

libc.test.src.math.smoke.fmaf_test
(add_fp_unittest doesn't support flags)

libc.test.src.stdio.scanf_core.converter_test
(needed to be moved away from string_reader, further cleanup needed)
2024-11-11 14:28:36 -08:00
Nick Desaulniers
f1800df5d5 [libc] fix lfind entrypoints (#115771)
- move arm entrypoint to fullbuild only
- remove baremetal entrypoints; we avoid POSIX on baremetal
- remove darwin/arm and windows entrypoints since these are untested

Fixes: #114692
2024-11-11 13:37:59 -08:00
Nick Desaulniers
582a4799e1 [libc] fix lfind old hdrgen (#115760)
Fixes: #114692
2024-11-11 11:51:24 -08:00
William Tran-Viet
c11b6e80b6 [libc][stdfix] Implement fixed point fxbits functions in llvm-libc (#114912) 2024-11-11 12:54:16 -05:00
Duncan
396ed9c2a1 [libc][search] implement posix lfind function (#114692)
# Changes
- Implement the POSIX
[`lfind`](https://man7.org/linux/man-pages/man3/lsearch.3.html)
function.

- Put a checkmark in the [posix support table
docs](https://libc.llvm.org/libc_search.html) next to `lfind`.
2024-11-11 09:53:20 -08:00
wldfngrs
f7bb12901e [libc][math][c23] Add tanpif16 function (#115183)
- Implementation of `tan` for 16-bit floating point inputs scaled by pi.
i.e,. `tanpif16()`
- Implementation of Tanpi in MPFRWrapper for MPFR versions < 4.2
- Exhaustive tests for `tanpif16()`
2024-11-08 09:56:31 -05:00
OverMighty
faefedf7f8 [libc][math][c23] Add exp10m1f C23 math function (#87992)
Fixes #86503.
2024-11-07 23:56:00 +01:00
Jingyu Qiu
5a6cc50921 [libc] add mremap (#112804) 2024-11-06 10:25:50 -08:00
Duncan
6219c80839 [libc] [unistd] implement pipe2 syscall wrapper (#114474)
Closes #85289

Co-authored-by: Michael Jones <michaelrj@google.com>
2024-11-06 08:35:03 -08:00
Shourya Goel
790a7859a8 Comment out CF16 entrypoints for aarch64 and CF128 entrypoints for X84-64 (#114696)
Temporarily Fixes buildbot errors due to #113300
2024-11-03 11:14:11 +05:30
Shourya Goel
ffe04e0351 [libc][complex] implement different flavors of creal and cimag functions (#113300)
I have commented out the test for `neg_zero`(creal) because : 

1. real(neg_zero + 0.0i) equals zero. 
2. real(neg_zero - 0.0i) equals neg_zero.

I am not sure if this is the intended behaviour. 

[EDIT]
I have updated tests for `neg_zero` (creal) to be : 

```
    EXPECT_FP_EQ(func(CFPT(neg_zero - zero * 1.0i)), neg_zero);
    EXPECT_FP_EQ(func(CFPT(neg_zero + zero * 1.0i)), zero);
```

because all three [gcc, clang and GNU MPC] also give the same result. 
https://godbolt.org/z/hxhcn6aof
and it seems that it is indeed the correct behaviour since Imaginary
types are not supported yet, refer #113671
2024-11-03 09:38:09 +05:30
Nick Desaulniers
e083a33478 [libc][cmake] make i386 distinct from x86_64 (#114477)
Configured via:

    $ cmake ../runtimes -G Ninja -DLLVM_ENABLE_LLD=ON \
      -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_RUNTIMES="libc" \
      -DLIBC_TARGET_TRIPLE=i386-linux-gnu -DCMAKE_C_COMPILER=clang \
      -DCMAKE_CXX_COMPILER=clang++

Link: #93709
2024-11-01 08:31:05 -07:00
wldfngrs
7395ef5419 [libc][math][c23] Add cospif16 function (#113001)
Implementation of `cos` for half precision floating point inputs scaled
by pi (i.e., `cospi`), correctly rounded for all rounding modes.

---------

Co-authored-by: OverMighty <its.overmighty@gmail.com>
2024-10-29 03:39:57 -07:00
OverMighty
d97f6d1ae9 [libc][math][c23] Add sqrtf16 C23 math function (#112406)
Part of #95250.
2024-10-19 01:41:52 +02:00
OverMighty
69d3a44ede [libc][math][c23] Add log10f16 C23 math function (#106091)
Part of #95250.
2024-10-19 01:40:40 +02:00
OverMighty
6d347fdfbd [libc][math][c23] Add log2f16 C23 math function (#106084)
Part of #95250.
2024-10-19 01:10:32 +02:00
OverMighty
65cf7afb6d [libc][math][c23] Add logf16 C23 math function (#106072)
Part of #95250.
2024-10-18 22:35:12 +02:00
OverMighty
fdd7c0353f [libc][math][c23] Add tanhf16 C23 math function (#106006)
Part of #95250.
2024-10-18 14:22:45 +02:00
OverMighty
ed3d051782 [libc][math][c23] Add sinhf16 and coshf16 C23 math functions (#105947)
Part of #95250.
2024-10-17 20:44:23 +02:00
OverMighty
95c24cb9de [libc][math][c23] Add exp10m1f16 C23 math function (#105706)
Part of #95250.
2024-10-16 16:33:13 +02:00
wldfngrs
ddc3f2dd26 [libc] Add sinpif16 function (#110994)
Half-precision floating point (16-bit) implementation of the
trigonometric function Sin for inputs scaled by pi
2024-10-15 18:40:08 -04:00
Aly ElAshram
76173b1b67 [libc] Add Linux mman extension remap_file_pages. (#110307)
Fixes https://github.com/llvm/llvm-project/issues/110122
- Create remap_file_pages.h/.cpp wrapper for the linux sys call.
- Add UnitTests for remap_file_pages
- Add function to libc/spec/linux.td
- Add Function spec to mman.yaml
2024-10-14 14:04:32 -07:00
OverMighty
ce65d4e974 [libc][math][c23] Add exp2m1f16 C23 math function (#105690)
Part of #95250.
2024-10-12 19:31:12 +02:00
Fabio D'Urso
2396c46999 [libc] Add malloc.h header defining mallopt (#110908)
This patch adds the malloc.h header, declaring Scudo's mallopt
entrypoint when built LLVM_LIBC_INCLUDE_SCUDO, as well as two
constants that can be passed to it (M_PURGE and M_PURGE_ALL).

Due to limitations of the current build system, only the declaration
of mallopt is gated by LLVM_LIBC_INCLUDE_SCUDO, and the two new
constants are defined irrespectively of it. We may need to refine
this in the future.

Note that some allocators other than Scudo may offer a mallopt
implementation too (e.g. man 3 mallopt), albeit with different
supported input values. This patch only supports the specific case of
LLVM_LIBC_INCLUDE_SCUDO.
2024-10-03 18:45:23 +02:00
Shourya Goel
2d784b1946 [libc][math] Implement iscanonical[f|l] as a libc math function (#110565)
This PR implements the iscanonical function as part of the libc math
library.

The addition of this function is crucial for completing the
implementation of remaining math macros, as referenced in #109201
2024-10-02 10:14:04 -04:00
Shourya Goel
47e3d8dc7e [libc][math] Implement issignaling[f|l] as a libc math function (#110556)
This PR implements the issignaling function as part of the libc math
library, addressing the TODO items mentioned in #110011

The addition of this function is crucial for completing the
implementation of remaining math macros, as referenced in #109201
2024-10-01 13:49:28 -04:00
Michael Jones
13dd2fd1e0 [libc] Put bind back, fix gcc build (#109341)
Fixes #106467.
Bind was accidentally removed while trying to clean up functions that
didn't end up being needed. The GCC issue was just a warning treated as
an error.
2024-09-19 15:10:56 -07:00
Michael Jones
f6b4c34d4f [libc] Add functions to send/recv messages (#106467)
This patch adds the necessary functions to send and receive messages
over a socket. Those functions are: recv, recvfrom, recvmsg, send,
sendto, sendmsg, and socketpair for testing.
2024-09-19 14:43:00 -07:00
Зишан Мирза
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