summaryrefslogtreecommitdiff
path: root/libc/src/__support/HashTable/generic
AgeCommit message (Collapse)Author
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-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-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-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] [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.