This patch implements `hcreate(_r)/hsearch(_r)/hdestroy(_r)` as
specified in https://man7.org/linux/man-pages/man3/hsearch.3.html.
Notice that `neon/asimd` extension is not yet added in this patch.
- The implementation is largely simplified from rust's
[`hashbrown`](https://github.com/rust-lang/hashbrown/blob/master/src/raw/mod.rs)
as we only consider fix-sized insertion-only hashtables. Technical
details are provided in code comments.
- This patch also contains a portable string hash function, which is
derived from [`aHash`](https://github.com/tkaitchuck/aHash)'s fallback
routine. Not using any SIMD acceleration, it has a good enough quality
(passing all SMHasher tests) and is not too bad in speed.
- Some general functionalities are added, such as `memory_size`,
`offset_to`(alignment), `next_power_of_two`, `is_power_of_two`.
`ctz/clz` are extended to support shorter integers.
Summary:
The POSIX standard expects the first argument to this function to be
constant, e.g. https://man7.org/linux/man-pages/man2/nanosleep.2.html.
This fixes that problem and also corrects an obvious problem with
enabling this for offloading.
limits.h currently interferes with Clang's limits.h. include_next
emits a warning because it is a GNU extension. Will re add this once
we figure out a good solution.
This reverts commits 13bbca8d69,
002cba0329, and
0fb3066873.
This header contains implementation specific constants.
The compiler already provides its own limits.h with numerical limits
conforming to freestanding ISO C. But it is missing extensions like
POSIX, and does for example not include <linux/limits.h> which is
expected on a Linux system, therefore, an LLVM libc implementation of
limits.h is needed for hosted (__STDC_HOSTED__) environments.
Reviewed By: michaelrj
Differential Revision: https://reviews.llvm.org/D156961
This patch adds a bunch of ifdefs to handle the 32 bit versions of
some syscalls, which often only append a 64 to the name of the syscall
(with exception of SYS_lseek -> SYS_llseek and SYS_futex ->
SYS_futex_time64)
This patch also tries to handle cases where wait4 is not available
(as in riscv32): to implement wait, wait4 and waitpid when wait4 is
not available, we check for alternative wait calls and ultimately rely
on waitid to implement them all.
In riscv32, only waitid is available, so we need it to support this
platform.
Reviewed By: michaelrj
Differential Revision: https://reviews.llvm.org/D148371
The current argument types are currently switched around for ftruncate
and truncate. Currently passes tests because the internal definitions
inside the __llvm_libc namespace are fine.
Reviewed By: michaelrj, thesamesam, sivachandra
Differential Revision: https://reviews.llvm.org/D152664
Missing in header for `pthread_exit` and `exit`.
Missing in spec file for `pthread_exit`.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D151143
This patch adds the function "socket" from the header "sys/socket". It's
a simple syscall wrapper, and I plan on adding the related functions in
a followup patch.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D149622
added getchar and getchar_unlocked which are just wrappers getc and getc_unlocked respectively.
Reviewed By: sivachandra, lntue, michaelrj
Differential Revision: https://reviews.llvm.org/D147919
Implements: https://linux.die.net/man/2/sched_yield
Possibly we don't need the return value check / errno as according to
both the manpage (and current linux source) `sched_yield` cannot fail.
Reviewed By: sivachandra, michaelrj
Differential Revision: https://reviews.llvm.org/D147985
+ Deleted duplicate definitions of StructTimeVal and StructTimeValPtr.
+ Caled syscall clock_gettime to get timespec data.
+ Added tests to test for sleeping 200 and 1000 microseconds.
+ Fixed comments from https://reviews.llvm.org/D137881
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D138064
Implement gettimeofday per
.../onlinepubs/9699919799/functions/gettimeofday.html.
This call clock_gettime to implement gettimeofday function.
Tested:
Limited unit test: This makes a call and checks that no error was
returned. Used nanosleep for 100 microseconds and verfified it
returns a value that elapses more than 100 microseconds and less
than 300 microseconds.
Co-authored-by: Jeff Bailey <jeffbailey@google.com>
Differential Revision: https://reviews.llvm.org/D137881
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
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
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
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
A very simple and minimal implementation of fork is added. Future
changes will add more functionality to satisfy POSIX and Linux
requirements.
An implementation of wait and a few support macros in sys/wait.h
have also been added to help with testing the fork function.
Reviewed By: lntue, michaelrj
Differential Revision: https://reviews.llvm.org/D135131
Add the syscall wrapper function and tests. It's implemented using a
macro to guarantee the minimum number of arguments.
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D134919
They were disabled because we were including linux/signal.h from our
signal.h. Linux's signal.h is not designed to be included from user
programs as it causes a lot of non-standard name pollution. Also, it is
not self-contained. This change defines types and macros relevant for
signal related syscalls within libc's headers and removes inclusion of
Linux headers.
This patch enables the funtions only for x86_64. They will be enabled
for aarch64 also in a follow up patch after testing.
Reviewed By: abrachet, lntue
Differential Revision: https://reviews.llvm.org/D134567
The existing thrd_once function has been refactored so that the
implementation can be shared between thrd_once and pthread_once
functions.
Reviewed By: michaelrj
Differential Revision: https://reviews.llvm.org/D134716
Tested:
Limited unit test: This makes a call and checks that no error was
returned, but we currently don't have the ability to ensure that
time has elapsed as expected.
Co-authored-by: Jeff Bailey <jeffbailey@google.com>
Reviewed By: sivachandra, jeffbailey
Differential Revision: https://reviews.llvm.org/D134095