The memory functions are highly performance sensitive and use builtins
where possible, but also need to define those functions names when they
don't exist to avoid compilation errors. Previously all those
redefinitions were behind the SSE2 flag for x86, which caused errors on
CPUs that supported SSE2 but not AVX512. This patch splits the various
CPU extensions out to avoid errors on such CPUs.
Reviewed By: gchatelet
Differential Revision: https://reviews.llvm.org/D138163
This patch adds scanf, sscanf, and fscanf entrypoints. It also adds unit
tests for sscanf and a basic test to fscanf. The scanf function is
basically impossible to test in an automated fashion due to it recieving
user input.
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D138076
The memory functions are highly performance sensitive and use builtins
where possible, but also need to define those functions names when they
don't exist to avoid compilation errors. Previously all those
redefinitions were behind the SSE2 flag for x86, which caused errors on
CPUs that supported SSE2 but not AVX512. This patch splits the various
CPU extensions out to avoid errors on such CPUs.
Reviewed By: gchatelet
Differential Revision: https://reviews.llvm.org/D137868
The `assert.h` and `ctype.h` headers are never built despite their
entrypoints being present in the generated library. This patch adds a
dependency on these headers so that they will be built properly.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D138142
+ Avoid the `clockid` var and just passed `long(CLOCK_REALTIME)`
to the syscall.
Reviewed By: rtenneti
Differential Revision: https://reviews.llvm.org/D138070
The mprotect test has been failing and causing significant buildbot
noise. Given that this is a simple functions it's more important that
the buildbot errors be useful than having more thorough tests for this
function.
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D138061
+ 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
The assert functions were disabled while the signal functions were being
fixed. This patch re-enables them.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D138056
When using `LLVM_ENABLE_RUNTIMES=libc` we need to perform a few extra
steps to include LLVM utilities similar to if we were performing a
standalone build. Libc depends on the tablegen utilities and the LLVM
libraries when performing a full build. When using an
`LLVM_ENABLE_PROJECTS=libc` build these are included as a part of the
greater LLVM build, but here we need to perform it maunally. This patch
should allow using `LLVM_LIBC_FULL_BUILD=ON` when building with
runtimes.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D138040
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
Fork, as a thread function, should go in the threads folder.
Additionally, it depends on the thread mutex, and it was causing build
issues for targets where we don't support threads.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D137867
In the code
const char *str = "abc"
if you do sizeof(str) you get the size of the pointer, not the string.
This patch fixes that mistake.
Differential Revision: https://reviews.llvm.org/D137586
This patch adds the basic conversion facilities to scanf as well as unit
tests for them. It also adds scanf_main which will be used for the
eventual scanf entrypoints.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D137376
This is the interface that will be used to read from a file or string in
scanf. This patch also adds the string and file implementations of the
reader, although the file reader is not yet complete since ungetc has
not yet been implemented.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D137117
Previously, the printf parser would treat "%\0" as a conversion with the
name "\0", and advance past the null byte causing a buffer overflow.
This patch corrects that in both printf and scanf.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D137367
These examples are serve as an examples for people wanting to start
using the libc.
Reviewed By: michaelrj, jeffbailey
Differential Revision: https://reviews.llvm.org/D137090
A bug in the file read logic has also been fixed along the way. Parts
of the ungetc tests will fail without that bug fixed.
Reviewed By: michaelrj
Differential Revision: https://reviews.llvm.org/D137286
The new framework makes it explicit which processor feature is being
used and allows for easier per platform customization:
- ARM cpu now uses trivial implementations to reduce code size.
- Memcmp, Bcmp and Memmove have been optimized for x86
- Bcmp has been optimized for aarch64.
This is a reland of https://reviews.llvm.org/D135134 (b3f1d58, 0284148813)
Reviewed By: courbet
Differential Revision: https://reviews.llvm.org/D136595
This patch extracts the testing logic from `op_tests.cpp` into
`memory_check_utils.h` so we can reuse it for mem* function integration
tests.
This makes testing consistent and thorough.
For instance this catches a bug that got unnoticed during submission of
D136595 and D135134. Integration test for memcmp was only testing a
single size.
This also leverages ASAN to make sure that data is not read / written
outside permitted boundaries
Differential Revision: https://reviews.llvm.org/D136865