aboutsummaryrefslogtreecommitdiff
path: root/src/util.hff
blob: b8416f18e9eb5d306f75506c255d0b36205e81e8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// util.cff
extern fn xmalloc(n usize) *void;
extern fn xcalloc(n usize, m usize) *void;
extern fn xrealloc(p *void, n usize) *void;
extern fn xstrdup(str *const u8) *u8;
def FNV1A_INI u32 = 0x811c9dc5;
extern fn fnv1a(h u32, [#]const u8) u32;
extern fn fnv1a_s(h u32, *const u8) u32;
extern fn fnv1a_i(h u32, i64) u32;
fn cwhash32(x u32) u32 {
   // https://nullprogram.com/blog/2018/07/31/
   x ^= x >> 16;
   x *= 0x7feb352dU;
   x ^= x >> 15;
   x *= 0x846ca68bU;
   x ^= x >> 16;
   return x;
}
extern fn addfilepath(*const u8) int;
extern fn fileid2path(id int) *const u8;
extern fn internstr(*const u8) *const u8;