aboutsummaryrefslogtreecommitdiff
path: root/structs.c
diff options
context:
space:
mode:
Diffstat (limited to 'structs.c')
-rw-r--r--structs.c8
1 files changed, 3 insertions, 5 deletions
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;
}