Polly 20.0.0git
hash.h
Go to the documentation of this file.
1/*
2 * Copyright 2008-2009 Katholieke Universiteit Leuven
3 *
4 * Use of this software is governed by the MIT license
5 *
6 * Written by Sven Verdoolaege, K.U.Leuven, Departement
7 * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
8 */
9
10#ifndef ISL_HASH_H
11#define ISL_HASH_H
12
13#include <stdlib.h>
14#include <isl/stdint.h>
15#include <isl/ctx.h>
16
17#if defined(__cplusplus)
18extern "C" {
19#endif
20
21#define isl_hash_init() (2166136261u)
22#define isl_hash_byte(h,b) do { \
23 h *= 16777619; \
24 h ^= b; \
25 } while(0)
26#define isl_hash_hash(h,h2) \
27 do { \
28 isl_hash_byte(h, (h2) & 0xFF); \
29 isl_hash_byte(h, ((h2) >> 8) & 0xFF); \
30 isl_hash_byte(h, ((h2) >> 16) & 0xFF); \
31 isl_hash_byte(h, ((h2) >> 24) & 0xFF); \
32 } while(0)
33#define isl_hash_bits(h,bits) \
34 ((bits) == 32) ? (h) : \
35 ((bits) >= 16) ? \
36 ((h) >> (bits)) ^ ((h) & (((uint32_t)1 << (bits)) - 1)) : \
37 (((h) >> (bits)) ^ (h)) & (((uint32_t)1 << (bits)) - 1)
38
39uint32_t isl_hash_string(uint32_t hash, const char *s);
40uint32_t isl_hash_mem(uint32_t hash, const void *p, size_t len);
41
42#define isl_hash_builtin(h,l) isl_hash_mem(h, &l, sizeof(l))
43
45{
46 uint32_t hash;
47 void *data;
48};
49
51 int bits;
52 int n;
54};
55
56struct isl_hash_table *isl_hash_table_alloc(struct isl_ctx *ctx, int min_size);
57void isl_hash_table_free(struct isl_ctx *ctx, struct isl_hash_table *table);
58
59int isl_hash_table_init(struct isl_ctx *ctx, struct isl_hash_table *table,
60 int min_size);
61void isl_hash_table_clear(struct isl_hash_table *table);
64 struct isl_hash_table *table,
65 uint32_t key_hash,
66 isl_bool (*eq)(const void *entry, const void *val),
67 const void *val, int reserve);
69 isl_stat (*fn)(void **entry, void *user), void *user);
71 isl_bool (*test)(void **entry, void *user), void *user);
72void isl_hash_table_remove(struct isl_ctx *ctx,
73 struct isl_hash_table *table,
74 struct isl_hash_table_entry *entry);
75
76#if defined(__cplusplus)
77}
78#endif
79
80#endif
isl_stat
Definition: ctx.h:84
isl_bool
Definition: ctx.h:89
void isl_hash_table_clear(struct isl_hash_table *table)
Definition: isl_hash.c:136
isl_bool isl_hash_table_every(isl_ctx *ctx, struct isl_hash_table *table, isl_bool(*test)(void **entry, void *user), void *user)
Definition: isl_hash.c:235
struct isl_hash_table_entry * isl_hash_table_entry_none
Definition: isl_hash.c:155
uint32_t isl_hash_string(uint32_t hash, const char *s)
Definition: isl_hash.c:15
uint32_t isl_hash_mem(uint32_t hash, const void *p, size_t len)
Definition: isl_hash.c:22
int isl_hash_table_init(struct isl_ctx *ctx, struct isl_hash_table *table, int min_size)
Definition: isl_hash.c:42
void isl_hash_table_remove(struct isl_ctx *ctx, struct isl_hash_table *table, struct isl_hash_table_entry *entry)
Definition: isl_hash.c:258
void isl_hash_table_free(struct isl_ctx *ctx, struct isl_hash_table *table)
Definition: isl_hash.c:143
isl_stat isl_hash_table_foreach(isl_ctx *ctx, struct isl_hash_table *table, isl_stat(*fn)(void **entry, void *user), void *user)
Definition: isl_hash.c:215
struct isl_hash_table_entry * isl_hash_table_find(struct isl_ctx *ctx, struct isl_hash_table *table, uint32_t key_hash, isl_bool(*eq)(const void *entry, const void *val), const void *val, int reserve)
Definition: isl_hash.c:157
struct isl_hash_table * isl_hash_table_alloc(struct isl_ctx *ctx, int min_size)
Definition: isl_hash.c:123
__isl_export __isl_give ISL_HMAP __isl_take ISL_KEY __isl_take ISL_VAL * val
Definition: hmap.h:32
isl_stat isl_stat(* fn)(__isl_take ISL_KEY *key, __isl_take ISL_VAL *val, void *user)
Definition: hmap.h:37
isl_stat isl_stat(*) void user)
Definition: hmap.h:39
__isl_constructor __isl_give ISL_HMAP int min_size
Definition: hmap.h:18
isl_bool isl_bool(* test)(__isl_keep ISL_KEY *key, __isl_keep ISL_VAL *val, void *user)
Definition: hmap.h:41
const char * p
Definition: isl_test.c:8643
Definition: hash.h:45
uint32_t hash
Definition: hash.h:46
void * data
Definition: hash.h:47
int bits
Definition: hash.h:51
struct isl_hash_table_entry * entries
Definition: hash.h:53