2 * Copyright 2008-2009 Katholieke Universiteit Leuven
4 * Use of this software is governed by the GNU LGPLv2.1 license
6 * Written by Sven Verdoolaege, K.U.Leuven, Departement
7 * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
13 #include <isl_stdint.h>
15 #if defined(__cplusplus)
19 #define isl_hash_init() (2166136261u)
20 #define isl_hash_byte(h,b) do { \
24 #define isl_hash_hash(h,h2) \
26 isl_hash_byte(h, (h2) & 0xFF); \
27 isl_hash_byte(h, ((h2) >> 8) & 0xFF); \
28 isl_hash_byte(h, ((h2) >> 16) & 0xFF); \
29 isl_hash_byte(h, ((h2) >> 24) & 0xFF); \
31 #define isl_hash_bits(h,bits) \
32 ((bits) == 32) ? (h) : \
34 ((h) >> (bits)) ^ ((h) & (((uint32_t)1 << (bits)) - 1)) : \
35 (((h) >> (bits)) ^ (h)) & (((uint32_t)1 << (bits)) - 1)
37 uint32_t isl_hash_string(uint32_t hash
, const char *s
);
39 struct isl_hash_table_entry
45 struct isl_hash_table
{
48 struct isl_hash_table_entry
*entries
;
53 struct isl_hash_table
*isl_hash_table_alloc(struct isl_ctx
*ctx
, int min_size
);
54 void isl_hash_table_free(struct isl_ctx
*ctx
, struct isl_hash_table
*table
);
56 int isl_hash_table_init(struct isl_ctx
*ctx
, struct isl_hash_table
*table
,
58 void isl_hash_table_clear(struct isl_hash_table
*table
);
59 struct isl_hash_table_entry
*isl_hash_table_find(struct isl_ctx
*ctx
,
60 struct isl_hash_table
*table
,
62 int (*eq
)(const void *entry
, const void *val
),
63 const void *val
, int reserve
);
64 int isl_hash_table_foreach(struct isl_ctx
*ctx
,
65 struct isl_hash_table
*table
,
66 int (*fn
)(void *entry
));
67 void isl_hash_table_remove(struct isl_ctx
*ctx
,
68 struct isl_hash_table
*table
,
69 struct isl_hash_table_entry
*entry
);
71 #if defined(__cplusplus)