summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorJohn Naylor <john.naylor@postgresql.org>2022-02-20 13:22:08 +0700
committerJohn Naylor <john.naylor@postgresql.org>2022-02-20 13:22:08 +0700
commit4b35408f1ed59dd590f683ae0f015bbaf3b84d3d (patch)
treef0fbcde2e180f22114c14331512b8bcfacfcf5e6 /src/common
parentd7a978601d4e469f1a8f19122c049bb25fd7f096 (diff)
Use bitwise rotate functions in more places
There were a number of places in the code that used bespoke bit-twiddling expressions to do bitwise rotation. While we've had pg_rotate_right32() for a while now, we hadn't gotten around to standardizing on that. Do so now. Since many potential call sites look more natural with the "left" equivalent, add that function too. Reviewed by Tom Lane and Yugo Nagata Discussion: https://www.postgresql.org/message-id/CAFBsxsH7c1LC0CGZ0ADCBXLHU5-%3DKNXx-r7tHYPAW51b2HK4Qw%40mail.gmail.com
Diffstat (limited to 'src/common')
-rw-r--r--src/common/hashfn.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/common/hashfn.c b/src/common/hashfn.c
index b7a322073d0..8779575b991 100644
--- a/src/common/hashfn.c
+++ b/src/common/hashfn.c
@@ -24,6 +24,7 @@
#include "postgres.h"
#include "common/hashfn.h"
+#include "port/pg_bitutils.h"
/*
@@ -44,8 +45,7 @@
/* Get a bit mask of the bits set in non-uint32 aligned addresses */
#define UINT32_ALIGN_MASK (sizeof(uint32) - 1)
-/* Rotate a uint32 value left by k bits - note multiple evaluation! */
-#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
+#define rot(x,k) pg_rotate_left32(x, k)
/*----------
* mix -- mix 3 32-bit values reversibly.