Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit31b5c05

Browse files
committed
Restore include-file updates, and fix some of the more glaring macro
sloppiness (insufficient parenthesization, etc).It still fails regress test for me, however.
1 parent8f82141 commit31b5c05

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

‎contrib/intarray/_int.c

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
format for these routines is dictated by Postgres architecture.
55
******************************************************************************/
66

7-
#include<stdio.h>
7+
#include"postgres.h"
8+
89
#include<float.h>
9-
#include<string.h>
1010

11-
#include"postgres.h"
1211
#include"access/gist.h"
1312
#include"access/itup.h"
1413
#include"access/rtree.h"
@@ -22,7 +21,7 @@
2221

2322
#definemax(a,b) ((a) > (b) ? (a) : (b))
2423
#definemin(a,b) ((a) <= (b) ? (a) : (b))
25-
#defineabs(a) ((a) < (0) ?(-a) : (a))
24+
#defineabs(a) ((a) < (0) ?-(a) : (a))
2625

2726
#defineARRPTR(x) ( (int4 *) ARR_DATA_PTR(x) )
2827
#ifdefPGSQL71
@@ -53,7 +52,7 @@ typedef char* BITVECP;
5352

5453
#defineNULLIFY(a) MemSet( a, 0, sizeof( BITVEC ) )
5554
#defineNEWSIG(a) \
56-
a=(BITVECP) malloc( sizeof( BITVEC );\
55+
a=(BITVECP) malloc( sizeof( BITVEC ) );\
5756
NULLIFY(a);
5857

5958
#defineLOOPBYTE(a) \
@@ -66,10 +65,11 @@ typedef char* BITVECP;
6665
a;\
6766
}
6867

69-
#definegetbytebit(x,i) ( *( (char*)(x) + (int)( i / BITBYTE ) ) )
70-
#defineclrbit(x,i) getbytebit(x,i) &= ~( 0x01 << ( i % BITBYTE ) )
71-
#definesetbit(x,i) getbytebit(x,i) |= ( 0x01 << ( i % BITBYTE ) )
72-
#definegetbit(x,i) ( getbytebit(x,i) >> ( i % BITBYTE ) & 0x01 )
68+
/* beware of multiple evaluation of arguments to these macros! */
69+
#defineGETBYTEBIT(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) )
70+
#defineCLRBIT(x,i) GETBYTEBIT(x,i) &= ~( 0x01 << ( (i) % BITBYTE ) )
71+
#defineSETBIT(x,i) GETBYTEBIT(x,i) |= ( 0x01 << ( (i) % BITBYTE ) )
72+
#defineGETBIT(x,i) ( (GETBYTEBIT(x,i) >> ( (i) % BITBYTE )) & 0x01 )
7373

7474
#defineunion_sig(a,b,r) LOOPBYTE(r[i] = a[i] | b[i])
7575
#defineinter_sig(a,b,r) LOOPBYTE(r[i] = a[i] & b[i])
@@ -97,7 +97,7 @@ static void printbitvec( BITVEC bv ) {
9797
inti;
9898
charstr[SIGLENBIT+1 ];
9999
str[SIGLENBIT ]='\0';
100-
LOOPBIT(str[i]= (getbit(bv,i) ) ?'1' :'0' );
100+
LOOPBIT(str[i]= (GETBIT(bv,i) ) ?'1' :'0' );
101101

102102
elog(NOTICE,"BV: %s",str);
103103
}
@@ -727,7 +727,7 @@ gensign(BITVEC sign, int * a, int len) {
727727
inti;
728728
NULLIFY(sign);
729729
for(i=0;i<len;i++) {
730-
setbit(sign,*a%SIGLENBIT );
730+
SETBIT(sign,(*a)%SIGLENBIT );
731731
a++;
732732
}
733733
}
@@ -770,7 +770,7 @@ rt__intbig_size(ArrayType *a, float* sz) {
770770
}
771771

772772
bv=SIGPTR(a);
773-
LOOPBIT(len+=getbit(bv,i) );
773+
LOOPBIT(len+=GETBIT(bv,i) );
774774
*sz= (float)len;
775775
return;
776776
}
@@ -780,8 +780,9 @@ _intbig_union(ArrayType *a, ArrayType *b) {
780780
ArrayType*r=NULL;
781781
BITVECPda,db,dr;
782782
inti;
783-
783+
784784
if (ARRISNULL(a )&&ARRISNULL(b ) )returnnew_intArrayType(0);
785+
785786
if (ARRISNULL(a ) ) {
786787
r=copy_intArrayType(b );
787788
returnr;
@@ -876,7 +877,7 @@ g_intbig_compress(GISTENTRY *entry) {
876877
gensign(SIGPTR(r ),
877878
ARRPTR (in ),
878879
ARRSIZE(in ) );
879-
880+
880881
gistentryinit(*retval, (char*)r,entry->rel,entry->page,entry->offset,VARSIZE(r ), FALSE);
881882

882883
#ifdefPGSQL71
@@ -971,10 +972,12 @@ g_intbig_penalty(GISTENTRY *origentry, GISTENTRY *newentry, float *result){
971972
bool
972973
g_intbig_consistent(GISTENTRY*entry,ArrayType*query,StrategyNumberstrategy) {
973974
boolretval;
974-
ArrayType*q=new_intArrayType(SIGLENINT );
975+
ArrayType*q;
975976

976977
if (ARRISNULL(query ) )return FALSE;
977978

979+
q=new_intArrayType(SIGLENINT );
980+
978981
gensign(SIGPTR(q ),
979982
ARRPTR(query ),
980983
ARRSIZE(query ) );
@@ -1060,7 +1063,7 @@ _int_common_penalty(GISTENTRY *origentry, GISTENTRY *newentry, float *result,
10601063
pfree((char*)ud);
10611064

10621065
#ifdefGIST_DEBUG
1063-
elog(NOTICE,"--penalty\t%g",*result);
1066+
elog(NOTICE,"--penalty\t%g\t%g\t%g",*result,tmp1,tmp2);
10641067
#endif
10651068

10661069
return(result);
@@ -1160,6 +1163,7 @@ _int_common_picksplit(bytea *entryvec,
11601163
*/
11611164

11621165
maxoff=OffsetNumberNext(maxoff);
1166+
11631167
for (i=FirstOffsetNumber;i <=maxoff;i=OffsetNumberNext(i)) {
11641168

11651169

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp