This code is creating a warning on Fuchsia, this patch should fix that
warning.
Reviewed By: mcgrathr
Differential Revision: https://reviews.llvm.org/D157546
Nvidia uses a 32-bit mask, but we store it in a common 64-bit integer to
provide it with a compatible ABI with the AMD implementaiton which may
use a 64-bit mask. Silence these warnings by explicitly casting to the
smaller value, we know this is always legal as the result will always
fit into the smaller value if it was generated on NVPTX.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D157548
For whatever reason, the CMake did not like having the `generic_`
version live in the same directory. This patch pushes them to a new
directory, which is probably clearer anyway.
Reviewed By: michaelrj
Differential Revision: https://reviews.llvm.org/D157544
This more closely matches the stricter warnings used for
this same code in the Fuchsia build.
Reviewed By: michaelrj
Differential Revision: https://reviews.llvm.org/D156630
The GPU has much tighter requirements for handling IO functions.
Previously we attempted to define the GPU as one of the platform files.
Using a common interface allowed us to easily define these functions
without much extra work. However, it became more clear that this was a
poor fit for the GPU. The file interface uses function pointers, which
prevented inlining and caused bad perfromance and resource usage on the
GPU. Further, using an actual `FILE` type rather than referring to it as
a host stub prevented us from usin files coming from the host on the GPU
device.
After talking with @sivachandra, the approach now is to simply define
GPU specific versions of the functions we intend to support. Also, we
are ignoring `errno` for the time being as it is unlikely we will ever
care about supporting it fully.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D157427
Sometimes the vfprintf test was failing, I suspect that's due to it
using the same filename as the fprintf test. This patch fixes that
problem by changing the filename of the vfprintf output file.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D157523
This patch fixes the floating point conversion warnings found with
`-Wconversion` and `-Wno-sign-conversion`. These were the last warnings
I found, meaning that once this lands https://reviews.llvm.org/D156630
should be unblocked.
Reviewed By: mcgrathr, lntue
Differential Revision: https://reviews.llvm.org/D157449
This patch adds support for yocto images, which are custom Linux-base
systems created by yocto.
$CMAKE_HOST_SYSTEM_NAME returns "poky" as the system name, but it is a
linux image, so we just replace the name with "linux", so libc can use
the correct path.
Reviewed By: michaelrj
Differential Revision: https://reviews.llvm.org/D157404
This patch is an alternative to D155902. It provides the following benefits:
- No buffer manual allocation and error handling for the general case
- More flexible API : width specifier, sign and prefix handling
- Simpler code
The more flexible API removes the need for manually tweaking the buffer afterwards, and so prevents relying on implementation details of IntegerToString.
Reviewed By: michaelrj, jhuber6
Differential Revision: https://reviews.llvm.org/D156981
tests not compile with `-ffreestanding` can pull unwanted dependencies like `limits.h` which defines `PTHREAD_STACK_MIN`.
This is what caused the build bot failure in https://reviews.llvm.org/D156981#4570776.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D157444
This patch is an alternative to D155902. It provides the following benefits:
- No buffer manual allocation and error handling for the general case
- More flexible API : width specifier, sign and prefix handling
- Simpler code
The more flexible API removes the need for manually tweaking the buffer afterwards, and so prevents relying on implementation details of IntegerToString.
Reviewed By: michaelrj, jhuber6
Differential Revision: https://reviews.llvm.org/D156981
Summrary:
Following D156014 we can now use aliases for NVPTX, removing this source
of divergence. We require at least +ptx63 and at least sm_30 for
`.alias` but this is already within what we build for with `libc`
support.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D157323
Update documentaiton now that macros are laid out in a more structured way.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D143911
This patch is large, but is almost entirely just adding casts to calls
to syscall_impl. Much of the work was done programatically, with human
checking when the syntax or types got confusing.
Reviewed By: mcgrathr
Differential Revision: https://reviews.llvm.org/D156950
Some printf implementations perform a null check on pointers passed to
%s. While that's not in the standard, this patch adds it as an option
for compatibility. It also puts a similar check in %n behind the same
flag.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D156923
This was generated using clang-tidy and clang-apply-replacements,
on src/string/*.cpp for just the llvmlibc-inline-function-decl
check, after applying https://reviews.llvm.org/D157164, and then
some manual fixup.
Reviewed By: abrachet
Differential Revision: https://reviews.llvm.org/D157169
The v variants of the printf functions take their variadic arguments as
a va_list instead of as individual arguments. They are otherwise
identical to the corresponding printf variants. This patch adds them
(vprintf, vfprintf, vsprintf, and vsnprintf) as well as tests.
Reviewed By: phosek
Differential Revision: https://reviews.llvm.org/D157138
This broke some bots that don't have linux/time_types.h available
(libc-x86_64-debian-*).
The header is needed because of __kernel_timespec, and since this is
only needed when SYS_sched_rr_get_interval_time64 is available, guarding
the include should fix the broken bot.
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 Fuchsia zxtest library has ASSERT_DEATH but not EXPECT_DEATH.
The latter may be added in the future, but for now just use the
former as substitute.
Reviewed By: abrachet
Differential Revision: https://reviews.llvm.org/D156940
Other libc implementations support underscores in NaN(n-char-sequence)
strings. Us not supporting that is causing fuzz failures, so this patch
solves the problem.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D156927
In 32-bit systems, sizeof(size_t) is 4, so we fail to build an 128-bit
integer in mul_shift_mod_1e9, which ends up ignoring the top bits in the
mantissa.
This patch fixes the issue by calling the Uint constructor directly. If
it's a system that supports 128-bit integers, the constructor that takes
a value will be called, if the system doesn't support 128-bit integers
(like rv32), mantissa is already a UInt.
Reviewed By: lntue, michaelrj
Differential Revision: https://reviews.llvm.org/D156813
This patch fixes the return time for sched_getscheduler which was set to
always zero. The syscall documentation, however, defines:
On success, sched_getscheduler() returns the policy for the thread (a
nonnegative integer).
I also changed the return type for sched_setscheduler, but this change
didn't impact and test case.
This patch also removes the duplicated code from param_and_scheduler_test.cpp
and adds SCHED_BATCH and SCHED_IDLE to the tests.
Reviewed By: michaelrj
Differential Revision: https://reviews.llvm.org/D156700
The GPU makes use of different address spaces. We generally work with
global memory, thread private memory, and thread shared memory. This
patch simply adds a few preliminary wrappers to map these concepts to
the numerical values the backend uses. Obviously casts between these
will need to be checked by the user.
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D156731
The other architectures use a brief sleep to defer work during this spin
loop that checks the RPC mailboxes. This patch adds one for x64 to
improve usage when running the server.
Reviewed By: tianshilei1992
Differential Revision: https://reviews.llvm.org/D156566
The number of trailing zeroes was being calculated incorrectly. It was
assuming that it could add all of the implicit leading zeroes in the
final block, not accounting for the number of digits actually reqested
by the precision.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D156489
Previously including SCUDO in a libc build with runtimes/ as root was
not possible since this code only checked for compiler-rt enabled via
LLVM_ENABLED_PROJECTS.
Reviewed By: thesamesam
Differential Revision: https://reviews.llvm.org/D156388
This patch adds support for `fread` on the GPU via the RPC mechanism.
Here we simply pass the size of the read to the server and then copy it
back to the client via the RPC channel. This should allow us to do the
basic operations on files now. This will obviously be slow for large
sizes due ot the number of RPC calls involved, this could be optimized
further by having a special RPC call that can initiate a memcpy between
the two pointers.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D155121
The expected number for the max ptrdiff value was expected to be exactly
4294967296 (2**32) for 32 bit systems, when it should be
4294967295 (2**32 - 1). This also adds a second test to check for this
case on non-32 bit systems.
Reviewed By: lntue, mikhail.ramalho
Differential Revision: https://reviews.llvm.org/D156257
Summray:
We landed some extra math support, which is apparently broken on the
max / min functions. the `mod` functions cannot be tested as they use
`std::limits` which don't exist in a freestanding environment. Also the
`blockstore` test seems to be broken. We will need to fix these in the
future but for now we need something in a workable state.
Reviewed By: jplehr
Differential Revision: https://reviews.llvm.org/D156329
It's necessary for the assert_fail function, so it needs to stay in for
the moment.
Reviewed By: alfredfo
Differential Revision: https://reviews.llvm.org/D156275
Previously displaying a failed assert would involve a runtime integer to
string conversion. This patch changes that to be a compile time string
conversion.
This was inspired by a comment by JonChesterfield on https://reviews.llvm.org/D155899
Reviewed By: lntue, sivachandra, JonChesterfield
Differential Revision: https://reviews.llvm.org/D156168