From bac14fa6c79b6abea50fd5f188799ae8e83cb20d Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 5 Sep 2024 16:23:05 -0400 Subject: Fully clean up siphash code and fix some issues --- structs.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'structs.c') diff --git a/structs.c b/structs.c index ebd4f7a3..566f39ff 100644 --- a/structs.c +++ b/structs.c @@ -97,9 +97,9 @@ static CORD compile_hash_method(env_t *env, ast_t *ast) { auto def = Match(ast, StructDef); CORD full_name = CORD_cat(namespace_prefix(env->libname, env->namespace), def->name); - CORD hash_func = CORD_all("static uint32_t ", full_name, "$hash(const ", full_name, "_t *obj, const TypeInfo *info) {\n" + CORD hash_func = CORD_all("static uint64_t ", full_name, "$hash(const ", full_name, "_t *obj, const TypeInfo *info) {\n" "(void)info;\n" - "uint32_t field_hashes[] = {"); + "uint64_t field_hashes[] = {"); for (arg_ast_t *field = def->fields; field; field = field->next) { type_t *field_type = get_arg_ast_type(env, field); if (field_type->tag == BoolType) // Bools can be bit fields, so you can't use *obj->field there: @@ -108,9 +108,7 @@ static CORD compile_hash_method(env_t *env, ast_t *ast) hash_func = CORD_all(hash_func, "\ngeneric_hash(&obj->$", field->name, ", ", compile_type_info(env, field_type), "),"); } hash_func = CORD_all(hash_func, "};\n" - "uint32_t hash;\n" - "halfsiphash(&field_hashes, sizeof(field_hashes), TOMO_HASH_KEY, (uint8_t*)&hash, sizeof(hash));\n" - "return hash;\n}\n"); + "return siphash24((void*)&field_hashes, sizeof(field_hashes));\n}\n"); return hash_func; } -- cgit v1.2.3