aboutsummaryrefslogtreecommitdiff
path: root/libc
AgeCommit message (Collapse)AuthorFilesLines
2024-04-01[libc] fixup ftello test (#87282)Nick Desaulniers1-1/+1
Use a seek offset that fits within the file size. This was missed in presubmit because the FILE based stdio tests aren't run in overlay mode; fullbuild is not tested in presubmit. WRITE_SIZE == 11, so using a value of 42 for offseto would cause the expression `WRITE_SIZE - offseto` to evaluate to -31 as an unsigned 64b integer (18446744073709551585ULL). Fixes #86928
2024-04-01[libc][math] Implement atan2f correctly rounded to all rounding modes. (#86716)lntue22-73/+634
We compute atan2f(y, x) in 2 stages: - Fast step: perform computations in double precision , with relative errors < 2^-50 - Accurate step: if the result from the Fast step fails Ziv's rounding test, then we perform computations in double-double precision, with relative errors < 2^-100. On Ryzen 5900X, worst-case latency is ~ 200 clocks, compared to average latency ~ 60 clocks, and average reciprocal throughput ~ 20 clocks.
2024-04-01[libc] fixup missing include for fullbuild (#87266)Nick Desaulniers2-0/+2
Fixes #86928
2024-04-01[libc][POSIX] implement fseeko, ftello (#86928)Shourya Goel11-4/+130
Fixes: #85287
2024-04-01[libc] Include algorithm.h to parser.h (#87125)Caslyn Tonelli2-0/+2
This includes algorithm.h directly to provide the definition for `cpp:max` in parser.h. This will define `max(...)` in the libc namespace for build systems that pull in parser.h explicitly.
2024-03-29[libc] enable stack protectors and frame pointers on default (#86288)Schrodinger ZHU Yifan3-0/+22
2024-03-29[libc][math][c23] Fix impl and tests for X86_80 canonicalize function. (#87103)Shourya Goel3-55/+54
In continuation to: #87097
2024-03-29[libc][Docs] Update RPC server example using CUDA after changesJoseph Huber1-11/+4
Summary: This has changed, so update it to match the new interface.
2024-03-29[libc] Change RPC interface to not use device ids (#87087)Joseph Huber5-150/+85
Summary: The current implementation of RPC tied everything to device IDs and forced us to do init / shutdown to manage some global state. This turned out to be a bad idea in situations where we want to track multiple hetergeneous devices that may report the same device ID in the same process. This patch changes the interface to instead create an opaque handle to the internal device and simply allocates it via `new`. The user will then take this device and store it to interface with the attached device. This interface puts the burden of tracking the device identifier to mapped d evices onto the user, but in return heavily simplifies the implementation.
2024-03-29[libc] Fix missing UINTMAX_WIDTH (#87092)Michael Jones1-3/+4
In patch #82461 the sprintf tests were made to use UINTMAX_WIDTH which isn't defined on all systems. This patch changes it to sizeof(uintmax_t)*CHAR_BIT which is more portable.
2024-03-29Add bit width length modifier to printf (#82461)Om Prakaash9-18/+215
Resolves #81685. This adds support for wN and wfN length modifiers in fprintf.
2024-03-28[libc] Add inf/nan tests for strfrom*() functions (#86663)Vinayak Dev2-7/+73
Adds tests for `inf` and `nan` values to the tests for `strfrom*()` functions. Also marks some variables as `[[maybe_unused]]` to silence unused variable warnings.
2024-03-28Revert "[libc][math][c23] Fix X86_Binary80 special cases for canonicalize ↵Nick Desaulniers3-54/+56
functions. (#86924)" This reverts commit 7c1c07c92099d3e36e8f362706a5824ab04bdf38. Fails in presubmit. Link: https://lab.llvm.org/buildbot/#/builders/90/builds/67461 Link: https://lab.llvm.org/buildbot/#/builders/225/builds/33519 Link: https://lab.llvm.org/buildbot/#/builders/163/builds/53858 Link: https://lab.llvm.org/buildbot/#/builders/250/builds/20983 Link: #86924
2024-03-28[libc][math][c23] Fix X86_Binary80 special cases for canonicalize functions. ↵Shourya Goel3-56/+54
(#86924) Updates the special case of pseudo infinty as pointed in #85940
2024-03-28[libc][math][c23] Fix bounds checking and add FE_INVALID raising in ↵OverMighty5-481/+975
{,u}fromfp{,x}* (#86892) See https://github.com/llvm/llvm-project/pull/86692#issuecomment-2024044889 and https://github.com/llvm/llvm-project/pull/86892#discussion_r1542276037. cc @lntue @nickdesaulniers
2024-03-28[libc][support][FixedVector] add reverse iterator (#86732)Nick Desaulniers2-0/+24
Critically, we don't want to return an iterator to the end of the underlying cpp::array "store." Add a test to catch this issue. This will be used by __cxa_finalize to iterate backwards through a FixedVector. Link: #85651
2024-03-28[libc] s/NULL/nullptr (#86867)Nick Desaulniers5-8/+8
Otherwise we need to pull in stddef.h for the declaration of NULL.
2024-03-28[libc] Disable testing for NVPTX debug builds (#86856)Joseph Huber1-0/+5
Summary: Debug builds don't optimize out certain parts of the code that end up making the GPU backend crash. This results in regular builds not being successful just to build the testing objects. Disable them for now in debug mode.
2024-03-27[libc] Move baremetal write_to_stderr implementation to io.cpp (#86890)Petr Hosek3-6/+24
This is required to avoid multiple definitions error.
2024-03-27[libc][NFC] refactor fmin and fmax (#86718)Job Henandez Lara1-14/+10
Hello, So, I worked on the fmaximum and fminimum functions recently and the reviewers suggested the structure: ``` if (bitsx ...) return ...; if (bitsy ..) return ... return ...; ``` So I went ahead and did the same for fmin and fmax. I hope this isnt an issue for you all. thanks. --------- Co-authored-by: Job Hernandez <h93@protonmail.com>
2024-03-27[libc] add flag for FP_*LOGB0/NAN values (#86723)Michael Jones1-2/+7
These values vary by system, this flag allows you to toggle their value.
2024-03-27Revert "[libc][math][c23] Add remaining linux/* entrypoints for ↵Nick Desaulniers4-60/+16
{,u}fromfp{,x}* (#86692)" This reverts commit cd17082b24079a31eff0057abe407da5cfb7b0fc because the newly added tests fail on 32b ARM. Link: #86692 Link: https://lab.llvm.org/buildbot/#/builders/229/builds/24458
2024-03-27[libc][math][c23] Add remaining linux/* entrypoints for {,u}fromfp{,x}* (#86692)OverMighty4-16/+60
2024-03-27[libc] Remove obsolete LIBC_HAS_BUILTIN macro (#86554)Marc Auberer25-103/+77
Fixes #86546 and removes the macro `LIBC_HAS_BUILTIN`. This was necessary to support older compilers that did not support `__has_builtin`. All of the compilers we support already have this builtin. See: https://libc.llvm.org/compiler_support.html All uses now use `__has_builtin` directly cc @nickdesaulniers
2024-03-27[libc][support][UInt] implement 128b math helpers (#86531)Nick Desaulniers4-11/+66
Flush out the remaining UInt<128> support and add test coverage. We could have used cpp::popcount in the implementation of UInt::has_single_bit, but has_single_bit has a perhaps useful early return.
2024-03-26[libc][FPUtil] fixup missing explicit cast (#86736)Nick Desaulniers1-1/+1
The arm32 buildbot reports an error because UInt::operator bool() is explicit, thus an explicit cast is necessary. Link: #85940
2024-03-26[libc] Fix misplaced `[[noreturn]]` attribute.Joseph Huber1-1/+1
Summary: This needs to go after `extern "C"`.
2024-03-26[libc] Remove LIBC_HAS_ATTRIBUTE macro (#86656)Vinayak Dev2-9/+1
Resolves #86547 Replace occurrences of the macro `LIBC_HAS_ATTRIBUTE` with `__has_attribute`.
2024-03-26[libc]: Remove unused includes from strfrom*.cpp (#86657)Vinayak Dev3-9/+0
Removes unused header includes from `strfrom*()` implementation files.
2024-03-26[libc] Remove definition of LIBC_NAMESPACE in test (#86704)Michael Jones1-2/+0
The canonicalize test added in #85940 defined the LIBC_NAMESPACE macro. this macro is intended to be set only by the build system and never in the code.
2024-03-26[libc][OSUtil] refactor quick_exit to be an object library everywhere (#85955)Nick Desaulniers14-111/+31
The usage of __builtin_unreachable after calls to quick_exit were distressing. If a function is properly marked [[noreturn]] then __builtin_unreachable is not necessary. Looking into this further, we seem to have header only implementations for CPU targets. The inline nature of these functions is curious; we're going to exit, it doesn't matter if we need to pay the call of a function or not. If we just make these functions have distinct TUs rather than be header only, we can clean up the cmake rules for quick_exit which were different between CPU and GPU. Remove darwin support for quick_exit. This isn't being tested, and we can bring it back when necessary.
2024-03-26[libc][math][c23] Implement canonicalize functions (#85940)Shourya Goel21-267/+892
Fixes: #85286
2024-03-25[libc][math][c23] add c23 floating point fmaximum and fminimum functions. ↵Job Henandez Lara114-0/+3547
(#86016) Fixes https://github.com/llvm/llvm-project/issues/85496. --------- Co-authored-by: Job Hernandez <h93@protonmail.com>
2024-03-25[libc] add statvfs/fstatvfs (#86169)Schrodinger ZHU Yifan22-0/+495
fixes #86449
2024-03-25[libc][NFC] fix typo (#86540)Alan Zhao1-2/+2
2024-03-25[libc][math][c23] Add {,u}fromfp{,x}{,f,l,f128} functions (#86003)OverMighty63-16/+3180
Fixes #85279. cc @lntue
2024-03-22[libc] Implement strfromd() and strfroml() (#86113)Vinayak Dev13-97/+650
Follow up to #85438. Implements the functions `strfromd()` and `strfroml()` introduced in C23, and unifies the testing framework for `strfrom*()` functions.
2024-03-22Fix typo (#86319)Job Henandez Lara1-1/+1
Im working on the floating point fmaximum and fminimum functions right now in a different pr and I ran the individual tests by doing ``` ninja libc.test.src.math.smoke.<func>_test.__unit__ ```
2024-03-22[libc][stdlib] initial support for __cxa_finalize (#85865)Nick Desaulniers2-17/+22
I'm trying to break up the pieces of supporting __cxa_finalize into smaller commits. Provide this symbol first, and make use of it from exit. Next will be to store __dso_handle, then finally to only run callbacks that were registered from a specific dso. Link: #85651 Link: https://itanium-cxx-abi.github.io/cxx-abi/abi.html#dso-dtor
2024-03-22[libc] fix up the use of angle includes in include/ (#86027)Nick Desaulniers76-131/+131
Performed en-masse via: $ grep -rn "#include <ll" libc/include -l | \ xargs perl -pi -e 's/#include <ll(.*)>/#include "ll$1"/' $ grep -rn "#include <__" libc/include -l | \ xargs perl -pi -e 's/#include <__(.*)>/#include "__$1"/' Link: #83463 Link: #83210
2024-03-22[reland][libc] Add reverse_iterator comparisons (#86188)Guillaume Chatelet1-0/+35
This is a reland of #86147 but with a proper `base()` function. https://en.cppreference.com/w/cpp/iterator/reverse_iterator/operator_cmp
2024-03-21[libc] Make math-macros.h C++-friendly (#86206)Roland McGrath1-4/+28
The isfinite, isnan, and isinf "functions" are specified by C99..C23 to be macros that act as type-generic functions. Defining them as their __builtin_* counterparts works fine for this. However, in C++ the identifiers need to be usable in different contexts, such as being declared inside a C++ namespace. So define inline constexpr template functions for them under `#ifdef __cplusplus`.
2024-03-21Revert "[libc] Add reverse_iterator comparisons" (#86186)Guillaume Chatelet1-35/+0
Reverts llvm/llvm-project#86147
2024-03-21[libc] Add reverse_iterator comparisons (#86147)Guillaume Chatelet1-0/+35
https://en.cppreference.com/w/cpp/iterator/reverse_iterator/operator_cmp
2024-03-21[libc][stdio] implement rename via SYS_renameat2 (#86140)Nick Desaulniers2-2/+4
SYS_rename may be unavailable on architectures such as aarch64 and riscv. rename can be implemented in terms of SYS_rename, SYS_renameat, or SYS_renameat2. I don't have a full picture of the history here, but it seems that SYS_renameat might also be unavailable on some platforms. `man 2 rename` mentions that SYS_renameat2 was added in Linux 3.15. We don't need to support such ancient kernel versions prior. Link: #84980 Link: #85068
2024-03-21[libc] Add `is_constant_evaluated` type_traits (#86139)Guillaume Chatelet3-2/+25
This will replace `__builtin_is_constant_evaluated` in math_extras.h.
2024-03-21[libc][stdio][test] fixup rename test (#86136)Nick Desaulniers2-1/+3
Link: #84980 Link: #85068
2024-03-21[libc][c11] Add stdio.h's rename() function (#85068)aniplcc11-1/+136
Adds stdio.h's rename() function as defined in n3096. Fixes #84980.
2024-03-20[libc] Add an option to always build GPU loader utilities (#86040)Joseph Huber1-1/+2
Summary: Right now it's difficult to build these utilities standalone becayse they're keyed off of the other GPU handling. if someone wants to *just* build these utilities it's not possible without setting up the runtimes build. Since we can't just build these by default add an option to enable it. We can't just use the handling like LIBC_HDRGEN does because this is only for the GPU build, which isn't fully set up until way later. So this is probably the easiest way to just allow people to build these tools even without a GPU build setup.
2024-03-20[libc]: Implement strfromf() and shared utilities (#85438)Vinayak Dev8-1/+343
Fixes #84244. Implements the function `strfromf()` introduced in C23, and adds shared utilities for implementation of other `strfrom*()` functions, including `strfromd()` and `strfroml()`.