Newer
Older
Tardis / lang / symbol.c
// SPDX-License-Identifier: MIT
// Copyright (c) 2023 John Watts and the LuminaSensum contributors

#include "symbol.h"
#include <stdint.h>

// FNV-1a Algorithm from http://www.isthe.com/chongo/tech/comp/fnv/
// Thanks for releasing it to the public domain :)
uint32_t fnv32a_text(unsigned char *text) {
	uint32_t hash = (uint32_t)0x811c9dc5;
	while (*text) {
		hash ^= (uint32_t)*text++;
		hash *= (uint32_t)0x01000193;
	}
	return hash;
}

symbol find_symbol(char *name) { return fnv32a_text((unsigned char *)name); }