Commit 31b5c058 authored by Tom Lane's avatar Tom Lane

Restore include-file updates, and fix some of the more glaring macro

sloppiness (insufficient parenthesization, etc).
It still fails regress test for me, however.
parent 8f82141b
...@@ -4,11 +4,10 @@ ...@@ -4,11 +4,10 @@
format for these routines is dictated by Postgres architecture. format for these routines is dictated by Postgres architecture.
******************************************************************************/ ******************************************************************************/
#include <stdio.h> #include "postgres.h"
#include <float.h> #include <float.h>
#include <string.h>
#include "postgres.h"
#include "access/gist.h" #include "access/gist.h"
#include "access/itup.h" #include "access/itup.h"
#include "access/rtree.h" #include "access/rtree.h"
...@@ -22,7 +21,7 @@ ...@@ -22,7 +21,7 @@
#define max(a,b) ((a) > (b) ? (a) : (b)) #define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) <= (b) ? (a) : (b)) #define min(a,b) ((a) <= (b) ? (a) : (b))
#define abs(a) ((a) < (0) ? (-a) : (a)) #define abs(a) ((a) < (0) ? -(a) : (a))
#define ARRPTR(x) ( (int4 *) ARR_DATA_PTR(x) ) #define ARRPTR(x) ( (int4 *) ARR_DATA_PTR(x) )
#ifdef PGSQL71 #ifdef PGSQL71
...@@ -53,7 +52,7 @@ typedef char* BITVECP; ...@@ -53,7 +52,7 @@ typedef char* BITVECP;
#define NULLIFY(a) MemSet( a, 0, sizeof( BITVEC ) ) #define NULLIFY(a) MemSet( a, 0, sizeof( BITVEC ) )
#define NEWSIG(a) \ #define NEWSIG(a) \
a=(BITVECP) malloc( sizeof( BITVEC );\ a=(BITVECP) malloc( sizeof( BITVEC ) );\
NULLIFY(a); NULLIFY(a);
#define LOOPBYTE(a) \ #define LOOPBYTE(a) \
...@@ -66,10 +65,11 @@ typedef char* BITVECP; ...@@ -66,10 +65,11 @@ typedef char* BITVECP;
a;\ a;\
} }
#define getbytebit(x,i) ( *( (char*)(x) + (int)( i / BITBYTE ) ) ) /* beware of multiple evaluation of arguments to these macros! */
#define clrbit(x,i) getbytebit(x,i) &= ~( 0x01 << ( i % BITBYTE ) ) #define GETBYTEBIT(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) )
#define setbit(x,i) getbytebit(x,i) |= ( 0x01 << ( i % BITBYTE ) ) #define CLRBIT(x,i) GETBYTEBIT(x,i) &= ~( 0x01 << ( (i) % BITBYTE ) )
#define getbit(x,i) ( getbytebit(x,i) >> ( i % BITBYTE ) & 0x01 ) #define SETBIT(x,i) GETBYTEBIT(x,i) |= ( 0x01 << ( (i) % BITBYTE ) )
#define GETBIT(x,i) ( (GETBYTEBIT(x,i) >> ( (i) % BITBYTE )) & 0x01 )
#define union_sig(a,b,r) LOOPBYTE(r[i] = a[i] | b[i]) #define union_sig(a,b,r) LOOPBYTE(r[i] = a[i] | b[i])
#define inter_sig(a,b,r) LOOPBYTE(r[i] = a[i] & b[i]) #define inter_sig(a,b,r) LOOPBYTE(r[i] = a[i] & b[i])
...@@ -97,7 +97,7 @@ static void printbitvec( BITVEC bv ) { ...@@ -97,7 +97,7 @@ static void printbitvec( BITVEC bv ) {
int i; int i;
char str[ SIGLENBIT+1 ]; char str[ SIGLENBIT+1 ];
str[ SIGLENBIT ] ='\0'; str[ SIGLENBIT ] ='\0';
LOOPBIT( str[i] = ( getbit(bv,i) ) ? '1' : '0' ); LOOPBIT( str[i] = ( GETBIT(bv,i) ) ? '1' : '0' );
elog(NOTICE,"BV: %s", str); elog(NOTICE,"BV: %s", str);
} }
...@@ -727,7 +727,7 @@ gensign(BITVEC sign, int * a, int len) { ...@@ -727,7 +727,7 @@ gensign(BITVEC sign, int * a, int len) {
int i; int i;
NULLIFY(sign); NULLIFY(sign);
for(i=0; i<len; i++) { for(i=0; i<len; i++) {
setbit( sign, *a%SIGLENBIT ); SETBIT( sign, (*a)%SIGLENBIT );
a++; a++;
} }
} }
...@@ -770,7 +770,7 @@ rt__intbig_size(ArrayType *a, float* sz) { ...@@ -770,7 +770,7 @@ rt__intbig_size(ArrayType *a, float* sz) {
} }
bv = SIGPTR(a); bv = SIGPTR(a);
LOOPBIT( len += getbit(bv, i) ); LOOPBIT( len += GETBIT(bv, i) );
*sz = (float) len; *sz = (float) len;
return; return;
} }
...@@ -780,8 +780,9 @@ _intbig_union(ArrayType *a, ArrayType *b) { ...@@ -780,8 +780,9 @@ _intbig_union(ArrayType *a, ArrayType *b) {
ArrayType * r = NULL; ArrayType * r = NULL;
BITVECP da, db, dr; BITVECP da, db, dr;
int i; int i;
if ( ARRISNULL( a ) && ARRISNULL( b ) ) return new_intArrayType(0); if ( ARRISNULL( a ) && ARRISNULL( b ) ) return new_intArrayType(0);
if ( ARRISNULL( a ) ) { if ( ARRISNULL( a ) ) {
r = copy_intArrayType( b ); r = copy_intArrayType( b );
return r; return r;
...@@ -876,7 +877,7 @@ g_intbig_compress(GISTENTRY *entry) { ...@@ -876,7 +877,7 @@ g_intbig_compress(GISTENTRY *entry) {
gensign( SIGPTR( r ), gensign( SIGPTR( r ),
ARRPTR ( in ), ARRPTR ( in ),
ARRSIZE( in ) ); ARRSIZE( in ) );
gistentryinit(*retval, (char *)r, entry->rel, entry->page, entry->offset, VARSIZE( r ), FALSE); gistentryinit(*retval, (char *)r, entry->rel, entry->page, entry->offset, VARSIZE( r ), FALSE);
#ifdef PGSQL71 #ifdef PGSQL71
...@@ -971,10 +972,12 @@ g_intbig_penalty(GISTENTRY *origentry, GISTENTRY *newentry, float *result){ ...@@ -971,10 +972,12 @@ g_intbig_penalty(GISTENTRY *origentry, GISTENTRY *newentry, float *result){
bool bool
g_intbig_consistent(GISTENTRY *entry, ArrayType *query, StrategyNumber strategy) { g_intbig_consistent(GISTENTRY *entry, ArrayType *query, StrategyNumber strategy) {
bool retval; bool retval;
ArrayType * q = new_intArrayType( SIGLENINT ); ArrayType * q;
if ( ARRISNULL( query ) ) return FALSE; if ( ARRISNULL( query ) ) return FALSE;
q = new_intArrayType( SIGLENINT );
gensign( SIGPTR( q ), gensign( SIGPTR( q ),
ARRPTR( query ), ARRPTR( query ),
ARRSIZE( query ) ); ARRSIZE( query ) );
...@@ -1060,7 +1063,7 @@ _int_common_penalty(GISTENTRY *origentry, GISTENTRY *newentry, float *result, ...@@ -1060,7 +1063,7 @@ _int_common_penalty(GISTENTRY *origentry, GISTENTRY *newentry, float *result,
pfree((char *)ud); pfree((char *)ud);
#ifdef GIST_DEBUG #ifdef GIST_DEBUG
elog(NOTICE, "--penalty\t%g", *result); elog(NOTICE, "--penalty\t%g\t%g\t%g", *result, tmp1, tmp2);
#endif #endif
return(result); return(result);
...@@ -1160,6 +1163,7 @@ _int_common_picksplit(bytea *entryvec, ...@@ -1160,6 +1163,7 @@ _int_common_picksplit(bytea *entryvec,
*/ */
maxoff = OffsetNumberNext(maxoff); maxoff = OffsetNumberNext(maxoff);
for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i)) { for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment