]> mj.ucw.cz Git - libucw.git/blobdiff - lib/hashfunc.h
Use $(COPT2) instead of -O6.
[libucw.git] / lib / hashfunc.h
index 17a865b19184c0ca301db4f173d6d37bead3a39c..c10f224910d9ba563ef401adc45ae57db011912a 100644 (file)
@@ -39,7 +39,8 @@ uns hash_string_nocase(const byte *str) CONST;
  *  of using shifts and adds on architectures where multiplication
  *  instructions are slow).
  */
-static inline uns CONST hash_int(uns x) { return 0x01008041*x; }
-static inline uns CONST hash_pointer(void *x) { return hash_int((uns)(addr_int_t)x); }
+static inline uns CONST hash_u32(uns x) { return 0x01008041*x; }
+static inline uns CONST hash_u64(u64 x) { return hash_u32((uns)x ^ (uns)(x >> 32)); }
+static inline uns CONST hash_pointer(void *x) { return ((sizeof(x) <= 4) ? hash_u32((uns)(addr_int_t)x) : hash_u64((u64)(addr_int_t)x)); }
 
 #endif