| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 8 个月前 | ||
[libc][math] Add float-only implementation for sinf / cosf. (#161680) Based on the double precision's sin/cos fast path algorithm: Step 1: Perform range reduction y = x mod pi/8 with target errors < 2^-54. This is because the worst case mod pi/8 for single precision is ~2^-31, so to have up to 1 ULP errors from the range reduction, the targeted errors should be 2^(-31 - 23) = 2^-54. Step 2: Polynomial approximation We use degree-5 and degree-4 polynomials to approximate sin and cos of the reduced angle respectively. Step 3: Combine the results using trig identities math \begin{align*} \sin(x) &= \sin(y) \cdot \cos(k \cdot \frac{\pi}{8}) + \cos(y) \cdot \sin(k \cdot \frac{\pi}{8}) \\ \cos(x) &= \cos(y) \cdot \cos(k \cdot \frac{\pi}{8}) - \sin(y) \cdot \sin(k \cdot \frac{\pi}{8}) \end{align*} Overall errors: <= 3 ULPs for default rounding modes (tested exhaustively). Current limitation: large range reduction requires FMA instructions for binary32. This restriction will be removed in the followup PR. --------- Co-authored-by: Petr Hosek <phosek@google.com> | 9 个月前 | |
[libc] replace for loops with a call to memcpy in File (#165219) Addresses TODOs in file.cpp by replacing data copies via for loops with calls to inline_memcpy. Signed-off-by: Shreeyash Pandey <shreeyash335@gmail.com> | 8 个月前 | |
[libc] Add a config option to disable slab reclaiming (#151599) Summary: Without slab reclaiming this interface is much simpler and it can speed up cases with a lot of churn. Basically, wastes memory for performance. | 9 个月前 | |
[libc][NFC] Add stdint.h proxy header to fix dependency issue with <stdint.h> includes. (#150303) https://github.com/llvm/llvm-project/issues/149993 | 1 年前 | |
Reapply "[libc] Return errno from OFD failure paths in fcntl." (#166658) (#166846) The previous implementation in #166252 (rolled back in #166658) caused buildbot failures due to a bug in an added test. The modified UseAfterClose did not pass a struct flock value to fcntl: https://github.com/llvm/llvm-project/blob/2d5170594147b42a37698760d6e0194eec4f1390/libc/test/src/fcntl/fcntl_test.cpp#L175 Which ASAN caught and errored in the fcntl implementation when the unspecified argument was accessed: https://github.com/llvm/llvm-project/blob/c12cb2892c808af459eaa270b8738a2b375ecc9b/libc/src/__support/OSUtil/linux/fcntl.cpp#L59 | 8 个月前 | |
[libc][NFC] Fix warnings in RPC server code | 8 个月前 | |
[libc] Use anonymous namespace for file-local symbols (#157202) A namespace like LIBC_NAMESPACE::internal should only ever be defined if it's providing global symbols declared in headers. These StringUtil implementations were defining global namespaced symbols for their file-local helper code, which they should not. | 10 个月前 | |
[libc][stdfix] Implement fxdivi functions (rdivi) (#154914) This PR includes only one of the fxdivi functions (rdivi). It uses a polynomial function for initial approximation followed by 4 newton-raphson iterations to calculate the reciprocal and finally multiplies the numerator with it to get the result. --------- Signed-off-by: Shreeyash Pandey <shreeyash335@gmail.com> | 9 个月前 | |
[libc] add cpu feature flags for SVE/SVE2/MOPS (#166884) Add in SVE/SVE2/MOPS features for aarch64 cpus. These features may be interesting for future memory/math routines. SVE/SVE2 are now being accepted in more implementations: ❯ echo | clang-21 -dM -E - -march=native | grep -i ARM_FEAT #define __ARM_FEATURE_ATOMICS 1 #define __ARM_FEATURE_BF16 1 #define __ARM_FEATURE_BF16_SCALAR_ARITHMETIC 1 #define __ARM_FEATURE_BF16_VECTOR_ARITHMETIC 1 #define __ARM_FEATURE_BTI 1 #define __ARM_FEATURE_CLZ 1 #define __ARM_FEATURE_COMPLEX 1 #define __ARM_FEATURE_CRC32 1 #define __ARM_FEATURE_DIRECTED_ROUNDING 1 #define __ARM_FEATURE_DIV 1 #define __ARM_FEATURE_DOTPROD 1 #define __ARM_FEATURE_FMA 1 #define __ARM_FEATURE_FP16_SCALAR_ARITHMETIC 1 #define __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 1 #define __ARM_FEATURE_FRINT 1 #define __ARM_FEATURE_IDIV 1 #define __ARM_FEATURE_JCVT 1 #define __ARM_FEATURE_LDREX 0xF #define __ARM_FEATURE_MATMUL_INT8 1 #define __ARM_FEATURE_NUMERIC_MAXMIN 1 #define __ARM_FEATURE_PAUTH 1 #define __ARM_FEATURE_QRDMX 1 #define __ARM_FEATURE_RCPC 1 #define __ARM_FEATURE_SVE 1 #define __ARM_FEATURE_SVE2 1 #define __ARM_FEATURE_SVE_BF16 1 #define __ARM_FEATURE_SVE_MATMUL_INT8 1 #define __ARM_FEATURE_SVE_VECTOR_OPERATORS 2 #define __ARM_FEATURE_UNALIGNED 1 MOPS is another set of extension for string operations, but may not be generally available for now: ❯ echo | clang-21 -dM -E - -march=armv9.2a+mops | grep -i MOPS #define __ARM_FEATURE_MOPS 1 | 8 个月前 | |
[libc][math] Add float-only implementation for atanf. (#167004) Algorithm: 1) atan(x) = sign(x) * atan(|x|) 2) If |x| > 1 + 1/32, atan(|x|) = pi/2 - atan(1/|x|) 3) For 1/16 < |x| < 1 + 1/32, we find k such that: | |x| - k/16 | <= 1/32. Let y = |x| - k/16, then using the angle summation formula, we have: atan(|x|) = atan(k/16) + atan( (|x| - k/16) / (1 + |x| * k/16) ) = atan(k/16) + atan( y / (1 + (y + k/16) * k/16 ) = atan(k/16) + atan( y / ((1 + k^2/256) + y * k/16) ) 4) Let u = y / (1 + k^2/256), then we can rewritten the above as: atan(|x|) = atan(k/16) + atan( u / (1 + u * k/16) ) ~ atan(k/16) + (u - k/16 * u^2 + (k^2/256 - 1/3) * u^3 + + (k/16 - (k/16)^3) * u^4) + O(u^5) With all the computations are done in single precision (float), the total of approximation errors and rounding errors is bounded by 4 ULPs. | 8 个月前 | |
[libc] fix sysconf test for rv32 (#162685) | 9 个月前 | |
[libc][POSIX] Add clock_settime() function for Linux (#161729) Closes #161461 - This is my first time contributing to libc's POSIX, so for reference I used clock_gettime implementation for Linux. For convenience, here is the description of clock_settime function [behavior](https://www.man7.org/linux/man-pages/man3/clock_settime.3.html) | 8 个月前 | |
| 11 个月前 | ||
[libc] Templatize strtofloatingpoint and implement wcstof. (#167755) This change follows the pattern of 315dfe5865962d8a3d60e21d1fffce5214fe54ef by making strtofloat also accept wchar_t* strings (in addition to regular char*). It uses overloads from wctype_utils or specialized functions to ensure comparison with literal characters (or literal strings) pick char or wchar_t variants based on the argument type. The wcstof implementation is added, with unit test cases copied from strtof test suite. | 8 个月前 | |
[libc] Change __builtin_memcpy to inline_memcpy. (#158345) | 10 个月前 | |
[libc] Some MSVC compatibility fixes in src/__support. (#159428) | 10 个月前 | |
[libc][NFC] Add stdint.h proxy header to fix dependency issue with <stdint.h> includes. (#150303) https://github.com/llvm/llvm-project/issues/149993 | 1 年前 | |
[libc][NFC] Add stdint.h proxy header to fix dependency issue with <stdint.h> includes. (#150303) https://github.com/llvm/llvm-project/issues/149993 | 1 年前 | |
| 2 年前 | ||
[libc] Add proxy headers to handle memory allocation associated with the header #include <stdlib.h> (#114690) This finishes the work from https://github.com/llvm/llvm-project/pull/114453 by adding proxy headers for malloc, realloc, free and aligned_alloc`. | 1 年前 | |
[libc] Some compatibility update for building with MSVC. (#157701) Add compiler identity macro and disable some unsupported features. | 10 个月前 | |
[libc][complex] Testing infra for MPC (#121261) This PR aims to add the groundwork to test the precision of libc complex functions against MPC. I took cargf as a test to verify that the infra works fine. | 1 年前 | |
[libc][complex] Testing infra for MPC (#121261) This PR aims to add the groundwork to test the precision of libc complex functions against MPC. I took cargf as a test to verify that the infra works fine. | 1 年前 | |
[libc] Use function overloads to make string parsing code more generic. (#167417) ctype_utils/wctype_utils were chaged in 120689e46679c6db37cd9e839ec0721e80a22d4f and e7f7973899f76773ae6e9a6b1e8c7e9f9cc5cb56, respectively to operate on char/wchar_t. Now we can switch to the overloaded names (e.g. have noth isspace(char and isspace(wchar_t)) to simplify the templatized strtointeger implementation from 315dfe5865962d8a3d60e21d1fffce5214fe54ef and make it easier to potentially add templatized strtofloat implementation. | 8 个月前 | |
[libc][NFC] Add stdint.h proxy header to fix dependency issue with <stdint.h> includes. (#150303) https://github.com/llvm/llvm-project/issues/149993 | 1 年前 | |
[libc] Some MSVC compatibility changes for src/string/memory_utils. (#158393) | 10 个月前 | |
| 2 年前 | ||
[libc] Add hardening for FixedVector data structure and fix exposed bug. (#122159) Add LIBC_ASSERT statements to FixedVector implementation, and zero out the memory when the elements are removed to flag out-of-bound access and dangling pointer/reference access. This change unmasks the bug in one of FixedVector uses for atexit handlers: dangling reference use, which was actually led to crashes in the wild (with prod blockstore implementation). Fix it in this CL. | 1 年前 | |
[libc] Fix printf long double bugs (#166474) Found in testing against abseil. Two bugs were found: 1) SHIFT_AMOUNT in float_converter<long double> would sometimes be negative causing an underflow when passed as the amount to left shift by for BigInt. 2) is_lowest_block had an off-by-one because it was adding 1 to the block index. Both are fixed and there are new tests to catch regressions. | 8 个月前 | |
[libc][NFC] Remove template arguments from Block (#117386) | 1 年前 | |
[libc][NFC] Remove template arguments from Block (#117386) | 1 年前 | |
[libc] Breakup freelist_malloc into separate files (#119806) This better matches the structure we use for the rest of libc. | 1 年前 | |
[libc] Fix malloc Block alignment issue on riscv32 (#117815) Aligning blocks to max_align_t is neither necessary nor sufficient to ensure that the usable_space() is so aligned. Instead, we make this an invariant of Block and maintain it in init() and split(). This allows targets like riscv32 with small pointers and large max_align_t to maintain the property that all available blocks are aligned for malloc(). This change adjusts the tests to match and also updates them closer to llvm-libc style. | 1 年前 | |
[NFC][libc] Remove Block::ALIGNMENT and Block::BLOCK_OVERHEAD | 1 年前 | |
Reapply "[libc] Use best-fit binary trie to make malloc logarithmic (#117065)" This reverts commit 93b83642ee34d0092b94776728dad0117c2b72a1. - Correct riscv32 assumption about alignment (bit of a hack). - Fix test case where the largest_small and smallest sizes are the same. | 1 年前 | |
[libc][NFC] Remove template arguments from Block (#117386) | 1 年前 | |
[libc][NFC] Add stdint.h proxy header to fix dependency issue with <stdint.h> includes. (#150303) https://github.com/llvm/llvm-project/issues/149993 | 1 年前 | |
[libc] Templatize strtofloatingpoint and implement wcstof. (#167755) This change follows the pattern of 315dfe5865962d8a3d60e21d1fffce5214fe54ef by making strtofloat also accept wchar_t* strings (in addition to regular char*). It uses overloads from wctype_utils or specialized functions to ensure comparison with literal characters (or literal strings) pick char or wchar_t variants based on the argument type. The wcstof implementation is added, with unit test cases copied from strtof test suite. | 8 个月前 | |
[libc][NFC] Add stdint.h proxy header to fix dependency issue with <stdint.h> includes. (#150303) https://github.com/llvm/llvm-project/issues/149993 | 1 年前 | |
| 2 年前 | ||
[libc] Migrate ctype_utils to use char instead of int where applicable. (#166225) Functions like isalpha / tolower can operate on chars internally. This allows us to get rid of unnecessary casts and open a way to creating wchar_t overloads with the same names (e.g. for isalpha), that would simplify templated code for conversion functions (see 315dfe5865962d8a3d60e21d1fffce5214fe54ef). Add the int->char converstion to public entrypoints implementation instead. We also need to introduce bounds check on the input argument values - these functions' behavior is unspecified if the argument is neither EOF nor fits in "unsigned char" range, but the tests we've had verified that they always return false for small negative values. To preserve this behavior, cover it explicitly. | 8 个月前 | |
| 2 年前 | ||
[libc] Allow user-defined LIBC_ASSERT macro. (#168087) By only defining it if LIBC_ASSERT macro is not defined. Fixes https://github.com/llvm/llvm-project/issues/162392 | 8 个月前 | |
[libc] Remove LIBC_ERRNO_MODE_SYSTEM mode. (#153077) Use LIBC_ERRNO_MODE_SYSTEM_INLINE instead as the default for the "public packaging" (i.e. release mode) of an overlay build. The Bazel build has already switched to use it by default in 5ccc734fa0355f971f8f515457a0bece33ab6642. This should be a safe change, as LIBC_ERRNO_MODE_SYSTEM_INLINE works a drop-in (but simpler) LIBC_ERRNO_MODE_SYSTEM replacement. Remove the associated code paths and config settings. Fixes issue #143454. | 11 个月前 | |
[libc] Some MSVC compatibility fixes in src/__support. (#159428) | 10 个月前 | |
[libc] Add -Wno-sign-conversion & re-attempt -Wconversion (#129811) Relates to https://github.com/llvm/llvm-project/issues/119281#issuecomment-2699470459 | 1 年前 | |
| 2 年前 | ||
[libc][NFC] Add stdint.h proxy header to fix dependency issue with <stdint.h> includes. (#150303) https://github.com/llvm/llvm-project/issues/149993 | 1 年前 | |
[libc][NFC] Add stdint.h proxy header to fix dependency issue with <stdint.h> includes. (#150303) https://github.com/llvm/llvm-project/issues/149993 | 1 年前 | |
[libc] Alternative algorithm for decimal FP printf (#123643) The existing options for bin→dec float conversion are all based on the Ryū algorithm, which generates 9 output digits at a time using a table lookup. For users who can't afford the space cost of the table, the table-lookup subroutine is replaced with one that computes the needed table entry on demand, but the algorithm is otherwise unmodified. The performance problem with computing table entries on demand is that now you need to calculate a power of 10 for each 9 digits you output. But if you're calculating a custom power of 10 anyway, it's easier to just compute one, and multiply the _whole_ mantissa by it. This patch adds a header file alongside float_dec_converter.h, which replaces the whole Ryū system instead of just the table-lookup routine, implementing this alternative simpler algorithm. The result is accurate enough to satisfy (minimally) the accuracy demands of IEEE 754-2019 even in 128-bit long double. The new float128 test cases demonstrate this by testing the cases closest to the 39-digit rounding boundary. In my tests of generating 39 output digits (the maximum number supported by this algorithm) this code is also both faster and smaller than the USE_DYADIC_FLOAT version of the existing Ryū code. | 1 年前 | |
[libc] Templatize strtofloatingpoint and implement wcstof. (#167755) This change follows the pattern of 315dfe5865962d8a3d60e21d1fffce5214fe54ef by making strtofloat also accept wchar_t* strings (in addition to regular char*). It uses overloads from wctype_utils or specialized functions to ensure comparison with literal characters (or literal strings) pick char or wchar_t variants based on the argument type. The wcstof implementation is added, with unit test cases copied from strtof test suite. | 8 个月前 | |
[libc] Use function overloads to make string parsing code more generic. (#167417) ctype_utils/wctype_utils were chaged in 120689e46679c6db37cd9e839ec0721e80a22d4f and e7f7973899f76773ae6e9a6b1e8c7e9f9cc5cb56, respectively to operate on char/wchar_t. Now we can switch to the overloaded names (e.g. have noth isspace(char and isspace(wchar_t)) to simplify the templatized strtointeger implementation from 315dfe5865962d8a3d60e21d1fffce5214fe54ef and make it easier to potentially add templatized strtofloat implementation. | 8 个月前 | |
[libcxx][libc] Hand in Hand PoC with from_chars (#91651) Implements std::from_chars for float and double. The implementation uses LLVM-libc to do the real parsing. Since this is the first time libc++ uses LLVM-libc there is a bit of additional infrastructure code. The patch is based on the [RFC] Project Hand In Hand (LLVM-libc/libc++ code sharing) https://discourse.llvm.org/t/rfc-project-hand-in-hand-llvm-libc-libc-code-sharing/77701 | 1 年前 | |
[libc][NFC] Rename UInt.h to big_int.h and UInt128.h to uint128.h for consistency (#87808) | 2 年前 | |
[libc] Use function overloads to make string parsing code more generic. (#167417) ctype_utils/wctype_utils were chaged in 120689e46679c6db37cd9e839ec0721e80a22d4f and e7f7973899f76773ae6e9a6b1e8c7e9f9cc5cb56, respectively to operate on char/wchar_t. Now we can switch to the overloaded names (e.g. have noth isspace(char and isspace(wchar_t)) to simplify the templatized strtointeger implementation from 315dfe5865962d8a3d60e21d1fffce5214fe54ef and make it easier to potentially add templatized strtofloat implementation. | 8 个月前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 8 个月前 | ||
| 9 个月前 | ||
| 8 个月前 | ||
| 9 个月前 | ||
| 1 年前 | ||
| 8 个月前 | ||
| 8 个月前 | ||
| 10 个月前 | ||
| 9 个月前 | ||
| 8 个月前 | ||
| 8 个月前 | ||
| 9 个月前 | ||
| 8 个月前 | ||
| 11 个月前 | ||
| 8 个月前 | ||
| 10 个月前 | ||
| 10 个月前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 2 年前 | ||
| 1 年前 | ||
| 10 个月前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 8 个月前 | ||
| 1 年前 | ||
| 10 个月前 | ||
| 2 年前 | ||
| 1 年前 | ||
| 8 个月前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 8 个月前 | ||
| 1 年前 | ||
| 2 年前 | ||
| 8 个月前 | ||
| 2 年前 | ||
| 8 个月前 | ||
| 11 个月前 | ||
| 10 个月前 | ||
| 1 年前 | ||
| 2 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 8 个月前 | ||
| 8 个月前 | ||
| 1 年前 | ||
| 2 年前 | ||
| 8 个月前 |