removed wrong INLINE
[libfirm] / ir / adt / hashptr.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/adt/hashptr.h
4  * Purpose:     Hash function for pointers
5  * Author:      Michael Beck, Sebastian Hack
6  * Modified by:
7  * Created:     2004
8  * CVS-ID:      $Id$
9  * Copyright:   (C) 2004 University of Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12 #ifndef __HASHPTR_H__
13 #define __HASHPTR_H__
14
15 #include "firm_config.h"
16
17 #define _FIRM_FNV_OFFSET_BASIS 2166136261
18 #define _FIRM_FNV_FNV_PRIME 16777619
19
20 static INLINE unsigned firm_fnv_hash(const unsigned char *data, unsigned bytes)
21 {
22         unsigned i;
23         unsigned hash = _FIRM_FNV_OFFSET_BASIS;
24
25         for(i = 0; i < bytes; ++i) {
26                 hash *= _FIRM_FNV_FNV_PRIME;
27                 hash ^= data[i];
28         }
29
30         return hash;
31 }
32
33 /**
34  * hash a pointer value: Pointer addresses are mostly aligned to 4
35  * or 8 bytes. So we remove the lowest 3 bits
36  */
37 #define HASH_PTR(ptr)    (((char *) (ptr) - (char *)0) >> 3)
38
39 /**
40  * Hash a string.
41  * @param str The string (can be const).
42  * @param len The length of the string.
43  * @return A hash value for the string.
44  */
45 #define HASH_STR(str,len) firm_fnv_hash((const unsigned char *) (str), (len))
46
47 #endif /* __HASHPTR_H__ */