Commit b492c3ac authored by Bruce Momjian's avatar Bruce Momjian

Add parentheses to macros when args are used in computations. Without

them, the executation behavior could be unexpected.
parent 13b729ca
...@@ -466,7 +466,7 @@ typedef struct ...@@ -466,7 +466,7 @@ typedef struct
int4 buflen; int4 buflen;
} INFIX; } INFIX;
#define RESIZEBUF(inf,addsize) while( ( inf->cur - inf->buf ) + addsize + 1 >= inf->buflen ) { \ #define RESIZEBUF(inf,addsize) while( ( (inf)->cur - (inf)->buf ) + (addsize) + 1 >= (inf)->buflen ) { \
int4 len = inf->cur - inf->buf; \ int4 len = inf->cur - inf->buf; \
inf->buflen *= 2; \ inf->buflen *= 2; \
inf->buf = (char*) repalloc( (void*)inf->buf, inf->buflen ); \ inf->buf = (char*) repalloc( (void*)inf->buf, inf->buflen ); \
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
* Oroginal code by Spencer Garrett <srg@quick.com> * Oroginal code by Spencer Garrett <srg@quick.com>
*/ */
#define _CRC32_(crc, ch) (crc = (crc >> 8) ^ crc32tab[(crc ^ (ch)) & 0xff]) #define _CRC32_(crc, ch) ((crc) = ((crc) >> 8) ^ crc32tab[((crc) ^ (ch)) & 0xff])
/* generated using the AUTODIN II polynomial /* generated using the AUTODIN II polynomial
* x^32 + x^26 + x^23 + x^22 + x^16 + * x^32 + x^26 + x^23 + x^22 + x^16 +
......
...@@ -109,7 +109,7 @@ typedef struct ...@@ -109,7 +109,7 @@ typedef struct
} ltxtquery; } ltxtquery;
#define HDRSIZEQT MAXALIGN( 2*sizeof(int4) ) #define HDRSIZEQT MAXALIGN( 2*sizeof(int4) )
#define COMPUTESIZE(size,lenofoperand) ( HDRSIZEQT + size * sizeof(ITEM) + lenofoperand ) #define COMPUTESIZE(size,lenofoperand) ( HDRSIZEQT + (size) * sizeof(ITEM) + (lenofoperand) )
#define GETQUERY(x) (ITEM*)( (char*)(x)+HDRSIZEQT ) #define GETQUERY(x) (ITEM*)( (char*)(x)+HDRSIZEQT )
#define GETOPERAND(x) ( (char*)GETQUERY(x) + ((ltxtquery*)x)->size * sizeof(ITEM) ) #define GETOPERAND(x) ( (char*)GETQUERY(x) + ((ltxtquery*)x)->size * sizeof(ITEM) )
......
...@@ -386,12 +386,12 @@ typedef struct ...@@ -386,12 +386,12 @@ typedef struct
} INFIX; } INFIX;
#define RESIZEBUF(inf,addsize) \ #define RESIZEBUF(inf,addsize) \
while( ( inf->cur - inf->buf ) + addsize + 1 >= inf->buflen ) \ while( ( (inf)->cur - (inf)->buf ) + (addsize) + 1 >= (inf)->buflen ) \
{ \ { \
int4 len = inf->cur - inf->buf; \ int4 len = (inf)->cur - (inf)->buf; \
inf->buflen *= 2; \ (inf)->buflen *= 2; \
inf->buf = (char*) repalloc( (void*)inf->buf, inf->buflen ); \ (inf)->buf = (char*) repalloc( (void*)(inf)->buf, (inf)->buflen ); \
inf->cur = inf->buf + len; \ (inf)->cur = (inf)->buf + len; \
} }
/* /*
......
...@@ -452,41 +452,41 @@ BF_swap(BF_word * x, int count) ...@@ -452,41 +452,41 @@ BF_swap(BF_word * x, int count)
#if BF_SCALE #if BF_SCALE
/* Architectures which can shift addresses left by 2 bits with no extra cost */ /* Architectures which can shift addresses left by 2 bits with no extra cost */
#define BF_ROUND(L, R, N) \ #define BF_ROUND(L, R, N) \
tmp1 = L & 0xFF; \ tmp1 = (L) & 0xFF; \
tmp2 = L >> 8; \ tmp2 = (L) >> 8; \
tmp2 &= 0xFF; \ tmp2 &= 0xFF; \
tmp3 = L >> 16; \ tmp3 = (L) >> 16; \
tmp3 &= 0xFF; \ tmp3 &= 0xFF; \
tmp4 = L >> 24; \ tmp4 = (L) >> 24; \
tmp1 = data.ctx.S[3][tmp1]; \ tmp1 = data.ctx.S[3][tmp1]; \
tmp2 = data.ctx.S[2][tmp2]; \ tmp2 = data.ctx.S[2][tmp2]; \
tmp3 = data.ctx.S[1][tmp3]; \ tmp3 = data.ctx.S[1][tmp3]; \
tmp3 += data.ctx.S[0][tmp4]; \ tmp3 += data.ctx.S[0][tmp4]; \
tmp3 ^= tmp2; \ tmp3 ^= tmp2; \
R ^= data.ctx.P[N + 1]; \ (R) ^= data.ctx.P[(N) + 1]; \
tmp3 += tmp1; \ tmp3 += tmp1; \
R ^= tmp3; (R) ^= tmp3;
#else #else
/* Architectures with no complicated addressing modes supported */ /* Architectures with no complicated addressing modes supported */
#define BF_INDEX(S, i) \ #define BF_INDEX(S, i) \
(*((BF_word *)(((unsigned char *)S) + (i)))) (*((BF_word *)(((unsigned char *)(S)) + (i))))
#define BF_ROUND(L, R, N) \ #define BF_ROUND(L, R, N) \
tmp1 = L & 0xFF; \ tmp1 = (L) & 0xFF; \
tmp1 <<= 2; \ tmp1 <<= 2; \
tmp2 = L >> 6; \ tmp2 = (L) >> 6; \
tmp2 &= 0x3FC; \ tmp2 &= 0x3FC; \
tmp3 = L >> 14; \ tmp3 = (L) >> 14; \
tmp3 &= 0x3FC; \ tmp3 &= 0x3FC; \
tmp4 = L >> 22; \ tmp4 = (L) >> 22; \
tmp4 &= 0x3FC; \ tmp4 &= 0x3FC; \
tmp1 = BF_INDEX(data.ctx.S[3], tmp1); \ tmp1 = BF_INDEX(data.ctx.S[3], tmp1); \
tmp2 = BF_INDEX(data.ctx.S[2], tmp2); \ tmp2 = BF_INDEX(data.ctx.S[2], tmp2); \
tmp3 = BF_INDEX(data.ctx.S[1], tmp3); \ tmp3 = BF_INDEX(data.ctx.S[1], tmp3); \
tmp3 += BF_INDEX(data.ctx.S[0], tmp4); \ tmp3 += BF_INDEX(data.ctx.S[0], tmp4); \
tmp3 ^= tmp2; \ tmp3 ^= tmp2; \
R ^= data.ctx.P[N + 1]; \ (R) ^= data.ctx.P[(N) + 1]; \
tmp3 += tmp1; \ tmp3 += tmp1; \
R ^= tmp3; (R) ^= tmp3;
#endif #endif
/* /*
......
...@@ -57,11 +57,11 @@ static void gen_tabs(void); ...@@ -57,11 +57,11 @@ static void gen_tabs(void);
/* Invert byte order in a 32 bit variable */ /* Invert byte order in a 32 bit variable */
#define bswap(x) ((rotl(x, 8) & 0x00ff00ff) | (rotr(x, 8) & 0xff00ff00)) #define bswap(x) ((rotl((x), 8) & 0x00ff00ff) | (rotr((x), 8) & 0xff00ff00))
/* Extract byte from a 32 bit quantity (little endian notation) */ /* Extract byte from a 32 bit quantity (little endian notation) */
#define byte(x,n) ((u1byte)((x) >> (8 * n))) #define byte(x,n) ((u1byte)((x) >> (8 * (n))))
#if BYTE_ORDER != LITTLE_ENDIAN #if BYTE_ORDER != LITTLE_ENDIAN
#define BYTE_SWAP #define BYTE_SWAP
...@@ -100,19 +100,19 @@ static u4byte il_tab[4][256]; ...@@ -100,19 +100,19 @@ static u4byte il_tab[4][256];
static u4byte tab_gen = 0; static u4byte tab_gen = 0;
#endif /* !PRE_CALC_TABLES */ #endif /* !PRE_CALC_TABLES */
#define ff_mult(a,b) (a && b ? pow_tab[(log_tab[a] + log_tab[b]) % 255] : 0) #define ff_mult(a,b) ((a) && (b) ? pow_tab[(log_tab[a] + log_tab[b]) % 255] : 0)
#define f_rn(bo, bi, n, k) \ #define f_rn(bo, bi, n, k) \
bo[n] = ft_tab[0][byte(bi[n],0)] ^ \ (bo)[n] = ft_tab[0][byte((bi)[n],0)] ^ \
ft_tab[1][byte(bi[(n + 1) & 3],1)] ^ \ ft_tab[1][byte((bi)[((n) + 1) & 3],1)] ^ \
ft_tab[2][byte(bi[(n + 2) & 3],2)] ^ \ ft_tab[2][byte((bi)[((n) + 2) & 3],2)] ^ \
ft_tab[3][byte(bi[(n + 3) & 3],3)] ^ *(k + n) ft_tab[3][byte((bi)[((n) + 3) & 3],3)] ^ *((k) + (n))
#define i_rn(bo, bi, n, k) \ #define i_rn(bo, bi, n, k) \
bo[n] = it_tab[0][byte(bi[n],0)] ^ \ (bo)[n] = it_tab[0][byte((bi)[n],0)] ^ \
it_tab[1][byte(bi[(n + 3) & 3],1)] ^ \ it_tab[1][byte((bi)[((n) + 3) & 3],1)] ^ \
it_tab[2][byte(bi[(n + 2) & 3],2)] ^ \ it_tab[2][byte((bi)[((n) + 2) & 3],2)] ^ \
it_tab[3][byte(bi[(n + 1) & 3],3)] ^ *(k + n) it_tab[3][byte((bi)[((n) + 1) & 3],3)] ^ *((k) + (n))
#ifdef LARGE_TABLES #ifdef LARGE_TABLES
...@@ -123,16 +123,16 @@ static u4byte tab_gen = 0; ...@@ -123,16 +123,16 @@ static u4byte tab_gen = 0;
fl_tab[3][byte(x, 3)] ) fl_tab[3][byte(x, 3)] )
#define f_rl(bo, bi, n, k) \ #define f_rl(bo, bi, n, k) \
bo[n] = fl_tab[0][byte(bi[n],0)] ^ \ (bo)[n] = fl_tab[0][byte((bi)[n],0)] ^ \
fl_tab[1][byte(bi[(n + 1) & 3],1)] ^ \ fl_tab[1][byte((bi)[((n) + 1) & 3],1)] ^ \
fl_tab[2][byte(bi[(n + 2) & 3],2)] ^ \ fl_tab[2][byte((bi)[((n) + 2) & 3],2)] ^ \
fl_tab[3][byte(bi[(n + 3) & 3],3)] ^ *(k + n) fl_tab[3][byte((bi)[((n) + 3) & 3],3)] ^ *((k) + (n))
#define i_rl(bo, bi, n, k) \ #define i_rl(bo, bi, n, k) \
bo[n] = il_tab[0][byte(bi[n],0)] ^ \ (bo)[n] = il_tab[0][byte((bi)[n],0)] ^ \
il_tab[1][byte(bi[(n + 3) & 3],1)] ^ \ il_tab[1][byte((bi)[((n) + 3) & 3],1)] ^ \
il_tab[2][byte(bi[(n + 2) & 3],2)] ^ \ il_tab[2][byte((bi)[((n) + 2) & 3],2)] ^ \
il_tab[3][byte(bi[(n + 1) & 3],3)] ^ *(k + n) il_tab[3][byte((bi)[((n) + 1) & 3],3)] ^ *((k) + (n))
#else #else
...@@ -143,16 +143,16 @@ static u4byte tab_gen = 0; ...@@ -143,16 +143,16 @@ static u4byte tab_gen = 0;
((u4byte)sbx_tab[byte(x, 3)] << 24) ((u4byte)sbx_tab[byte(x, 3)] << 24)
#define f_rl(bo, bi, n, k) \ #define f_rl(bo, bi, n, k) \
bo[n] = (u4byte)sbx_tab[byte(bi[n],0)] ^ \ (bo)[n] = (u4byte)sbx_tab[byte((bi)[n],0)] ^ \
rotl(((u4byte)sbx_tab[byte(bi[(n + 1) & 3],1)]), 8) ^ \ rotl(((u4byte)sbx_tab[byte((bi)[((n) + 1) & 3],1)]), 8) ^ \
rotl(((u4byte)sbx_tab[byte(bi[(n + 2) & 3],2)]), 16) ^ \ rotl(((u4byte)sbx_tab[byte((bi)[((n) + 2) & 3],2)]), 16) ^ \
rotl(((u4byte)sbx_tab[byte(bi[(n + 3) & 3],3)]), 24) ^ *(k + n) rotl(((u4byte)sbx_tab[byte((bi)[((n) + 3) & 3],3)]), 24) ^ *((k) + (n))
#define i_rl(bo, bi, n, k) \ #define i_rl(bo, bi, n, k) \
bo[n] = (u4byte)isb_tab[byte(bi[n],0)] ^ \ (bo)[n] = (u4byte)isb_tab[byte((bi)[n],0)] ^ \
rotl(((u4byte)isb_tab[byte(bi[(n + 3) & 3],1)]), 8) ^ \ rotl(((u4byte)isb_tab[byte((bi)[((n) + 3) & 3],1)]), 8) ^ \
rotl(((u4byte)isb_tab[byte(bi[(n + 2) & 3],2)]), 16) ^ \ rotl(((u4byte)isb_tab[byte((bi)[((n) + 2) & 3],2)]), 16) ^ \
rotl(((u4byte)isb_tab[byte(bi[(n + 1) & 3],3)]), 24) ^ *(k + n) rotl(((u4byte)isb_tab[byte((bi)[((n) + 1) & 3],3)]), 24) ^ *((k) + (n))
#endif #endif
static void static void
...@@ -282,25 +282,25 @@ do { t = ls_box(rotr(t, 8)) ^ rco_tab[i]; \ ...@@ -282,25 +282,25 @@ do { t = ls_box(rotr(t, 8)) ^ rco_tab[i]; \
#define loop6(i) \ #define loop6(i) \
do { t = ls_box(rotr(t, 8)) ^ rco_tab[i]; \ do { t = ls_box(rotr(t, 8)) ^ rco_tab[i]; \
t ^= e_key[6 * i]; e_key[6 * i + 6] = t; \ t ^= e_key[6 * (i)]; e_key[6 * (i) + 6] = t; \
t ^= e_key[6 * i + 1]; e_key[6 * i + 7] = t; \ t ^= e_key[6 * (i) + 1]; e_key[6 * (i) + 7] = t; \
t ^= e_key[6 * i + 2]; e_key[6 * i + 8] = t; \ t ^= e_key[6 * (i) + 2]; e_key[6 * (i) + 8] = t; \
t ^= e_key[6 * i + 3]; e_key[6 * i + 9] = t; \ t ^= e_key[6 * (i) + 3]; e_key[6 * (i) + 9] = t; \
t ^= e_key[6 * i + 4]; e_key[6 * i + 10] = t; \ t ^= e_key[6 * (i) + 4]; e_key[6 * (i) + 10] = t; \
t ^= e_key[6 * i + 5]; e_key[6 * i + 11] = t; \ t ^= e_key[6 * (i) + 5]; e_key[6 * (i) + 11] = t; \
} while (0) } while (0)
#define loop8(i) \ #define loop8(i) \
do { t = ls_box(rotr(t, 8)) ^ rco_tab[i]; \ do { t = ls_box(rotr(t, 8)) ^ rco_tab[i]; \
t ^= e_key[8 * i]; e_key[8 * i + 8] = t; \ t ^= e_key[8 * (i)]; e_key[8 * (i) + 8] = t; \
t ^= e_key[8 * i + 1]; e_key[8 * i + 9] = t; \ t ^= e_key[8 * (i) + 1]; e_key[8 * (i) + 9] = t; \
t ^= e_key[8 * i + 2]; e_key[8 * i + 10] = t; \ t ^= e_key[8 * (i) + 2]; e_key[8 * (i) + 10] = t; \
t ^= e_key[8 * i + 3]; e_key[8 * i + 11] = t; \ t ^= e_key[8 * (i) + 3]; e_key[8 * (i) + 11] = t; \
t = e_key[8 * i + 4] ^ ls_box(t); \ t = e_key[8 * (i) + 4] ^ ls_box(t); \
e_key[8 * i + 12] = t; \ e_key[8 * (i) + 12] = t; \
t ^= e_key[8 * i + 5]; e_key[8 * i + 13] = t; \ t ^= e_key[8 * (i) + 5]; e_key[8 * (i) + 13] = t; \
t ^= e_key[8 * i + 6]; e_key[8 * i + 14] = t; \ t ^= e_key[8 * (i) + 6]; e_key[8 * (i) + 14] = t; \
t ^= e_key[8 * i + 7]; e_key[8 * i + 15] = t; \ t ^= e_key[8 * (i) + 7]; e_key[8 * (i) + 15] = t; \
} while (0) } while (0)
rijndael_ctx * rijndael_ctx *
......
/* $PostgreSQL: pgsql/contrib/pgcrypto/sha1.c,v 1.14 2004/08/29 16:43:05 tgl Exp $ */ /* $PostgreSQL: pgsql/contrib/pgcrypto/sha1.c,v 1.15 2005/05/25 21:40:39 momjian Exp $ */
/* $KAME: sha1.c,v 1.3 2000/02/22 14:01:18 itojun Exp $ */ /* $KAME: sha1.c,v 1.3 2000/02/22 14:01:18 itojun Exp $ */
/* /*
...@@ -59,7 +59,7 @@ static uint32 _K[] = {0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6}; ...@@ -59,7 +59,7 @@ static uint32 _K[] = {0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6};
#define F2(b, c, d) (((b) & (c)) | ((b) & (d)) | ((c) & (d))) #define F2(b, c, d) (((b) & (c)) | ((b) & (d)) | ((c) & (d)))
#define F3(b, c, d) (((b) ^ (c)) ^ (d)) #define F3(b, c, d) (((b) ^ (c)) ^ (d))
#define S(n, x) (((x) << (n)) | ((x) >> (32 - n))) #define S(n, x) (((x) << (n)) | ((x) >> (32 - (n))))
#define H(n) (ctxt->h.b32[(n)]) #define H(n) (ctxt->h.b32[(n)])
#define COUNT (ctxt->count) #define COUNT (ctxt->count)
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/contrib/rtree_gist/rtree_gist.c,v 1.11 2005/05/21 12:08:05 neilc Exp $ * $PostgreSQL: pgsql/contrib/rtree_gist/rtree_gist.c,v 1.12 2005/05/25 21:40:40 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -276,14 +276,14 @@ gbox_picksplit(PG_FUNCTION_ARGS) ...@@ -276,14 +276,14 @@ gbox_picksplit(PG_FUNCTION_ARGS)
#define ADDLIST( list, unionD, pos, num ) do { \ #define ADDLIST( list, unionD, pos, num ) do { \
if ( pos ) { \ if ( pos ) { \
if ( unionD->high.x < cur->high.x ) unionD->high.x = cur->high.x; \ if ( (unionD)->high.x < cur->high.x ) (unionD)->high.x = cur->high.x; \
if ( unionD->low.x > cur->low.x ) unionD->low.x = cur->low.x; \ if ( (unionD)->low.x > cur->low.x ) (unionD)->low.x = cur->low.x; \
if ( unionD->high.y < cur->high.y ) unionD->high.y = cur->high.y; \ if ( (unionD)->high.y < cur->high.y ) (unionD)->high.y = cur->high.y; \
if ( unionD->low.y > cur->low.y ) unionD->low.y = cur->low.y; \ if ( (unionD)->low.y > cur->low.y ) (unionD)->low.y = cur->low.y; \
} else { \ } else { \
memcpy( (void*)unionD, (void*) cur, sizeof( BOX ) ); \ memcpy( (void*)(unionD), (void*) cur, sizeof( BOX ) ); \
} \ } \
list[pos] = num; \ (list)[pos] = num; \
(pos)++; \ (pos)++; \
} while(0) } while(0)
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* Oroginal code by Spencer Garrett <srg@quick.com> * Oroginal code by Spencer Garrett <srg@quick.com>
*/ */
#define _CRC32_(crc, ch) (crc = (crc >> 8) ^ crc32tab[(crc ^ (ch)) & 0xff]) #define _CRC32_(crc, ch) ((crc) = ((crc) >> 8) ^ crc32tab[((crc) ^ (ch)) & 0xff])
/* generated using the AUTODIN II polynomial /* generated using the AUTODIN II polynomial
* x^32 + x^26 + x^23 + x^22 + x^16 + * x^32 + x^26 + x^23 + x^22 + x^16 +
......
...@@ -27,7 +27,7 @@ typedef char *BITVECP; ...@@ -27,7 +27,7 @@ typedef char *BITVECP;
} }
#define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) ) #define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) )
#define GETBITBYTE(x,i) ( ((char)(x)) >> i & 0x01 ) #define GETBITBYTE(x,i) ( ((char)(x)) >> (i) & 0x01 )
#define CLRBIT(x,i) GETBYTE(x,i) &= ~( 0x01 << ( (i) % BITBYTE ) ) #define CLRBIT(x,i) GETBYTE(x,i) &= ~( 0x01 << ( (i) % BITBYTE ) )
#define SETBIT(x,i) GETBYTE(x,i) |= ( 0x01 << ( (i) % BITBYTE ) ) #define SETBIT(x,i) GETBYTE(x,i) |= ( 0x01 << ( (i) % BITBYTE ) )
#define GETBIT(x,i) ( (GETBYTE(x,i) >> ( (i) % BITBYTE )) & 0x01 ) #define GETBIT(x,i) ( (GETBYTE(x,i) >> ( (i) % BITBYTE )) & 0x01 )
...@@ -50,15 +50,15 @@ typedef struct ...@@ -50,15 +50,15 @@ typedef struct
#define SIGNKEY 0x02 #define SIGNKEY 0x02
#define ALLISTRUE 0x04 #define ALLISTRUE 0x04
#define ISARRKEY(x) ( ((GISTTYPE*)x)->flag & ARRKEY ) #define ISARRKEY(x) ( ((GISTTYPE*)(x))->flag & ARRKEY )
#define ISSIGNKEY(x) ( ((GISTTYPE*)x)->flag & SIGNKEY ) #define ISSIGNKEY(x) ( ((GISTTYPE*)(x))->flag & SIGNKEY )
#define ISALLTRUE(x) ( ((GISTTYPE*)x)->flag & ALLISTRUE ) #define ISALLTRUE(x) ( ((GISTTYPE*)(x))->flag & ALLISTRUE )
#define GTHDRSIZE ( sizeof(int4)*2 ) #define GTHDRSIZE ( sizeof(int4)* 2 )
#define CALCGTSIZE(flag, len) ( GTHDRSIZE + ( ( (flag) & ARRKEY ) ? ((len)*sizeof(int4)) : (((flag) & ALLISTRUE) ? 0 : SIGLEN) ) ) #define CALCGTSIZE(flag, len) ( GTHDRSIZE + ( ( (flag) & ARRKEY ) ? ((len)*sizeof(int4)) : (((flag) & ALLISTRUE) ? 0 : SIGLEN) ) )
#define GETSIGN(x) ( (BITVECP)( (char*)x+GTHDRSIZE ) ) #define GETSIGN(x) ( (BITVECP)( (char*)(x) + GTHDRSIZE ) )
#define GETARR(x) ( (int4*)( (char*)x+GTHDRSIZE ) ) #define GETARR(x) ( (int4*)( (char*)(x) + GTHDRSIZE ) )
#define ARRNELEM(x) ( ( ((GISTTYPE*)x)->len - GTHDRSIZE )/sizeof(int4) ) #define ARRNELEM(x) ( ( ((GISTTYPE*)(x))->len - GTHDRSIZE ) / sizeof(int4) )
#endif #endif
...@@ -658,12 +658,12 @@ typedef struct ...@@ -658,12 +658,12 @@ typedef struct
} INFIX; } INFIX;
#define RESIZEBUF(inf,addsize) \ #define RESIZEBUF(inf,addsize) \
while( ( inf->cur - inf->buf ) + addsize + 1 >= inf->buflen ) \ while( ( (inf)->cur - (inf)->buf ) + (addsize) + 1 >= (inf)->buflen ) \
{ \ { \
int4 len = inf->cur - inf->buf; \ int4 len = (inf)->cur - (inf)->buf; \
inf->buflen *= 2; \ (inf)->buflen *= 2; \
inf->buf = (char*) repalloc( (void*)inf->buf, inf->buflen ); \ (inf)->buf = (char*) repalloc( (void*)(inf)->buf, (inf)->buflen ); \
inf->cur = inf->buf + len; \ (inf)->cur = (inf)->buf + len; \
} }
/* /*
......
...@@ -31,9 +31,9 @@ typedef struct ...@@ -31,9 +31,9 @@ typedef struct
} QUERYTYPE; } QUERYTYPE;
#define HDRSIZEQT ( 2*sizeof(int4) ) #define HDRSIZEQT ( 2*sizeof(int4) )
#define COMPUTESIZE(size,lenofoperand) ( HDRSIZEQT + size * sizeof(ITEM) + lenofoperand ) #define COMPUTESIZE(size, lenofoperand) ( HDRSIZEQT + (size) * sizeof(ITEM) + (lenofoperand) )
#define GETQUERY(x) (ITEM*)( (char*)(x)+HDRSIZEQT ) #define GETQUERY(x) (ITEM*)( (char*)(x)+HDRSIZEQT )
#define GETOPERAND(x) ( (char*)GETQUERY(x) + ((QUERYTYPE*)x)->size * sizeof(ITEM) ) #define GETOPERAND(x) ( (char*)GETQUERY(x) + ((QUERYTYPE*)(x))->size * sizeof(ITEM) )
#define ISOPERATOR(x) ( (x)=='!' || (x)=='&' || (x)=='|' || (x)=='(' || (x)==')' ) #define ISOPERATOR(x) ( (x)=='!' || (x)=='&' || (x)=='|' || (x)=='(' || (x)==')' )
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* Oroginal code by Spencer Garrett <srg@quick.com> * Oroginal code by Spencer Garrett <srg@quick.com>
*/ */
#define _CRC32_(crc, ch) (crc = (crc >> 8) ^ crc32tab[(crc ^ (ch)) & 0xff]) #define _CRC32_(crc, ch) ((crc) = ((crc) >> 8) ^ crc32tab[((crc) ^ (ch)) & 0xff])
/* generated using the AUTODIN II polynomial /* generated using the AUTODIN II polynomial
* x^32 + x^26 + x^23 + x^22 + x^16 + * x^32 + x^26 + x^23 + x^22 + x^16 +
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
#define BITBYTE 8 #define BITBYTE 8
#define SIGLENINT 63 /* >121 => key will toast, so it will not #define SIGLENINT 63 /* >121 => key will toast, so it will not
* work !!! */ * work !!! */
#define SIGLEN ( sizeof(int4)*SIGLENINT ) #define SIGLEN ( sizeof(int4) * SIGLENINT )
#define SIGLENBIT (SIGLEN*BITBYTE) #define SIGLENBIT (SIGLEN * BITBYTE)
typedef char BITVEC[SIGLEN]; typedef char BITVEC[SIGLEN];
typedef char *BITVECP; typedef char *BITVECP;
...@@ -28,7 +28,7 @@ typedef char *BITVECP; ...@@ -28,7 +28,7 @@ typedef char *BITVECP;
} }
#define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) ) #define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) )
#define GETBITBYTE(x,i) ( ((char)(x)) >> i & 0x01 ) #define GETBITBYTE(x,i) ( ((char)(x)) >> (i) & 0x01 )
#define CLRBIT(x,i) GETBYTE(x,i) &= ~( 0x01 << ( (i) % BITBYTE ) ) #define CLRBIT(x,i) GETBYTE(x,i) &= ~( 0x01 << ( (i) % BITBYTE ) )
#define SETBIT(x,i) GETBYTE(x,i) |= ( 0x01 << ( (i) % BITBYTE ) ) #define SETBIT(x,i) GETBYTE(x,i) |= ( 0x01 << ( (i) % BITBYTE ) )
#define GETBIT(x,i) ( (GETBYTE(x,i) >> ( (i) % BITBYTE )) & 0x01 ) #define GETBIT(x,i) ( (GETBYTE(x,i) >> ( (i) % BITBYTE )) & 0x01 )
...@@ -51,15 +51,15 @@ typedef struct ...@@ -51,15 +51,15 @@ typedef struct
#define SIGNKEY 0x02 #define SIGNKEY 0x02
#define ALLISTRUE 0x04 #define ALLISTRUE 0x04
#define ISARRKEY(x) ( ((GISTTYPE*)x)->flag & ARRKEY ) #define ISARRKEY(x) ( ((GISTTYPE*)(x))->flag & ARRKEY )
#define ISSIGNKEY(x) ( ((GISTTYPE*)x)->flag & SIGNKEY ) #define ISSIGNKEY(x) ( ((GISTTYPE*)(x))->flag & SIGNKEY )
#define ISALLTRUE(x) ( ((GISTTYPE*)x)->flag & ALLISTRUE ) #define ISALLTRUE(x) ( ((GISTTYPE*)(x))->flag & ALLISTRUE )
#define GTHDRSIZE ( sizeof(int4)*2 ) #define GTHDRSIZE ( sizeof(int4) * 2 )
#define CALCGTSIZE(flag, len) ( GTHDRSIZE + ( ( (flag) & ARRKEY ) ? ((len)*sizeof(int4)) : (((flag) & ALLISTRUE) ? 0 : SIGLEN) ) ) #define CALCGTSIZE(flag, len) ( GTHDRSIZE + ( ( (flag) & ARRKEY ) ? ((len)*sizeof(int4)) : (((flag) & ALLISTRUE) ? 0 : SIGLEN) ) )
#define GETSIGN(x) ( (BITVECP)( (char*)x+GTHDRSIZE ) ) #define GETSIGN(x) ( (BITVECP)( (char*)(x)+GTHDRSIZE ) )
#define GETARR(x) ( (int4*)( (char*)x+GTHDRSIZE ) ) #define GETARR(x) ( (int4*)( (char*)(x)+GTHDRSIZE ) )
#define ARRNELEM(x) ( ( ((GISTTYPE*)x)->len - GTHDRSIZE )/sizeof(int4) ) #define ARRNELEM(x) ( ( ((GISTTYPE*)(x))->len - GTHDRSIZE )/sizeof(int4) )
#endif #endif
...@@ -680,12 +680,12 @@ typedef struct ...@@ -680,12 +680,12 @@ typedef struct
} INFIX; } INFIX;
#define RESIZEBUF(inf,addsize) \ #define RESIZEBUF(inf,addsize) \
while( ( inf->cur - inf->buf ) + addsize + 1 >= inf->buflen ) \ while( ( (inf)->cur - (inf)->buf ) + (addsize) + 1 >= (inf)->buflen ) \
{ \ { \
int4 len = inf->cur - inf->buf; \ int4 len = (inf)->cur - (inf)->buf; \
inf->buflen *= 2; \ (inf)->buflen *= 2; \
inf->buf = (char*) repalloc( (void*)inf->buf, inf->buflen ); \ (inf)->buf = (char*) repalloc( (void*)(inf)->buf, (inf)->buflen ); \
inf->cur = inf->buf + len; \ (inf)->cur = (inf)->buf + len; \
} }
/* /*
......
...@@ -33,10 +33,10 @@ typedef struct ...@@ -33,10 +33,10 @@ typedef struct
char data[1]; char data[1];
} QUERYTYPE; } QUERYTYPE;
#define HDRSIZEQT ( 2*sizeof(int4) ) #define HDRSIZEQT ( 2 * sizeof(int4) )
#define COMPUTESIZE(size,lenofoperand) ( HDRSIZEQT + size * sizeof(ITEM) + lenofoperand ) #define COMPUTESIZE(size,lenofoperand) ( HDRSIZEQT + (size) * sizeof(ITEM) + (lenofoperand) )
#define GETQUERY(x) (ITEM*)( (char*)(x)+HDRSIZEQT ) #define GETQUERY(x) (ITEM*)( (char*)(x)+HDRSIZEQT )
#define GETOPERAND(x) ( (char*)GETQUERY(x) + ((QUERYTYPE*)x)->size * sizeof(ITEM) ) #define GETOPERAND(x) ( (char*)GETQUERY(x) + ((QUERYTYPE*)(x))->size * sizeof(ITEM) )
#define ISOPERATOR(x) ( (x)=='!' || (x)=='&' || (x)=='|' || (x)=='(' || (x)==')' ) #define ISOPERATOR(x) ( (x)=='!' || (x)=='&' || (x)=='|' || (x)=='(' || (x)==')' )
......
...@@ -24,10 +24,10 @@ typedef struct ...@@ -24,10 +24,10 @@ typedef struct
char data[1]; char data[1];
} tsstat; } tsstat;
#define STATHDRSIZE (sizeof(int4)*4) #define STATHDRSIZE (sizeof(int4) * 4)
#define CALCSTATSIZE(x, lenstr) ( x * sizeof(StatEntry) + STATHDRSIZE + lenstr ) #define CALCSTATSIZE(x, lenstr) ( (x) * sizeof(StatEntry) + STATHDRSIZE + (lenstr) )
#define STATPTR(x) ( (StatEntry*) ( (char*)x + STATHDRSIZE ) ) #define STATPTR(x) ( (StatEntry*) ( (char*)(x) + STATHDRSIZE ) )
#define STATSTRPTR(x) ( (char*)x + STATHDRSIZE + ( sizeof(StatEntry) * ((tsvector*)x)->size ) ) #define STATSTRPTR(x) ( (char*)(x) + STATHDRSIZE + ( sizeof(StatEntry) * ((tsvector*)(x))->size ) )
#define STATSTRSIZE(x) ( ((tsvector*)x)->len - STATHDRSIZE - ( sizeof(StatEntry) * ((tsvector*)x)->size ) ) #define STATSTRSIZE(x) ( ((tsvector*)(x))->len - STATHDRSIZE - ( sizeof(StatEntry) * ((tsvector*)(x))->size ) )
#endif #endif
...@@ -54,11 +54,11 @@ typedef struct ...@@ -54,11 +54,11 @@ typedef struct
char data[1]; char data[1];
} tsvector; } tsvector;
#define DATAHDRSIZE (sizeof(int4)*2) #define DATAHDRSIZE (sizeof(int4) * 2)
#define CALCDATASIZE(x, lenstr) ( x * sizeof(WordEntry) + DATAHDRSIZE + lenstr ) #define CALCDATASIZE(x, lenstr) ( (x) * sizeof(WordEntry) + DATAHDRSIZE + (lenstr) )
#define ARRPTR(x) ( (WordEntry*) ( (char*)x + DATAHDRSIZE ) ) #define ARRPTR(x) ( (WordEntry*) ( (char*)(x) + DATAHDRSIZE ) )
#define STRPTR(x) ( (char*)x + DATAHDRSIZE + ( sizeof(WordEntry) * ((tsvector*)x)->size ) ) #define STRPTR(x) ( (char*)(x) + DATAHDRSIZE + ( sizeof(WordEntry) * ((tsvector*)(x))->size ) )
#define STRSIZE(x) ( ((tsvector*)x)->len - DATAHDRSIZE - ( sizeof(WordEntry) * ((tsvector*)x)->size ) ) #define STRSIZE(x) ( ((tsvector*)(x))->len - DATAHDRSIZE - ( sizeof(WordEntry) * ((tsvector*)(x))->size ) )
#define _POSDATAPTR(x,e) (STRPTR(x)+((WordEntry*)(e))->pos+SHORTALIGN(((WordEntry*)(e))->len)) #define _POSDATAPTR(x,e) (STRPTR(x)+((WordEntry*)(e))->pos+SHORTALIGN(((WordEntry*)(e))->len))
#define POSDATALEN(x,e) ( ( ((WordEntry*)(e))->haspos ) ? (*(uint16*)_POSDATAPTR(x,e)) : 0 ) #define POSDATALEN(x,e) ( ( ((WordEntry*)(e))->haspos ) ? (*(uint16*)_POSDATAPTR(x,e)) : 0 )
#define POSDATAPTR(x,e) ( (WordEntryPos*)( _POSDATAPTR(x,e)+sizeof(uint16) ) ) #define POSDATAPTR(x,e) ( (WordEntryPos*)( _POSDATAPTR(x,e)+sizeof(uint16) ) )
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/hash/hashfunc.c,v 1.43 2005/03/29 00:16:50 tgl Exp $ * $PostgreSQL: pgsql/src/backend/access/hash/hashfunc.c,v 1.44 2005/05/25 21:40:40 momjian Exp $
* *
* NOTES * NOTES
* These functions are stored in pg_amproc. For each operator class * These functions are stored in pg_amproc. For each operator class
...@@ -192,15 +192,15 @@ hashvarlena(PG_FUNCTION_ARGS) ...@@ -192,15 +192,15 @@ hashvarlena(PG_FUNCTION_ARGS)
*/ */
#define mix(a,b,c) \ #define mix(a,b,c) \
{ \ { \
a -= b; a -= c; a ^= (c>>13); \ a -= b; a -= c; a ^= ((c)>>13); \
b -= c; b -= a; b ^= (a<<8); \ b -= c; b -= a; b ^= ((a)<<8); \
c -= a; c -= b; c ^= (b>>13); \ c -= a; c -= b; c ^= ((b)>>13); \
a -= b; a -= c; a ^= (c>>12); \ a -= b; a -= c; a ^= ((c)>>12); \
b -= c; b -= a; b ^= (a<<16); \ b -= c; b -= a; b ^= ((a)<<16); \
c -= a; c -= b; c ^= (b>>5); \ c -= a; c -= b; c ^= ((b)>>5); \
a -= b; a -= c; a ^= (c>>3); \ a -= b; a -= c; a ^= ((c)>>3); \
b -= c; b -= a; b ^= (a<<10); \ b -= c; b -= a; b ^= ((a)<<10); \
c -= a; c -= b; c ^= (b>>15); \ c -= a; c -= b; c ^= ((b)>>15); \
} }
/* /*
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* $PostgreSQL: pgsql/src/backend/regex/regcomp.c,v 1.42 2004/11/24 22:56:54 tgl Exp $ * $PostgreSQL: pgsql/src/backend/regex/regcomp.c,v 1.43 2005/05/25 21:40:40 momjian Exp $
* *
*/ */
...@@ -232,7 +232,7 @@ struct vars ...@@ -232,7 +232,7 @@ struct vars
struct cvec *cv; /* interface cvec */ struct cvec *cv; /* interface cvec */
struct cvec *cv2; /* utility cvec */ struct cvec *cv2; /* utility cvec */
struct cvec *mcces; /* collating-element information */ struct cvec *mcces; /* collating-element information */
#define ISCELEADER(v,c) (v->mcces != NULL && haschr(v->mcces, (c))) #define ISCELEADER(v,c) ((v)->mcces != NULL && haschr((v)->mcces, (c)))
struct state *mccepbegin; /* in nfa, start of MCCE prototypes */ struct state *mccepbegin; /* in nfa, start of MCCE prototypes */
struct state *mccepend; /* in nfa, end of MCCE prototypes */ struct state *mccepend; /* in nfa, end of MCCE prototypes */
struct subre *lacons; /* lookahead-constraint vector */ struct subre *lacons; /* lookahead-constraint vector */
......
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
* formatting.c * formatting.c
* *
* $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.86 2005/03/26 00:41:31 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.87 2005/05/25 21:40:40 momjian Exp $
* *
* *
* Portions Copyright (c) 1999-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1999-2005, PostgreSQL Global Development Group
...@@ -171,7 +171,7 @@ static char *months_full[] = { ...@@ -171,7 +171,7 @@ static char *months_full[] = {
* AC / DC * AC / DC
* ---------- * ----------
*/ */
#define YEAR_ABS(_y) (_y <= 0 ? -(_y -1) : _y) #define YEAR_ABS(_y) ((_y) <= 0 ? -((_y) - 1) : _y)
#define BC_STR_ORIG " BC" #define BC_STR_ORIG " BC"
#define A_D_STR "A.D." #define A_D_STR "A.D."
...@@ -457,13 +457,13 @@ static int dch_date(int arg, char *inout, int suf, int flag, FormatNode *node, v ...@@ -457,13 +457,13 @@ static int dch_date(int arg, char *inout, int suf, int flag, FormatNode *node, v
* Suffix tests * Suffix tests
* ---------- * ----------
*/ */
#define S_THth(_s) (((_s & DCH_S_TH) || (_s & DCH_S_th)) ? 1 : 0) #define S_THth(_s) ((((_s) & DCH_S_TH) || ((_s) & DCH_S_th)) ? 1 : 0)
#define S_TH(_s) ((_s & DCH_S_TH) ? 1 : 0) #define S_TH(_s) (((_s) & DCH_S_TH) ? 1 : 0)
#define S_th(_s) ((_s & DCH_S_th) ? 1 : 0) #define S_th(_s) (((_s) & DCH_S_th) ? 1 : 0)
#define S_TH_TYPE(_s) ((_s & DCH_S_TH) ? TH_UPPER : TH_LOWER) #define S_TH_TYPE(_s) (((_s) & DCH_S_TH) ? TH_UPPER : TH_LOWER)
#define S_FM(_s) ((_s & DCH_S_FM) ? 1 : 0) #define S_FM(_s) (((_s) & DCH_S_FM) ? 1 : 0)
#define S_SP(_s) ((_s & DCH_S_SP) ? 1 : 0) #define S_SP(_s) (((_s) & DCH_S_SP) ? 1 : 0)
/* ---------- /* ----------
* Suffixes definition for DATE-TIME TO/FROM CHAR * Suffixes definition for DATE-TIME TO/FROM CHAR
......
/* ---------- /* ----------
* pg_lzcompress.c - * pg_lzcompress.c -
* *
* $PostgreSQL: pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.18 2003/11/29 19:51:59 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.19 2005/05/25 21:40:41 momjian Exp $
* *
* This is an implementation of LZ compression for PostgreSQL. * This is an implementation of LZ compression for PostgreSQL.
* It uses a simple history table and generates 2-3 byte tags * It uses a simple history table and generates 2-3 byte tags
...@@ -328,8 +328,8 @@ do { \ ...@@ -328,8 +328,8 @@ do { \
do { \ do { \
if ((__ctrl & 0xff) == 0) \ if ((__ctrl & 0xff) == 0) \
{ \ { \
*__ctrlp = __ctrlb; \ *(__ctrlp) = __ctrlb; \
__ctrlp = __buf++; \ __ctrlp = (__buf)++; \
__ctrlb = 0; \ __ctrlb = 0; \
__ctrl = 1; \ __ctrl = 1; \
} \ } \
...@@ -346,7 +346,7 @@ do { \ ...@@ -346,7 +346,7 @@ do { \
#define pglz_out_literal(_ctrlp,_ctrlb,_ctrl,_buf,_byte) \ #define pglz_out_literal(_ctrlp,_ctrlb,_ctrl,_buf,_byte) \
do { \ do { \
pglz_out_ctrl(_ctrlp,_ctrlb,_ctrl,_buf); \ pglz_out_ctrl(_ctrlp,_ctrlb,_ctrl,_buf); \
*_buf++ = (unsigned char)(_byte); \ *(_buf)++ = (unsigned char)(_byte); \
_ctrl <<= 1; \ _ctrl <<= 1; \
} while (0) } while (0)
...@@ -366,14 +366,14 @@ do { \ ...@@ -366,14 +366,14 @@ do { \
_ctrl <<= 1; \ _ctrl <<= 1; \
if (_len > 17) \ if (_len > 17) \
{ \ { \
_buf[0] = (unsigned char)((((_off) & 0xf00) >> 4) | 0x0f); \ (_buf)[0] = (unsigned char)((((_off) & 0xf00) >> 4) | 0x0f); \
_buf[1] = (unsigned char)((_off & 0xff)); \ (_buf)[1] = (unsigned char)(((_off) & 0xff)); \
_buf[2] = (unsigned char)((_len) - 18); \ (_buf)[2] = (unsigned char)((_len) - 18); \
_buf += 3; \ (_buf) += 3; \
} else { \ } else { \
_buf[0] = (unsigned char)((((_off) & 0xf00) >> 4) | (_len - 3)); \ (_buf)[0] = (unsigned char)((((_off) & 0xf00) >> 4) | ((_len) - 3)); \
_buf[1] = (unsigned char)((_off) & 0xff); \ (_buf)[1] = (unsigned char)((_off) & 0xff); \
_buf += 2; \ (_buf) += 2; \
} \ } \
} while (0) } while (0)
......
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.48 2005/05/06 17:24:54 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.49 2005/05/25 21:40:41 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1564,7 +1564,7 @@ tuplesort_restorepos(Tuplesortstate *state) ...@@ -1564,7 +1564,7 @@ tuplesort_restorepos(Tuplesortstate *state)
*/ */
#define HEAPCOMPARE(tup1,index1,tup2,index2) \ #define HEAPCOMPARE(tup1,index1,tup2,index2) \
(checkIndex && (index1 != index2) ? index1 - index2 : \ (checkIndex && (index1 != index2) ? (index1) - (index2) : \
COMPARETUP(state, tup1, tup2)) COMPARETUP(state, tup1, tup2))
/* /*
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.63 2005/01/25 22:44:31 tgl Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.64 2005/05/25 21:40:41 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -43,11 +43,11 @@ ...@@ -43,11 +43,11 @@
#ifdef HAVE_LIBZ #ifdef HAVE_LIBZ
#include <zlib.h> #include <zlib.h>
#define GZCLOSE(fh) gzclose(fh) #define GZCLOSE(fh) gzclose(fh)
#define GZWRITE(p, s, n, fh) gzwrite(fh, p, n * s) #define GZWRITE(p, s, n, fh) gzwrite(fh, p, (n) * (s))
#define GZREAD(p, s, n, fh) gzread(fh, p, n * s) #define GZREAD(p, s, n, fh) gzread(fh, p, (n) * (s))
#else #else
#define GZCLOSE(fh) fclose(fh) #define GZCLOSE(fh) fclose(fh)
#define GZWRITE(p, s, n, fh) (fwrite(p, s, n, fh) * s) #define GZWRITE(p, s, n, fh) (fwrite(p, s, n, fh) * (s))
#define GZREAD(p, s, n, fh) fread(p, s, n, fh) #define GZREAD(p, s, n, fh) fread(p, s, n, fh)
#define Z_DEFAULT_COMPRESSION -1 #define Z_DEFAULT_COMPRESSION -1
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/access/attnum.h,v 1.20 2004/12/31 22:03:21 pgsql Exp $ * $PostgreSQL: pgsql/src/include/access/attnum.h,v 1.21 2005/05/25 21:40:42 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -58,6 +58,6 @@ typedef int16 AttrNumber; ...@@ -58,6 +58,6 @@ typedef int16 AttrNumber;
* Returns the attribute number for an attribute offset. * Returns the attribute number for an attribute offset.
*/ */
#define AttrOffsetGetAttrNumber(attributeOffset) \ #define AttrOffsetGetAttrNumber(attributeOffset) \
((AttrNumber) (1 + attributeOffset)) ((AttrNumber) (1 + (attributeOffset)))
#endif /* ATTNUM_H */ #endif /* ATTNUM_H */
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/c.h,v 1.183 2005/05/11 01:26:02 neilc Exp $ * $PostgreSQL: pgsql/src/include/c.h,v 1.184 2005/05/25 21:40:41 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -535,7 +535,7 @@ typedef NameData *Name; ...@@ -535,7 +535,7 @@ typedef NameData *Name;
* endof * endof
* Address of the element one past the last in an array. * Address of the element one past the last in an array.
*/ */
#define endof(array) (&array[lengthof(array)]) #define endof(array) (&(array)[lengthof(array)])
/* ---------------- /* ----------------
* Alignment macros: align a length or address appropriately for a given type. * Alignment macros: align a length or address appropriately for a given type.
...@@ -549,7 +549,7 @@ typedef NameData *Name; ...@@ -549,7 +549,7 @@ typedef NameData *Name;
*/ */
#define TYPEALIGN(ALIGNVAL,LEN) \ #define TYPEALIGN(ALIGNVAL,LEN) \
(((long) (LEN) + (ALIGNVAL-1)) & ~((long) (ALIGNVAL-1))) (((long) (LEN) + ((ALIGNVAL) - 1)) & ~((long) ((ALIGNVAL) - 1)))
#define SHORTALIGN(LEN) TYPEALIGN(ALIGNOF_SHORT, (LEN)) #define SHORTALIGN(LEN) TYPEALIGN(ALIGNOF_SHORT, (LEN))
#define INTALIGN(LEN) TYPEALIGN(ALIGNOF_INT, (LEN)) #define INTALIGN(LEN) TYPEALIGN(ALIGNOF_INT, (LEN))
......
...@@ -81,18 +81,18 @@ typedef FormData_pg_trigger *Form_pg_trigger; ...@@ -81,18 +81,18 @@ typedef FormData_pg_trigger *Form_pg_trigger;
#define TRIGGER_TYPE_DELETE (1 << 3) #define TRIGGER_TYPE_DELETE (1 << 3)
#define TRIGGER_TYPE_UPDATE (1 << 4) #define TRIGGER_TYPE_UPDATE (1 << 4)
#define TRIGGER_CLEAR_TYPE(type) (type = 0) #define TRIGGER_CLEAR_TYPE(type) ((type) = 0)
#define TRIGGER_SETT_ROW(type) (type |= TRIGGER_TYPE_ROW) #define TRIGGER_SETT_ROW(type) ((type) |= TRIGGER_TYPE_ROW)
#define TRIGGER_SETT_BEFORE(type) (type |= TRIGGER_TYPE_BEFORE) #define TRIGGER_SETT_BEFORE(type) ((type) |= TRIGGER_TYPE_BEFORE)
#define TRIGGER_SETT_INSERT(type) (type |= TRIGGER_TYPE_INSERT) #define TRIGGER_SETT_INSERT(type) ((type) |= TRIGGER_TYPE_INSERT)
#define TRIGGER_SETT_DELETE(type) (type |= TRIGGER_TYPE_DELETE) #define TRIGGER_SETT_DELETE(type) ((type) |= TRIGGER_TYPE_DELETE)
#define TRIGGER_SETT_UPDATE(type) (type |= TRIGGER_TYPE_UPDATE) #define TRIGGER_SETT_UPDATE(type) ((type) |= TRIGGER_TYPE_UPDATE)
#define TRIGGER_FOR_ROW(type) (type & TRIGGER_TYPE_ROW) #define TRIGGER_FOR_ROW(type) ((type) & TRIGGER_TYPE_ROW)
#define TRIGGER_FOR_BEFORE(type) (type & TRIGGER_TYPE_BEFORE) #define TRIGGER_FOR_BEFORE(type) ((type) & TRIGGER_TYPE_BEFORE)
#define TRIGGER_FOR_INSERT(type) (type & TRIGGER_TYPE_INSERT) #define TRIGGER_FOR_INSERT(type) ((type) & TRIGGER_TYPE_INSERT)
#define TRIGGER_FOR_DELETE(type) (type & TRIGGER_TYPE_DELETE) #define TRIGGER_FOR_DELETE(type) ((type) & TRIGGER_TYPE_DELETE)
#define TRIGGER_FOR_UPDATE(type) (type & TRIGGER_TYPE_UPDATE) #define TRIGGER_FOR_UPDATE(type) ((type) & TRIGGER_TYPE_UPDATE)
#endif /* PG_TRIGGER_H */ #endif /* PG_TRIGGER_H */
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/libpq/crypt.h,v 1.30 2004/12/31 22:03:32 pgsql Exp $ * $PostgreSQL: pgsql/src/include/libpq/crypt.h,v 1.31 2005/05/25 21:40:42 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#define MD5_PASSWD_LEN 35 #define MD5_PASSWD_LEN 35
#define isMD5(passwd) (strncmp((passwd),"md5",3) == 0 && \ #define isMD5(passwd) (strncmp(passwd, "md5", 3) == 0 && \
strlen(passwd) == MD5_PASSWD_LEN) strlen(passwd) == MD5_PASSWD_LEN)
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/port.h,v 1.74 2005/03/25 00:34:24 tgl Exp $ * $PostgreSQL: pgsql/src/include/port.h,v 1.75 2005/05/25 21:40:41 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -255,8 +255,8 @@ extern off_t ftello(FILE *stream); ...@@ -255,8 +255,8 @@ extern off_t ftello(FILE *stream);
#endif #endif
#ifndef HAVE_FSEEKO #ifndef HAVE_FSEEKO
#define fseeko(a, b, c) fseek((a), (b), (c)) #define fseeko(a, b, c) fseek(a, b, c)
#define ftello(a) ftell((a)) #define ftello(a) ftell(a)
#endif #endif
#ifndef HAVE_GETOPT #ifndef HAVE_GETOPT
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* $PostgreSQL: pgsql/src/include/regex/regguts.h,v 1.3 2003/11/29 22:41:10 pgsql Exp $ * $PostgreSQL: pgsql/src/include/regex/regguts.h,v 1.4 2005/05/25 21:40:42 momjian Exp $
*/ */
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
/* function-pointer declarator */ /* function-pointer declarator */
#ifndef FUNCPTR #ifndef FUNCPTR
#define FUNCPTR(name, args) (*name) args #define FUNCPTR(name, args) (*(name)) args
#endif #endif
/* memory allocation */ /* memory allocation */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/storage/itempos.h,v 1.20 2004/12/31 22:03:42 pgsql Exp $ * $PostgreSQL: pgsql/src/include/storage/itempos.h,v 1.21 2005/05/25 21:40:42 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -32,7 +32,7 @@ typedef ItemSubpositionData *ItemSubposition; ...@@ -32,7 +32,7 @@ typedef ItemSubpositionData *ItemSubposition;
* struct objpos *OBJP; * struct objpos *OBJP;
* unsigned LEN; * unsigned LEN;
*/ */
#define PNOBREAK(OBJP, LEN) ((OBJP)->op_len >= LEN) #define PNOBREAK(OBJP, LEN) ((OBJP)->op_len >= (LEN))
/* /*
* PSKIP(OBJP, LEN) * PSKIP(OBJP, LEN)
......
/* ---------- /* ----------
* pg_lzcompress.h - * pg_lzcompress.h -
* *
* $PostgreSQL: pgsql/src/include/utils/pg_lzcompress.h,v 1.10 2003/11/29 19:52:08 pgsql Exp $ * $PostgreSQL: pgsql/src/include/utils/pg_lzcompress.h,v 1.11 2005/05/25 21:40:42 momjian Exp $
* *
* Definitions for the builtin LZ compressor * Definitions for the builtin LZ compressor
* ---------- * ----------
...@@ -46,7 +46,7 @@ typedef struct PGLZ_Header ...@@ -46,7 +46,7 @@ typedef struct PGLZ_Header
* in the entry. * in the entry.
* ---------- * ----------
*/ */
#define PGLZ_RAW_SIZE(_lzdata) (_lzdata->rawsize) #define PGLZ_RAW_SIZE(_lzdata) ((_lzdata)->rawsize)
/* ---------- /* ----------
* PGLZ_IS_COMPRESSED - * PGLZ_IS_COMPRESSED -
...@@ -55,8 +55,8 @@ typedef struct PGLZ_Header ...@@ -55,8 +55,8 @@ typedef struct PGLZ_Header
* uncompressed data. * uncompressed data.
* ---------- * ----------
*/ */
#define PGLZ_IS_COMPRESSED(_lzdata) (_lzdata->varsize != \ #define PGLZ_IS_COMPRESSED(_lzdata) ((_lzdata)->varsize != \
_lzdata->rawsize + \ e (_lzdata)->rawsize + e \
sizeof(PGLZ_Header)) sizeof(PGLZ_Header))
/* ---------- /* ----------
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/utils/timestamp.h,v 1.42 2005/05/23 21:54:02 momjian Exp $ * $PostgreSQL: pgsql/src/include/utils/timestamp.h,v 1.43 2005/05/25 21:40:42 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -123,10 +123,10 @@ typedef struct ...@@ -123,10 +123,10 @@ typedef struct
#endif /* HAVE_INT64_TIMESTAMP */ #endif /* HAVE_INT64_TIMESTAMP */
#define TIMESTAMP_NOBEGIN(j) do {j = DT_NOBEGIN;} while (0) #define TIMESTAMP_NOBEGIN(j) do {(j) = DT_NOBEGIN;} while (0)
#define TIMESTAMP_IS_NOBEGIN(j) ((j) == DT_NOBEGIN) #define TIMESTAMP_IS_NOBEGIN(j) ((j) == DT_NOBEGIN)
#define TIMESTAMP_NOEND(j) do {j = DT_NOEND;} while (0) #define TIMESTAMP_NOEND(j) do {(j) = DT_NOEND;} while (0)
#define TIMESTAMP_IS_NOEND(j) ((j) == DT_NOEND) #define TIMESTAMP_IS_NOEND(j) ((j) == DT_NOEND)
#define TIMESTAMP_NOT_FINITE(j) (TIMESTAMP_IS_NOBEGIN(j) || TIMESTAMP_IS_NOEND(j)) #define TIMESTAMP_NOT_FINITE(j) (TIMESTAMP_IS_NOBEGIN(j) || TIMESTAMP_IS_NOEND(j))
......
...@@ -193,8 +193,8 @@ typedef struct ...@@ -193,8 +193,8 @@ typedef struct
*/ */
#define FMODULO(t,q,u) \ #define FMODULO(t,q,u) \
do { \ do { \
q = ((t < 0) ? ceil(t / u): floor(t / u)); \ (q) = (((t) < 0) ? ceil((t) / (u)): floor((t) / (u))); \
if (q != 0) t -= rint(q * u); \ if ((q) != 0) (t) -= rint((q) * (u)); \
} while(0) } while(0)
/* TMODULO() /* TMODULO()
...@@ -205,14 +205,14 @@ do { \ ...@@ -205,14 +205,14 @@ do { \
#ifdef HAVE_INT64_TIMESTAMP #ifdef HAVE_INT64_TIMESTAMP
#define TMODULO(t,q,u) \ #define TMODULO(t,q,u) \
do { \ do { \
q = (t / u); \ (q) = ((t) / (u)); \
if (q != 0) t -= (q * u); \ if ((q) != 0) (t) -= ((q) * (u)); \
} while(0) } while(0)
#else #else
#define TMODULO(t,q,u) \ #define TMODULO(t,q,u) \
do { \ do { \
q = ((t < 0) ? ceil(t / u): floor(t / u)); \ (q) = (((t) < 0) ? ceil((t) / (u)): floor((t) / (u))); \
if (q != 0) t -= rint(q * u); \ if ((q) != 0) (t) -= rint((q) * (u)); \
} while(0) } while(0)
#endif #endif
...@@ -277,8 +277,8 @@ do { \ ...@@ -277,8 +277,8 @@ do { \
#endif #endif
#endif /* HAVE_INT64_TIMESTAMP */ #endif /* HAVE_INT64_TIMESTAMP */
#define TIMESTAMP_NOBEGIN(j) do {j = DT_NOBEGIN;} while (0) #define TIMESTAMP_NOBEGIN(j) do {(j) = DT_NOBEGIN;} while (0)
#define TIMESTAMP_NOEND(j) do {j = DT_NOEND;} while (0) #define TIMESTAMP_NOEND(j) do {(j) = DT_NOEND;} while (0)
#define TIMESTAMP_IS_NOBEGIN(j) ((j) == DT_NOBEGIN) #define TIMESTAMP_IS_NOBEGIN(j) ((j) == DT_NOBEGIN)
#define TIMESTAMP_IS_NOEND(j) ((j) == DT_NOEND) #define TIMESTAMP_IS_NOEND(j) ((j) == DT_NOEND)
#define TIMESTAMP_NOT_FINITE(j) (TIMESTAMP_IS_NOBEGIN(j) || TIMESTAMP_IS_NOEND(j)) #define TIMESTAMP_NOT_FINITE(j) (TIMESTAMP_IS_NOBEGIN(j) || TIMESTAMP_IS_NOEND(j))
......
...@@ -740,7 +740,7 @@ int num_iter; ...@@ -740,7 +740,7 @@ int num_iter;
{ {
#define SPTAB(t, i) \ #define SPTAB(t, i) \
(*(int32_t *)((unsigned char *)t + i*(sizeof(int32_t)/4))) (*(int32_t *)((unsigned char *)(t) + (i)*(sizeof(int32_t)/4)))
#if defined(gould) #if defined(gould)
/* use this if B.b[i] is evaluated just once ... */ /* use this if B.b[i] is evaluated just once ... */
#define DOXOR(x,y,i) x^=SPTAB(SPE[0][i],B.b[i]); y^=SPTAB(SPE[1][i],B.b[i]); #define DOXOR(x,y,i) x^=SPTAB(SPE[0][i],B.b[i]); y^=SPTAB(SPE[1][i],B.b[i]);
...@@ -755,9 +755,9 @@ int num_iter; ...@@ -755,9 +755,9 @@ int num_iter;
#endif #endif
#define CRUNCH(p0, p1, q0, q1) \ #define CRUNCH(p0, p1, q0, q1) \
k = (q0 ^ q1) & SALT; \ k = ((q0) ^ (q1)) & SALT; \
B.b32.i0 = k ^ q0 ^ kp->b32.i0; \ B.b32.i0 = k ^ (q0) ^ kp->b32.i0; \
B.b32.i1 = k ^ q1 ^ kp->b32.i1; \ B.b32.i1 = k ^ (q1) ^ kp->b32.i1; \
kp = (C_block *)((char *)kp+ks_inc); \ kp = (C_block *)((char *)kp+ks_inc); \
\ \
DOXOR(p0, p1, 0); \ DOXOR(p0, p1, 0); \
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Add do ... while() macro fix * Add do ... while() macro fix
* Remove __inline, _DIAGASSERTs, __P * Remove __inline, _DIAGASSERTs, __P
* *
* $PostgreSQL: pgsql/src/port/qsort.c,v 1.5 2004/10/05 00:12:49 neilc Exp $ * $PostgreSQL: pgsql/src/port/qsort.c,v 1.6 2005/05/25 21:40:43 momjian Exp $
*/ */
/* $NetBSD: qsort.c,v 1.13 2003/08/07 16:43:42 agc Exp $ */ /* $NetBSD: qsort.c,v 1.13 2003/08/07 16:43:42 agc Exp $ */
...@@ -63,8 +63,8 @@ do { \ ...@@ -63,8 +63,8 @@ do { \
} while (--i > 0); \ } while (--i > 0); \
} while (0) } while (0)
#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \ #define SWAPINIT(a, es) swaptype = ((char *)(a) - (char *)0) % sizeof(long) || \
es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1; (es) % sizeof(long) ? 2 : (es) == sizeof(long)? 0 : 1;
static void static void
swapfunc(a, b, n, swaptype) swapfunc(a, b, n, swaptype)
......
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