Move some bitmap logic out of bitmapset.c
authorJohn Naylor <john.naylor@postgresql.org>
Tue, 6 Dec 2022 06:39:41 +0000 (13:39 +0700)
committerJohn Naylor <john.naylor@postgresql.org>
Wed, 6 Mar 2024 07:30:16 +0000 (14:30 +0700)
Move the logic for selecting appropriate pg_bitutils.h
functions based on word size to bitmapset.h for wider
visibility.

Reviewed (in a previous version) by Tom Lane
Discussion: https://postgr.es/m/CAFBsxsFW2JjTo58jtDB%2B3sZhxMx3t-3evew8%3DAcr%2BGGhC%2BkFaA%40mail.gmail.com

src/backend/nodes/bitmapset.c
src/include/nodes/bitmapset.h

index 65805d45277afd1f5858aae140270784b805f88f..cd05c642b04413af9d232e34b715d6957f5406fe 100644 (file)
 
 #define HAS_MULTIPLE_ONES(x)   ((bitmapword) RIGHTMOST_ONE(x) != (x))
 
-/* Select appropriate bit-twiddling functions for bitmap word size */
-#if BITS_PER_BITMAPWORD == 32
-#define bmw_leftmost_one_pos(w)        pg_leftmost_one_pos32(w)
-#define bmw_rightmost_one_pos(w)   pg_rightmost_one_pos32(w)
-#define bmw_popcount(w)                pg_popcount32(w)
-#elif BITS_PER_BITMAPWORD == 64
-#define bmw_leftmost_one_pos(w)        pg_leftmost_one_pos64(w)
-#define bmw_rightmost_one_pos(w)   pg_rightmost_one_pos64(w)
-#define bmw_popcount(w)                pg_popcount64(w)
-#else
-#error "invalid BITS_PER_BITMAPWORD"
-#endif
-
 #ifdef USE_ASSERT_CHECKING
 /*
  * bms_is_valid_set - for cassert builds to check for valid sets
index 906e8dcc1575742f7bf52045023c531acfe4d42e..283bea5ea961d20d92052d38ee5928e596fb5c3a 100644 (file)
@@ -73,6 +73,19 @@ typedef enum
    BMS_MULTIPLE,               /* >1 member */
 } BMS_Membership;
 
+/* Select appropriate bit-twiddling functions for bitmap word size */
+#if BITS_PER_BITMAPWORD == 32
+#define bmw_leftmost_one_pos(w)        pg_leftmost_one_pos32(w)
+#define bmw_rightmost_one_pos(w)   pg_rightmost_one_pos32(w)
+#define bmw_popcount(w)                pg_popcount32(w)
+#elif BITS_PER_BITMAPWORD == 64
+#define bmw_leftmost_one_pos(w)        pg_leftmost_one_pos64(w)
+#define bmw_rightmost_one_pos(w)   pg_rightmost_one_pos64(w)
+#define bmw_popcount(w)                pg_popcount64(w)
+#else
+#error "invalid BITS_PER_BITMAPWORD"
+#endif
+
 
 /*
  * function prototypes in nodes/bitmapset.c