aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/utils/hashutils.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/include/utils/hashutils.h b/src/include/utils/hashutils.h
new file mode 100644
index 00000000000..56b7bfc9cb9
--- /dev/null
+++ b/src/include/utils/hashutils.h
@@ -0,0 +1,23 @@
+/*
+ * Utilities for working with hash values.
+ *
+ * Portions Copyright (c) 2017, PostgreSQL Global Development Group
+ */
+
+#ifndef HASHUTILS_H
+#define HASHUTILS_H
+
+/*
+ * Combine two hash values, resulting in another hash value, with decent bit
+ * mixing.
+ *
+ * Similar to boost's hash_combine().
+ */
+static inline uint32
+hash_combine(uint32 a, uint32 b)
+{
+ a ^= b + 0x9e3779b9 + (a << 6) + (a >> 2);
+ return a;
+}
+
+#endif /* HASHUTILS_H */