Commit Graph

1160 Commits

Author SHA1 Message Date
Siva Chandra Reddy c03ea285bd [libc][Obvious] Add termios.h to the list of x86_64 linux headers. 2022-10-19 23:00:15 +00:00
Siva Chandra Reddy 67957368ae [libc] Add implementation of sigaltstack for linux.
Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D135949
2022-10-18 22:04:30 +00:00
Siva Chandra Reddy 18daa8255a [libc][Obvious] Skip some termios tests when there no is /dev/tty. 2022-10-18 20:58:50 +00:00
Siva Chandra Reddy b2a294bcf8 [libc] Add termios.h and the implementation of functions declared in it.
Reviewed By: lntue, michaelrj

Differential Revision: https://reviews.llvm.org/D136143
2022-10-18 20:53:00 +00:00
Guillaume Chatelet a786096f9d [libc][NFC] Cleanup and document utils.h 2022-10-18 14:32:39 +00:00
Guillaume Chatelet 2e3b8b31ce [libc][NFC] Use ASSERT instead of EXPECT in tests 2022-10-18 14:32:39 +00:00
Jeff Bailey 7caae24473 [libc]Identify which processors are completed for Math
Switch from green checkmarks to the following legend:

X = x86_64
A = aarch64
a = arm32

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D136020
2022-10-18 03:12:44 +00:00
Michael Jones 40b494396b [libc] add putc, fputc, and putchar
These three functions are simple, but needed for libc build testing.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D135990
2022-10-17 16:29:04 -07:00
Jeff Bailey 998d1ebb27 [libc][cleanup] Docs clean up
* Make consistent heading names
 * Factor out |check| into an include for reuse
 * Use it everywhere (No more YES or UTF-8)
 * Remove unneeded summary from pages. People know why they're there.
 * Ensure source location headers everywhere.

Differential Revision: https://reviews.llvm.org/D136016
2022-10-15 15:29:48 +00:00
Sterling Augustine d8415b02a5 Revert "[libc] New version of the mem* framework"
This reverts commit https://reviews.llvm.org/D135134 (b3f1d58a13)

That revision appears to have broken Arm memcpy in some subtle
ways. Am communicating with the original author to get a
good reproduction.
2022-10-14 12:32:20 -07:00
Siva Chandra Reddy 8b0e84a6f6 [libc] Add implementation of the POSIX getcwd function.
Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D135905
2022-10-14 16:20:59 +00:00
Guillaume Chatelet b3f1d58a13 [libc] New version of the mem* framework
This version is more composable and also simpler at the expense of being more explicit and more verbose. It also provides minimal implementations for ARM platforms.

    Codegen can be checked here https://godbolt.org/z/chf1Y6eGM

    Differential Revision: https://reviews.llvm.org/D135134
2022-10-14 13:46:42 +00:00
Guillaume Chatelet 6d252a4888 Revert "[libc] New version of the mem* framework"
This reverts commit 9721687835.
2022-10-14 13:21:52 +00:00
Guillaume Chatelet 84f887c82b Revert "[libc] Fix embedded version of bcmp / memcmp"
This reverts commit 7c9b8fa6d2.
2022-10-14 13:21:19 +00:00
Guillaume Chatelet 7c9b8fa6d2 [libc] Fix embedded version of bcmp / memcmp 2022-10-14 13:09:53 +00:00
Guillaume Chatelet 9721687835 [libc] New version of the mem* framework
This version is more composable and also simpler at the expense of being more explicit and more verbose. It also provides minimal implementations for ARM platforms.

Codegen can be checked here https://godbolt.org/z/x19zvE59v

Differential Revision: https://reviews.llvm.org/D135134
2022-10-14 12:42:54 +00:00
Guillaume Chatelet 4fed4b0943 Revert "[libc] New version of the mem* framework"
This reverts commit 98bf836f31.
2022-10-14 12:27:04 +00:00
Guillaume Chatelet 98bf836f31 [libc] New version of the mem* framework
This version is more composable and also simpler at the expense of being more explicit and more verbose. It also provides minimal implementations for ARM platforms.

Codegen can be checked here https://godbolt.org/z/x19zvE59v

Differential Revision: https://reviews.llvm.org/D135134
2022-10-14 12:25:03 +00:00
Siva Chandra Reddy 02a543db66 [libc] Add a simple implementation of the posix_spawn function.
The implementation currently ignores all spawn attributes. Support for
them will be added in future changes.

A simple allocator for integration tests has been added so that the
integration test for posix_spawn can use the
posix_spawn_file_actions_add* functions.

Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D135752
2022-10-13 18:47:47 +00:00
Guillaume Chatelet 9d1f6466e5 Revert "[libc] New version of the mem* framework"
This reverts commit d55f2d8ab0.
2022-10-13 14:49:58 +00:00
Guillaume Chatelet d55f2d8ab0 [libc] New version of the mem* framework
This version is more composable and also simpler at the expense of being more explicit and more verbose. It also provides minimal implementations for ARM platforms.

Codegen can be checked here https://godbolt.org/z/x19zvE59v

Differential Revision: https://reviews.llvm.org/D135134
2022-10-13 14:44:03 +00:00
Michael Jones 35a4fe4c0b [libc] add headers sys/auxv sys/prctl and sys/time
These headers are uncommonly used, and from extensions, but some basic
support is needed. Macros have been added where available.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D135731
2022-10-12 13:19:50 -07:00
Guillaume Chatelet e431731e08 Revert "[libc] New version of the mem* framework"
This reverts commit 4c19439d24.
2022-10-12 15:35:18 +00:00
Guillaume Chatelet 4c19439d24 [libc] New version of the mem* framework
This version is more composable and also simpler at the expense of being more explicit and more verbose.
This patch is not meant to be submitted but gives an idea of the change.
Codegen can be checked in https://godbolt.org/z/6z1dEoWbs by removing the "static inline" before individual functions.

Unittests are coming.

Suggested review order:
 - utils
 - op_base
 - op_builtin
 - op_generic
 - op_x86 / op_aarch64
 - *_implementations.h

Differential Revision: https://reviews.llvm.org/D135134
2022-10-12 15:26:26 +00:00
Andre Vieira bc71aa4fbc [libc] Update benchmarks/README.md
This patch updates the instructions on how to run the mem* benchmarks in
README.md.

Differential Revision: https://reviews.llvm.org/D135582
2022-10-12 16:13:24 +01:00
Siva Chandra Reddy 28943d617a [libc] Add POSIX functions posix_spawn_file_actions_*.
Namely, posix_spawn_file_actions_addclose,
posix_spawn_file_actions_adddup2, posix_spawn_file_actions_addopen,
posix_spawn_file_actions_destroy, posix_spawn_file_actions_init have
been added.

Reviewed By: michaelrj, lntue

Differential Revision: https://reviews.llvm.org/D135603
2022-10-11 04:54:44 +00:00
Michael Jones a6abcfee8a [libc] fix header list for x86_64
Some headers hadn't been added, this fixes that and improves the
ordering.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D135629
2022-10-10 16:05:53 -07:00
Michael Jones aec239cdb8 [libc] reset errno in isatty tests
Errno wasn't getting reset between tests, causing cascading failures.

Differential Revision: https://reviews.llvm.org/D135627
2022-10-10 15:49:48 -07:00
Michael Jones 707996e486 [libc] handle case where /dev/tty doesn't exist
In the isatty test it was assumed that /dev/tty existed, but that's not
always the case. Now we check for that.

Differential Revision: https://reviews.llvm.org/D135626
2022-10-10 15:40:52 -07:00
Michael Jones 7639ba6906 [libc] add isatty
The isatty function uses the side effects of an ioctl call to determine
if a specific file descriptor is a terminal. I chose TIOCGETD (get line
discipline of terminal) because it didn't require any new structs.

Reviewed By: sivachandra, lntue

Differential Revision: https://reviews.llvm.org/D135618
2022-10-10 15:20:46 -07:00
Michael Jones 1ac525b28b [libc] add sysconf with pagesize
The sysconf function has many options, this patch adds the basic funtion
and the pagesize option. More options will be added in future patches.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D135409
2022-10-10 14:51:45 -07:00
Siva Chandra Reddy 438e59182b [libc] Add implementation of pthread_atfork.
Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D135432
2022-10-10 18:28:43 +00:00
Schrodinger ZHU Yifan 9eb11856cf Implement `getrandom` function for linux targets.
Reviewed By: michaelrj, sivachandra

Differential Revision: https://reviews.llvm.org/D134665
2022-10-10 11:00:35 -07:00
Jeff Bailey aa8ab5b213 [libc] Document which date funcs are needed/done
Reviewed By: rtenneti

Differential Revision: https://reviews.llvm.org/D135501
2022-10-08 00:06:22 +00:00
Michael Jones 7c7f331a00 [libc][nfc] fix comment in clock_gettime
The first line got split because it was too long. Now it's fixed.

Differential Revision: https://reviews.llvm.org/D135498
2022-10-07 16:17:41 -07:00
Michael Jones 07c0a41b53 [libc] add printf decimal float conversion
This patch adds support for converting doubles to string in the %f/F
format specifier. It does not yet support long doubles outside of the
double range. This implementation is based on the work of Ulf Adams,
specifically the Ryu Printf algorithm.

See:
Ulf Adams. 2019. Ryū revisited: printf floating point conversion.
Proc. ACM Program. Lang. 3, OOPSLA, Article 169 (October 2019), 23 pages.
https://doi.org/10.1145/3360595

Differential Revision: https://reviews.llvm.org/D131023
2022-10-07 11:25:25 -07:00
Michael Jones 07793f95c4 [libc] add strsignal and refactor message mapping
The logic for strsignal and strerror is very similar, so I've moved them
both to use a shared utility (MessageMapper) for the basic
functionality.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D135322
2022-10-07 11:11:53 -07:00
Michael Jones a9f95b769e [libc] add strerror_r function
I've implemente the gnu variant of strerror_r since that seems to be the
one more relevant to what we're trying to do.

Differential Revision: https://reviews.llvm.org/D135227
2022-10-07 11:07:06 -07:00
Dominic Chen 74ec467964 [libc] Resolve NaN/implementation-defined behavior of floating-point tests
Differential Revision: https://reviews.llvm.org/D134917
2022-10-06 21:11:47 -07:00
Michael Jones 6d65ac5009 [libc][obvious] move kill into fullbuild only
Signal is currently fullbuild only, so all functions inside it should be
as well.

Differential Revision: https://reviews.llvm.org/D135410
2022-10-06 15:35:45 -07:00
Michael Jones 9015810648 [libc] add kill
Add the kill syscall wrapper and tests.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D135406
2022-10-06 15:25:56 -07:00
Michael Jones f2a9974666 [libc] fix futex type
Previously the futex type was defined in terms of unsigned int, now it's
uint32, which is more portable.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D135408
2022-10-06 15:19:43 -07:00
Siva Chandra Reddy 3f965818b6 [libc] Add POSIX execv and execve functions.
The POSIX global variable environ has also been added.

Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D135351
2022-10-06 19:50:23 +00:00
Dominic Chen 8f10d204d1 Revert "[libc] Resolve NaN/implementation-defined behavior of floating-point tests"
This reverts commit 5470b1fcb5.
2022-10-05 16:33:32 -07:00
Dominic Chen 5470b1fcb5 [libc] Resolve NaN/implementation-defined behavior of floating-point tests
Differential Revision: https://reviews.llvm.org/D134917
2022-10-05 16:23:19 -07:00
Siva Chandra Reddy 3e1986682f [libc][Obvious] Add "__" prefix to sched_getcpucount in the spec and elsewhere.
Without this fix, the declaration in sched.h will not have the "__" prefix and
will cause a compile failure.

Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D135286
2022-10-05 18:01:13 +00:00
Siva Chandra Reddy 995105de1b [libc] Add the POSIX waitpid function and the BSD wait4 function.
Reviewed By: lntue, michaelrj

Differential Revision: https://reviews.llvm.org/D135225
2022-10-05 07:38:55 +00:00
Michael Jones a9c7d0e1ae [libc] fix fullbuild handling for macro functions
Now they're only included at all if the mode is fullbuild.

Differential Revision: https://reviews.llvm.org/D135221
2022-10-04 15:37:31 -07:00
Michael Jones 0b790afb06 [libc] add CPU_COUNT macro and backing function
Add the macro CPU_COUNT as well as a backing function to implement the
functionality.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D135179
2022-10-04 15:22:55 -07:00
Michael Jones 38b6f58e33 [libc] implement basic rand and srand
This provides the reference implementation of rand and srand. In future
this will likely be upgraded to something that supports full ints.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D135187
2022-10-04 13:31:26 -07:00