Loads do not remove any nodes from the exec after sets. Also fix a 'node leak'.
[libfirm] / ir / adt / hashptr.h
index ff325c7..043ba5b 100644 (file)
@@ -1,29 +1,47 @@
 /*
- * Project:     libFIRM
- * File name:   ir/adt/hashptr.h
- * Purpose:     Hash function for pointers
- * Author:      Michael Beck, Sebastian Hack
- * Modified by:
- * Created:     2004
- * CVS-ID:      $Id$
- * Copyright:   (C) 2004 University of Karlsruhe
- * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
+ * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
  */
-#ifndef __HASHPTR_H__
-#define __HASHPTR_H__
+
+/**
+ * @file
+ * @brief       Hash function for pointers
+ * @author      Michael Beck, Sebastian Hack
+ * @version     $Id$
+ */
+#ifndef FIRM_ADT_HASHPTR_H
+#define FIRM_ADT_HASHPTR_H
 
 #include "firm_config.h"
 
 #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)
+
 static INLINE unsigned firm_fnv_hash(const unsigned char *data, unsigned bytes)
 {
        unsigned i;
        unsigned hash = _FIRM_FNV_OFFSET_BASIS;
 
        for(i = 0; i < bytes; ++i) {
-               hash *= _FIRM_FNV_FNV_PRIME;
+               hash = _FIRM_FNV_TIMES_PRIME(hash);
                hash ^= data[i];
        }
 
@@ -44,4 +62,29 @@ static INLINE unsigned firm_fnv_hash(const unsigned char *data, unsigned bytes)
  */
 #define HASH_STR(str,len) firm_fnv_hash((const unsigned char *) (str), (len))
 
-#endif /* __HASHPTR_H__ */
+#ifdef _MSC_VER
+#pragma warning(disable:4307)
+#endif /* _MSC_VER */
+
+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;
+}
+
+#ifdef _MSC_VER
+#pragma warning(default:4307)
+#endif /* _MSC_VER */
+
+/**
+ * Make one hash value out of two others.
+ * @param a One hash value.
+ * @param b Another hash value.
+ * @return A hash value computed from the both.
+ */
+#define HASH_COMBINE(a,b) _hash_combine(a, b)
+
+#endif