Skip to content

Commit bad1a5c

Browse files
committed
Use postgres-wide macros BITS_PER_BYTE instead self-definenig macros, also use it for calculating bit length of TPQTGist
1 parent 34b934f commit bad1a5c

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

contrib/tsearch2/gistidx.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@
99
* signature defines
1010
*/
1111

12-
#define BITBYTE 8
1312
#define SIGLENINT 63 /* >121 => key will toast, so it will not work
1413
* !!! */
1514
#define SIGLEN ( sizeof(int4) * SIGLENINT )
16-
#define SIGLENBIT (SIGLEN * BITBYTE)
15+
#define SIGLENBIT (SIGLEN * BITS_PER_BYTE)
1716

1817
typedef char BITVEC[SIGLEN];
1918
typedef char *BITVECP;
@@ -27,11 +26,11 @@ typedef char *BITVECP;
2726
a;\
2827
}
2928

30-
#define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) )
29+
#define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITS_PER_BYTE ) ) )
3130
#define GETBITBYTE(x,i) ( ((char)(x)) >> (i) & 0x01 )
32-
#define CLRBIT(x,i) GETBYTE(x,i) &= ~( 0x01 << ( (i) % BITBYTE ) )
33-
#define SETBIT(x,i) GETBYTE(x,i) |= ( 0x01 << ( (i) % BITBYTE ) )
34-
#define GETBIT(x,i) ( (GETBYTE(x,i) >> ( (i) % BITBYTE )) & 0x01 )
31+
#define CLRBIT(x,i) GETBYTE(x,i) &= ~( 0x01 << ( (i) % BITS_PER_BYTE ) )
32+
#define SETBIT(x,i) GETBYTE(x,i) |= ( 0x01 << ( (i) % BITS_PER_BYTE ) )
33+
#define GETBIT(x,i) ( (GETBYTE(x,i) >> ( (i) % BITS_PER_BYTE )) & 0x01 )
3534

3635
#define HASHVAL(val) (((unsigned int)(val)) % SIGLENBIT)
3736
#define HASH(sign, val) SETBIT((sign), HASHVAL(val))

contrib/tsearch2/query_gist.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include "query.h"
88

99
typedef uint64 TPQTGist;
10+
#define SIGLEN (sizeof(TPQTGist)*BITS_PER_BYTE)
11+
1012

1113
#define GETENTRY(vec,pos) ((TPQTGist *) DatumGetPointer((vec)->vector[(pos)].key))
1214

@@ -24,7 +26,7 @@ makesign(QUERYTYPE* a) {
2426

2527
for (i = 0; i < a->size; i++) {
2628
if ( ptr->type == VAL )
27-
sign |= 1 << (ptr->val % 64);
29+
sign |= 1 << (ptr->val % SIGLEN);
2830
ptr++;
2931
}
3032

@@ -198,7 +200,7 @@ static int
198200
sizebitvec(TPQTGist sign) {
199201
int size=0,i;
200202

201-
for(i=0;i<64;i++)
203+
for(i=0;i<SIGLEN;i++)
202204
size += 0x01 & (sign>>i);
203205

204206
return size;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy