summaryrefslogtreecommitdiff
path: root/libc/src/__support/HashTable
AgeCommit message (Collapse)Author
2025-07-23[libc][NFC] Add stdint.h proxy header to fix dependency issue with ↵lntue
<stdint.h> includes. (#150303) https://github.com/llvm/llvm-project/issues/149993
2025-06-18[libc] Internal getrandom implementation (#144427)sribee8
Implemented an internal getrandom to avoid calls to the public one in table.h --------- Co-authored-by: Sriya Pratipati <sriyap@google.com>
2025-06-16[libc] Removed public function calls in table.h (#144168)sribee8
Removed strcmp, strlen, and memset calls from table.h and replaced them with internal functions. --------- Co-authored-by: Sriya Pratipati <sriyap@google.com>
2025-06-11[libc] Move libc_errno.h to libc/src/__support and make ↵lntue
LIBC_ERRNO_MODE_SYSTEM to be header-only. (#143187) This is the first step in preparation for: https://discourse.llvm.org/t/rfc-make-clang-builtin-math-functions-constexpr-with-llvm-libc-to-support-c-23-constexpr-math-functions/86450
2025-05-13[libc] Add proxy header for ENTRY type. (#139746)lntue
https://github.com/llvm/llvm-project/issues/139561
2024-11-18[libc] avoid type-punning with inactive union member (#116685)Schrodinger ZHU Yifan
2024-11-13[libc] Rename libc/src/__support/endian.h to endian_internal.h (#115950)Daniel Thornburgh
This prevents a conflict with the Linux system endian.h when built in overlay mode for CPP files in __support. This issue appeared in PR #106259.
2024-07-20[libc] Added static casts to fix implicit conversion warnings in 32-bit systemsMikhail R. Gadelha
This patch fixes: randomness.h and getauxval.cpp were passing ssize_t as size_t kernel_statx.h was assigning an uint64_t to uintptr_t fopencookie.cpp was trying to create a FileIOResult using ssize_t but the constructor expected a size_t thread.h was trying to call free_stack (which takes a size_t) with an unsigned long long. free_stack does the calculations using uintptr_t, so I changed the passing values to size_t
2024-07-12[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace declaration (#98597)Petr Hosek
This is a part of #97655.
2024-07-12Revert "[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace ↵Mehdi Amini
declaration" (#98593) Reverts llvm/llvm-project#98075 bots are broken
2024-07-11[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace declaration (#98075)Petr Hosek
This is a part of #97655.
2024-05-02[libc] add hashtable fuzzing (#87949)Schrodinger ZHU Yifan
2024-02-29[libc] Revert https://github.com/llvm/llvm-project/pull/83199 since it broke ↵lntue
Fuchsia. (#83374) With some header fix forward for GPU builds.
2024-02-28[libc] fix clang-tidy llvm-header-guard warnings (#82679)Nick Desaulniers
Towards the goal of getting `ninja libc-lint` back to green, fix the numerous instances of: warning: header guard does not follow preferred style [llvm-header-guard] This is because many of our header guards start with `__LLVM` rather than `LLVM`. To filter just these warnings: $ ninja -k2000 libc-lint 2>&1 | grep llvm-header-guard To automatically apply fixits: $ find libc/src libc/include libc/test -name \*.h | \ xargs -n1 -I {} clang-tidy {} -p build/compile_commands.json \ -checks='-*,llvm-header-guard' --fix --quiet Some manual cleanup is still necessary as headers that were missing header guards outright will have them inserted before the license block (we prefer them after).
2024-02-27[libc] Add "include/" to the LLVM include directories (#83199)Joseph Huber
Summary: Recent changes added an include path in the float128 type that used the internal `libc` path to find the macro. This doesn't work once it's installed because we need to search from the root of the install dir. This patch adds "include/" to the include path so that our inclusion of installed headers always match the internal use.
2024-02-23[libc][NFC] Remove all trailing spaces from libc (#82831)Joseph Huber
Summary: There are a lot of random training spaces on various lines. This patch just got rid of all of them with `sed 's/\ \+$//g'.
2024-01-27[libc] change PREFER_GENERIC to EXPLICIT_SIMD_OPT (#79486)Schrodinger ZHU Yifan
fixes #79474.
2024-01-24[libc][NFC] mark hashtable as resizable (#79354)Schrodinger ZHU Yifan
It is not fix-sized anymore.
2024-01-08[libc] fix more -Wmissing-brace (#77382)Nick Desaulniers
Similar to #77345, the buildbots are observing similar warnings for the sse2 implementation. llvm-project/libc/src/__support/HashTable/sse2/bitmask_impl.inc:36:13: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces] return {bitmask}; ^~~~~~~ { } llvm-project/libc/src/__support/HashTable/sse2/bitmask_impl.inc:45:13: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces] return {static_cast<uint16_t>(~mask_available().word)}; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { } Link: https://lab.llvm.org/buildbot/#/builders/163/builds/49350/steps/8/logs/stdio Link: https://github.com/llvm/llvm-project/pull/74506
2024-01-08[libc] fix -Wmissing-braces (#77345)Nick Desaulniers
Fixes the following errors observed on the aarch64 fullbuild: /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/src/__support/HashTable/generic/bitmask_impl.inc:116:13: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces] return {static_cast<bitmask_t>(mask_available().word ^ repeat_byte(0x80))}; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { } In file included from /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/src/search/hdestroy.cpp:10: /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/src/__support/HashTable/table.h:336:41: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces] iterator end() const { return {0, 0, {0}, *this}; } ^ {} Link: https://lab.llvm.org/buildbot/#/builders/223/builds/33868/steps/6/logs/stdio Link: https://github.com/llvm/llvm-project/pull/74506
2023-12-05[libc] [search] improve hsearch robustness (#73896)Schrodinger ZHU Yifan
Following up the discussion at https://github.com/llvm/llvm-project/pull/73469#discussion_r1409593911 by @nickdesaulniers. According to FreeBSD implementation (https://android.googlesource.com/platform/bionic/+/refs/heads/main/libc/upstream-freebsd/lib/libc/stdlib/hcreate.c), `hsearch` is able to handle the cases where the global table is not properly initialized. To do this, FreeBSD actually allows hash table to be dynamically resized. If the global table is uninitialized at the first call, the table will be initialized with a minimal size; hence subsequent insertion will be reasonable as the table grows automatically. This patch mimic such behaviors. More precisely, this patch introduces: 1. a full table iterator that scans each element in the table, 2. a resize routine that is automatically triggered whenever the load factor is reached where it iterates the old table and insert the entries into a new one, 3. more tests that cover the growth of the table.
2023-12-05[reland][libc][NFC] Remove __support/bit.h and use __support/CPP/bit.h ↵Guillaume Chatelet
instead (#73939) (#74446) Same as #73939 but also fix `libc/src/string/memory_utils/op_aarch64.h` that was still using `deferred_static_assert`.
2023-12-05Revert "[libc][NFC] Remove __support/bit.h and use __support/CPP/bit.h ↵Guillaume Chatelet
instead" (#74444) Reverts llvm/llvm-project#73939 This broke libc-aarch64-ubuntu build bot https://lab.llvm.org/buildbot/#/builders/138/builds/56186
2023-12-05[libc][NFC] Remove __support/bit.h and use __support/CPP/bit.h instead (#73939)Guillaume Chatelet
2023-12-04[libc] fix HashTable warnings and build problems (#74371)Schrodinger ZHU Yifan
According to https://lab.llvm.org/buildbot/#/builders/163/builds/48002, the generic build on HashTable fails with two major issues with `werror`: 1. warnings on `error: suggest braces around initialization of subobject`. 2. `__support/HashTable` tests are built regardless of its entrypoints` This PR attempts to fix such issues.
2023-11-29[libc] Fix the GPU build for the hashing support (#73799)Joseph Huber
Summary: For reasons unknown to me, this function is undefined only on the GPU build if you use `uintptr_t` but not `uint64_t` directly. This patch makes an ifdef to use this directly for the GPU build to fix the bots.
2023-11-28[libc] add PREFER_GENERIC flag (#73744)Schrodinger ZHU Yifan
There are some basic vectorization features in standard architecture specifications. Such as SSE/SSE2 for x86-64, or NEON for aarch64. Even though such features are almost always available, we still need some methods to test fallback routines without any vectorization. Previous attempt in hsearch adds a DISABLE_SSE2_OPT flag that tries to compile the code with -mno-sse2 in order to test specific table scanning routines. However, it turns out that such flag may have some unwanted side effects hindering portability. This PR introduces PREFER_GENERIC as an alternative. When a target is built with PREFER_GENERIC, cmake will define a macro __LIBC_PREFER_GENERIC such that developers can selectively choose the fallback routine based on the macro.
2023-11-28[libc] [search] implement hcreate(_r)/hsearch(_r)/hdestroy(_r) (#73469)Schrodinger ZHU Yifan
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.