hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit f9ecff87cb74a1576c51fd42e8bac15dc7e7514b
parent b6254b970cf5874c4346a3aefc407f39ae6c82d6
Author: Sebastian <sebastian@sebsite.pw>
Date:   Fri, 17 Jun 2022 17:02:15 -0400

hash::fnv: make string arch-dependent

For all currently supported targets, this is an alias for string64, but
that won't be the case for all targets.

Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Ahash/fnv/+aarch64.ha | 6++++++
Ahash/fnv/+riscv64.ha | 6++++++
Ahash/fnv/+x86_64.ha | 6++++++
Mhash/fnv/fnv.ha | 3---
Mscripts/gen-stdlib | 1+
Mstdlib.mk | 2++
6 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/hash/fnv/+aarch64.ha b/hash/fnv/+aarch64.ha @@ -0,0 +1,6 @@ +// License: MPL-2.0 +// (c) 2021 Drew DeVault <sir@cmpwn.com> +// (c) 2022 Sebastian <sebastian@sebsite.pw> + +// Hashes a string, returning a size key, for use in a hash map. +export fn string(s: str) size = string64(s): size; diff --git a/hash/fnv/+riscv64.ha b/hash/fnv/+riscv64.ha @@ -0,0 +1,6 @@ +// License: MPL-2.0 +// (c) 2021 Drew DeVault <sir@cmpwn.com> +// (c) 2022 Sebastian <sebastian@sebsite.pw> + +// Hashes a string, returning a size key, for use in a hash map. +export fn string(s: str) size = string64(s): size; diff --git a/hash/fnv/+x86_64.ha b/hash/fnv/+x86_64.ha @@ -0,0 +1,6 @@ +// License: MPL-2.0 +// (c) 2021 Drew DeVault <sir@cmpwn.com> +// (c) 2022 Sebastian <sebastian@sebsite.pw> + +// Hashes a string, returning a size key, for use in a hash map. +export fn string(s: str) size = string64(s): size; diff --git a/hash/fnv/fnv.ha b/hash/fnv/fnv.ha @@ -21,9 +21,6 @@ export type state64 = struct { v: u64, }; -// Hashes a string, returning a size key, for use in a hash map. -export fn string(s: str) size = string64(s): size; - // Hashes a string, returning a 32-bit key. export fn string32(s: str) u32 = { let hash = fnv32a(); diff --git a/scripts/gen-stdlib b/scripts/gen-stdlib @@ -815,6 +815,7 @@ hash_crc64() { hash_fnv() { gen_srcs hash::fnv \ + '+$(ARCH).ha' \ fnv.ha gen_ssa hash::fnv hash io strings } diff --git a/stdlib.mk b/stdlib.mk @@ -1383,6 +1383,7 @@ $(HARECACHE)/hash/crc64/hash_crc64-any.ssa: $(stdlib_hash_crc64_any_srcs) $(stdl # hash::fnv (+any) stdlib_hash_fnv_any_srcs = \ + $(STDLIB)/hash/fnv/+$(ARCH).ha \ $(STDLIB)/hash/fnv/fnv.ha $(HARECACHE)/hash/fnv/hash_fnv-any.ssa: $(stdlib_hash_fnv_any_srcs) $(stdlib_rt) $(stdlib_hash_$(PLATFORM)) $(stdlib_io_$(PLATFORM)) $(stdlib_strings_$(PLATFORM)) @@ -3554,6 +3555,7 @@ $(TESTCACHE)/hash/crc64/hash_crc64-any.ssa: $(testlib_hash_crc64_any_srcs) $(tes # hash::fnv (+any) testlib_hash_fnv_any_srcs = \ + $(STDLIB)/hash/fnv/+$(ARCH).ha \ $(STDLIB)/hash/fnv/fnv.ha $(TESTCACHE)/hash/fnv/hash_fnv-any.ssa: $(testlib_hash_fnv_any_srcs) $(testlib_rt) $(testlib_hash_$(PLATFORM)) $(testlib_io_$(PLATFORM)) $(testlib_strings_$(PLATFORM))