isl_basic_map_from_constraint: only return copy of bmap on equality constraints
[isl.git] / include / isl_hash.h
blob3c5ea3c6bc3eb5105362e24a92ba721368b9cb7c
1 /*
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
8 */
10 #ifndef ISL_HASH_H
11 #define ISL_HASH_H
13 #include <isl_stdint.h>
15 #if defined(__cplusplus)
16 extern "C" {
17 #endif
19 #define isl_hash_init() (2166136261u)
20 #define isl_hash_byte(h,b) do { \
21 h *= 16777619; \
22 h ^= b; \
23 } while(0)
24 #define isl_hash_hash(h,h2) \
25 do { \
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); \
30 } while(0)
31 #define isl_hash_bits(h,bits) \
32 ((bits) == 32) ? (h) : \
33 ((bits) >= 16) ? \
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
41 uint32_t hash;
42 void *data;
45 struct isl_hash_table {
46 int bits;
47 int n;
48 struct isl_hash_table_entry *entries;
51 struct isl_ctx;
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,
57 int min_size);
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,
61 uint32_t key_hash,
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)
73 #endif
75 #endif