Commit Graph

682 Commits

Author SHA1 Message Date
Krishna Pandey
1f51038036 [libc][stdfix] Implement countlsfx functions in libc. (#126597)
fixes #113357

---------

Signed-off-by: krishna2803 <kpandey81930@gmail.com>
2025-02-12 14:12:44 -05:00
wldfngrs
7ee56b9afc [libc][math][c23] Add asinf16() function (#124212)
Co-authored-by: OverMighty <its.overmighty@gmail.com>
2025-02-10 12:38:55 +01:00
Joseph Huber
7623d91784 Revert "[libc][stdfix] Fix buildbot failure because of a typo. (#126291)"
This reverts commit bada9220b8.

Revert "[libc][stdfix] Implement fixed point `countlsfx` functions in llvm-libc (#125356)"

This reverts commit f2a1103b32.
2025-02-07 14:34:40 -06:00
Krishna Pandey
f2a1103b32 [libc][stdfix] Implement fixed point countlsfx functions in llvm-libc (#125356)
fixes #113357
2025-02-07 13:53:17 -05:00
c8ef
6807164500 [libc] Add the <endian.h> header. (#125168)
Closes [#124631](https://github.com/llvm/llvm-project/issues/124631).
ref:
https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/endian.h.html

This patch adds the implementation of `endian.h`, which includes the
header itself and three related macros. These macros in the header rely
on the compiler preprocessor, similar to how
https://github.com/llvm/llvm-project/blob/main/libc/src/__support/endian_internal.h
does. Hopefully this will meet the requirements for compiling llvm with
llvm-libc.
2025-02-07 09:20:18 +08:00
Alex Prabhat Bara
74c2e9a82a [libc] generate sys/wait.h for aarch64 (#125171)
Fixes: #125102
2025-02-06 13:15:45 -08:00
c8ef
e1c63bbde5 [libc] implement sys/uio/readv (#124718)
Closes #124694.

This patch adds the `sys/uio/readv` function.
ref:
https://pubs.opengroup.org/onlinepubs/009696699/functions/readv.html
2025-02-06 09:28:20 +08:00
Nick Desaulniers
72aa3889fb [libc][poll] remove entrypoint for riscv (#125941)
riscv32 specifically doesn't provide EITHER SYS_poll or SYS_ppoll. We may be
able to reimplement poll in terms of syscalls to SYS_ppoll_time64, but will
leave that as a TODO for the future. (Such as when we want to be able to cross
compile for riscv32).

Link: #125940
Fixes: #125118
2025-02-05 13:56:30 -08:00
Nick Desaulniers
8e35b3d29b [libc][POSIX][poll.h] implement poll (#125118)
Simple syscall.

Fixes: #124647
2025-02-05 13:24:39 -08:00
Krishna Pandey
6f750cfb96 [libc][unistd] Implement setsid (#125704)
https://man7.org/linux/man-pages/man2/setsid.2.html

closes #124632
2025-02-05 10:08:16 -08:00
Nick Desaulniers
631a6e0004 [libc][wchar] implement wcslen (#124150)
Update string_utils' string_length to work with char* or wchar_t*, so that it
may be reusable when implementing wmemchr, wcspbrk, wcsrchr, wcsstr.

Link: #121183
Link: #124027

Co-authored-by: Nick Desaulniers <ndesaulniers@google.com>

---------

Co-authored-by: Tristan Ross <tristan.ross@midstall.com>
2025-01-23 13:33:04 -08:00
Joseph Huber
db6b7a84e6 [libc][NFC] Strip all training whitespace and missing newlines (#124163) 2025-01-23 12:02:54 -06:00
Schrodinger ZHU Yifan
defd0d966d [libc] implement unistd/getentropy (#122692)
Implement GNU extension getentropy. This function is used by many
programs to acquire entropy without handling the loop of getrandom.
2025-01-15 18:27:05 +08:00
wldfngrs
ecf4f95c4f [libc][math][c23] Add tanf16 function (#121018)
- Implementation of tan for 16-bit floating point inputs.
- Exhaustive tests across the 16-bit input range
2025-01-12 23:46:53 -05:00
Schrodinger ZHU Yifan
73dd730fb9 [libc] implement sys/uio/writev (#122233)
implement sys/uio/writev according to POSIX standard. This vectorized IO
API is needed by many logging libraries to achieve atomic logging
multiple strings.
2025-01-10 12:49:00 +08:00
Shourya Goel
9f75b6664f [libc][complex] fix buildbot errors (#121141)
Fix buildbot errors due to #121140
2024-12-26 12:57:48 +05:30
Shourya Goel
abd9102344 [libc][complex] add cfloat16 and cfloat128 compiler flags (#121140)
Proper fix for the temporary fix in #114696
2024-12-26 12:50:07 +05:30
Shourya Goel
ff97daadcd Revert "[libc][complex] enable CFP128 entrypoints on X86_64 (#121111)" (#121113)
This reverts commit dd9c5c1182.
2024-12-25 20:56:13 +05:30
Shourya Goel
dd9c5c1182 [libc][complex] enable CFP128 entrypoints on X86_64 (#121111) 2024-12-25 20:45:32 +05:30
Shourya Goel
c98e79d856 [libc][complex] Implement different flavors of the cproj function (#119722)
Refer section 7.3.9.5 of ISO/IEC 9899:2023
2024-12-18 02:04:50 +05:30
wldfngrs
6a865b6d3d [libc][math][c23] Add cosf16 function (#118785) 2024-12-15 18:58:54 +01:00
Shourya Goel
d5b7b97034 [libc][complex] Add complex.yaml in hdrgen. (#119609) 2024-12-12 03:12:09 +05:30
Nick Desaulniers
d1d5fc381f [libc] fix up strings.h entrypoints (#119417)
I typo'd riscv, and the newly added baremetal aarch64 entrypoints had a mid air
collision.

Link: #118691
Link: #118899
2024-12-10 10:14:01 -08:00
Nick Desaulniers
1d7d0051f9 [libc] move src/network to src/arpa/inet (#119273)
So that docgen can find our implementations.

Fixes: #119272
2024-12-10 08:59:39 -08:00
Nick Desaulniers
431ea2d076 [libc] move bcmp, bzero, bcopy, index, rindex, strcasecmp, strncasecmp to strings.h (#118899)
docgen relies on the convention that we have a file foo.cpp in
libc/src/\<header\>/. Because the above functions weren't in libc/src/strings/
but rather libc/src/string/, docgen could not find that we had implemented
these.

Rather than add special carve outs to docgen, let's fix up our sources for
these 7 functions to stick with the existing conventions the rest of the
codebase follows.

Link: #118860
Fixes: #118875
2024-12-10 08:58:45 -08:00
Shourya Goel
78c2b6d483 [libc][complex] Implement different flavors of the conj function (#118671)
Refer section 7.3.9.4 of ISO/IEC 9899:2023
2024-12-10 10:05:11 +05:30
Schrodinger ZHU Yifan
245f26a3d3 [libc] revert all process_mrelease changes (#118650)
Revert as its test is unstable.
https://github.com/llvm/llvm-project/issues/118057
2024-12-05 11:58:37 -05:00
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