projects
/
libfirm
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
automatically generate opcode declarations from ir_spec
[libfirm]
/
include
/
libfirm
/
adt
/
hashptr.h
diff --git
a/include/libfirm/adt/hashptr.h
b/include/libfirm/adt/hashptr.h
index
043ba5b
..
80cde95
100644
(file)
--- a/
include/libfirm/adt/hashptr.h
+++ b/
include/libfirm/adt/hashptr.h
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (C) 1995-200
7
University of Karlsruhe. All right reserved.
+ * Copyright (C) 1995-200
8
University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
*
* This file is part of libFirm.
*
@@
-26,16
+26,15
@@
#ifndef FIRM_ADT_HASHPTR_H
#define FIRM_ADT_HASHPTR_H
#ifndef FIRM_ADT_HASHPTR_H
#define FIRM_ADT_HASHPTR_H
-#include "
firm_config
.h"
+#include "
../begin
.h"
#define _FIRM_FNV_OFFSET_BASIS 2166136261U
#define _FIRM_FNV_FNV_PRIME 16777619U
/* Computing x * _FIRM_FNV_FNV_PRIME */
#define _FIRM_FNV_OFFSET_BASIS 2166136261U
#define _FIRM_FNV_FNV_PRIME 16777619U
/* Computing x * _FIRM_FNV_FNV_PRIME */
-#define _FIRM_FNV_TIMES_PRIME(x) \
- (((x) << 24) + ((x) << 8) + ((x) << 7) + ((x) << 4) + ((x) << 1) + 1)
+#define _FIRM_FNV_TIMES_PRIME(x) ((x) * _FIRM_FNV_FNV_PRIME)
-static
INLINE
unsigned firm_fnv_hash(const unsigned char *data, unsigned bytes)
+static
inline
unsigned firm_fnv_hash(const unsigned char *data, unsigned bytes)
{
unsigned i;
unsigned hash = _FIRM_FNV_OFFSET_BASIS;
{
unsigned i;
unsigned hash = _FIRM_FNV_OFFSET_BASIS;
@@
-48,11
+47,29
@@
static INLINE unsigned firm_fnv_hash(const unsigned char *data, unsigned bytes)
return hash;
}
return hash;
}
+static inline unsigned firm_fnv_hash_str(const char *data)
+{
+ unsigned i;
+ unsigned hash = _FIRM_FNV_OFFSET_BASIS;
+
+ for(i = 0; data[i] != '\0'; ++i) {
+ hash = _FIRM_FNV_TIMES_PRIME(hash);
+ hash ^= data[i];
+ }
+
+ return hash;
+}
+
/**
* hash a pointer value: Pointer addresses are mostly aligned to 4
* or 8 bytes. So we remove the lowest 3 bits
*/
/**
* hash a pointer value: Pointer addresses are mostly aligned to 4
* or 8 bytes. So we remove the lowest 3 bits
*/
-#define HASH_PTR(ptr) (((char *) (ptr) - (char *)0) >> 3)
+#define HASH_PTR(ptr) ((unsigned)(((char *) (ptr) - (char *)0) >> 3))
+
+static inline unsigned hash_ptr(const void *ptr)
+{
+ return HASH_PTR(ptr);
+}
/**
* Hash a string.
/**
* Hash a string.
@@
-66,13
+83,13
@@
static INLINE unsigned firm_fnv_hash(const unsigned char *data, unsigned bytes)
#pragma warning(disable:4307)
#endif /* _MSC_VER */
#pragma warning(disable:4307)
#endif /* _MSC_VER */
-static
INLINE
unsigned _hash_combine(unsigned x, unsigned y)
+static
inline
unsigned _hash_combine(unsigned x, unsigned y)
{
{
- unsigned hash = _FIRM_FNV_TIMES_PRIME(_FIRM_FNV_OFFSET_BASIS);
- hash ^= x;
- hash = _FIRM_FNV_TIMES_PRIME(hash);
- hash ^= y;
- return hash;
+
unsigned hash = _FIRM_FNV_TIMES_PRIME(_FIRM_FNV_OFFSET_BASIS);
+
hash ^= x;
+
hash = _FIRM_FNV_TIMES_PRIME(hash);
+
hash ^= y;
+
return hash;
}
#ifdef _MSC_VER
}
#ifdef _MSC_VER
@@
-87,4
+104,6
@@
static INLINE unsigned _hash_combine(unsigned x, unsigned y)
*/
#define HASH_COMBINE(a,b) _hash_combine(a, b)
*/
#define HASH_COMBINE(a,b) _hash_combine(a, b)
+#include "../end.h"
+
#endif
#endif