X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=include%2Flibfirm%2Fadt%2Fhashptr.h;h=d7d481c41546c4101f526c5832e9511dad9fef2d;hb=68f1fef312ea0a037cf9815042ea30e95ce1b619;hp=03dd1087acfd3d4ac04e04a123dd319b2cbe504d;hpb=148554545066eb065e992d458c98bf01bf6adf55;p=libfirm diff --git a/include/libfirm/adt/hashptr.h b/include/libfirm/adt/hashptr.h index 03dd1087a..d7d481c41 100644 --- a/include/libfirm/adt/hashptr.h +++ b/include/libfirm/adt/hashptr.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved. + * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved. * * This file is part of libFirm. * @@ -26,8 +26,8 @@ #ifndef FIRM_ADT_HASHPTR_H #define FIRM_ADT_HASHPTR_H -#include "firm_config.h" -#include "compiler.h" +#include +#include "../begin.h" #define _FIRM_FNV_OFFSET_BASIS 2166136261U #define _FIRM_FNV_FNV_PRIME 16777619U @@ -35,9 +35,9 @@ /* Computing x * _FIRM_FNV_FNV_PRIME */ #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, size_t bytes) { - unsigned i; + size_t i; unsigned hash = _FIRM_FNV_OFFSET_BASIS; for(i = 0; i < bytes; ++i) { @@ -48,7 +48,7 @@ static INLINE unsigned firm_fnv_hash(const unsigned char *data, unsigned bytes) return hash; } -static INLINE unsigned firm_fnv_hash_str(const char *data) +static inline unsigned firm_fnv_hash_str(const char *data) { unsigned i; unsigned hash = _FIRM_FNV_OFFSET_BASIS; @@ -65,7 +65,12 @@ static INLINE unsigned firm_fnv_hash_str(const char *data) * 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. @@ -79,13 +84,13 @@ static INLINE unsigned firm_fnv_hash_str(const char *data) #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 @@ -100,4 +105,6 @@ static INLINE unsigned _hash_combine(unsigned x, unsigned y) */ #define HASH_COMBINE(a,b) _hash_combine(a, b) +#include "../end.h" + #endif