1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-02 09:02:37 +03:00

Replace int2/int4 in C code with int16/int32

The latter was already the dominant use, and it's preferable because
in C the convention is that intXX means XX bits.  Therefore, allowing
mixed use of int2, int4, int8, int16, int32 is obviously confusing.

Remove the typedefs for int2 and int4 for now.  They don't seem to be
widely used outside of the PostgreSQL source tree, and the few uses
can probably be cleaned up by the time this ships.
This commit is contained in:
Peter Eisentraut
2012-06-25 01:51:46 +03:00
parent 7eb8c78514
commit b8b2e3b2de
75 changed files with 411 additions and 404 deletions

View File

@ -22,7 +22,7 @@
#define SIGLENINT 31 /* >121 => key will toast, so it will not work
* !!! */
#define SIGLEN ( sizeof(int4) * SIGLENINT )
#define SIGLEN ( sizeof(int32) * SIGLENINT )
#define SIGLENBIT (SIGLEN * BITS_PER_BYTE)
typedef char BITVEC[SIGLEN];
@ -49,7 +49,7 @@ typedef char *BITVECP;
typedef struct
{
int32 vl_len_; /* varlena header (do not touch directly!) */
int4 flag;
int32 flag;
char data[1];
} SignTSVector;
@ -61,12 +61,12 @@ typedef struct
#define ISSIGNKEY(x) ( ((SignTSVector*)(x))->flag & SIGNKEY )
#define ISALLTRUE(x) ( ((SignTSVector*)(x))->flag & ALLISTRUE )
#define GTHDRSIZE ( VARHDRSZ + sizeof(int4) )
#define CALCGTSIZE(flag, len) ( GTHDRSIZE + ( ( (flag) & ARRKEY ) ? ((len)*sizeof(int4)) : (((flag) & ALLISTRUE) ? 0 : SIGLEN) ) )
#define GTHDRSIZE ( VARHDRSZ + sizeof(int32) )
#define CALCGTSIZE(flag, len) ( GTHDRSIZE + ( ( (flag) & ARRKEY ) ? ((len)*sizeof(int32)) : (((flag) & ALLISTRUE) ? 0 : SIGLEN) ) )
#define GETSIGN(x) ( (BITVECP)( (char*)(x)+GTHDRSIZE ) )
#define GETARR(x) ( (int4*)( (char*)(x)+GTHDRSIZE ) )
#define ARRNELEM(x) ( ( VARSIZE(x) - GTHDRSIZE )/sizeof(int4) )
#define GETARR(x) ( (int32*)( (char*)(x)+GTHDRSIZE ) )
#define ARRNELEM(x) ( ( VARSIZE(x) - GTHDRSIZE )/sizeof(int32) )
/* Number of one-bits in an unsigned byte */
static const uint8 number_of_ones[256] = {
@ -88,7 +88,7 @@ static const uint8 number_of_ones[256] = {
4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
};
static int4 sizebitvec(BITVECP sign);
static int32 sizebitvec(BITVECP sign);
Datum
gtsvectorin(PG_FUNCTION_ARGS)
@ -131,8 +131,8 @@ gtsvectorout(PG_FUNCTION_ARGS)
static int
compareint(const void *va, const void *vb)
{
int4 a = *((const int4 *) va);
int4 b = *((const int4 *) vb);
int32 a = *((const int32 *) va);
int32 b = *((const int32 *) vb);
if (a == b)
return 0;
@ -140,13 +140,13 @@ compareint(const void *va, const void *vb)
}
/*
* Removes duplicates from an array of int4. 'l' is
* Removes duplicates from an array of int32. 'l' is
* size of the input array. Returns the new size of the array.
*/
static int
uniqueint(int4 *a, int4 l)
uniqueint(int32 *a, int32 l)
{
int4 *ptr,
int32 *ptr,
*res;
if (l <= 1)
@ -154,7 +154,7 @@ uniqueint(int4 *a, int4 l)
ptr = res = a;
qsort((void *) a, l, sizeof(int4), compareint);
qsort((void *) a, l, sizeof(int32), compareint);
while (ptr - a < l)
if (*ptr != *res)
@ -167,9 +167,9 @@ uniqueint(int4 *a, int4 l)
static void
makesign(BITVECP sign, SignTSVector *a)
{
int4 k,
int32 k,
len = ARRNELEM(a);
int4 *ptr = GETARR(a);
int32 *ptr = GETARR(a);
MemSet((void *) sign, 0, sizeof(BITVEC));
for (k = 0; k < len; k++)
@ -186,8 +186,8 @@ gtsvector_compress(PG_FUNCTION_ARGS)
{ /* tsvector */
SignTSVector *res;
TSVector val = DatumGetTSVector(entry->key);
int4 len;
int4 *arr;
int32 len;
int32 *arr;
WordEntry *ptr = ARRPTR(val);
char *words = STRPTR(val);
@ -205,7 +205,7 @@ gtsvector_compress(PG_FUNCTION_ARGS)
COMP_CRC32(c, words + ptr->pos, ptr->len);
FIN_CRC32(c);
*arr = *(int4 *) &c;
*arr = *(int32 *) &c;
arr++;
ptr++;
}
@ -243,7 +243,7 @@ gtsvector_compress(PG_FUNCTION_ARGS)
else if (ISSIGNKEY(DatumGetPointer(entry->key)) &&
!ISALLTRUE(DatumGetPointer(entry->key)))
{
int4 i,
int32 i,
len;
SignTSVector *res;
BITVECP sign = GETSIGN(DatumGetPointer(entry->key));
@ -289,8 +289,8 @@ gtsvector_decompress(PG_FUNCTION_ARGS)
typedef struct
{
int4 *arrb;
int4 *arre;
int32 *arrb;
int32 *arre;
} CHKVAL;
/*
@ -299,9 +299,9 @@ typedef struct
static bool
checkcondition_arr(void *checkval, QueryOperand *val)
{
int4 *StopLow = ((CHKVAL *) checkval)->arrb;
int4 *StopHigh = ((CHKVAL *) checkval)->arre;
int4 *StopMiddle;
int32 *StopLow = ((CHKVAL *) checkval)->arrb;
int32 *StopHigh = ((CHKVAL *) checkval)->arre;
int32 *StopMiddle;
/* Loop invariant: StopLow <= val < StopHigh */
@ -378,10 +378,10 @@ gtsvector_consistent(PG_FUNCTION_ARGS)
}
}
static int4
static int32
unionkey(BITVECP sbase, SignTSVector *add)
{
int4 i;
int32 i;
if (ISSIGNKEY(add))
{
@ -395,7 +395,7 @@ unionkey(BITVECP sbase, SignTSVector *add)
}
else
{
int4 *ptr = GETARR(add);
int32 *ptr = GETARR(add);
for (i = 0; i < ARRNELEM(add); i++)
HASH(sbase, ptr[i]);
@ -410,9 +410,9 @@ gtsvector_union(PG_FUNCTION_ARGS)
GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
int *size = (int *) PG_GETARG_POINTER(1);
BITVEC base;
int4 i,
int32 i,
len;
int4 flag = 0;
int32 flag = 0;
SignTSVector *result;
MemSet((void *) base, 0, sizeof(BITVEC));
@ -454,7 +454,7 @@ gtsvector_same(PG_FUNCTION_ARGS)
*result = false;
else
{
int4 i;
int32 i;
BITVECP sa = GETSIGN(a),
sb = GETSIGN(b);
@ -471,16 +471,16 @@ gtsvector_same(PG_FUNCTION_ARGS)
}
else
{ /* a and b ISARRKEY */
int4 lena = ARRNELEM(a),
int32 lena = ARRNELEM(a),
lenb = ARRNELEM(b);
if (lena != lenb)
*result = false;
else
{
int4 *ptra = GETARR(a),
int32 *ptra = GETARR(a),
*ptrb = GETARR(b);
int4 i;
int32 i;
*result = true;
for (i = 0; i < lena; i++)
@ -495,10 +495,10 @@ gtsvector_same(PG_FUNCTION_ARGS)
PG_RETURN_POINTER(result);
}
static int4
static int32
sizebitvec(BITVECP sign)
{
int4 size = 0,
int32 size = 0,
i;
LOOPBYTE
@ -587,7 +587,7 @@ fillcache(CACHESIGN *item, SignTSVector *key)
typedef struct
{
OffsetNumber pos;
int4 cost;
int32 cost;
} SPLITCOST;
static int
@ -630,11 +630,11 @@ gtsvector_picksplit(PG_FUNCTION_ARGS)
*datum_r;
BITVECP union_l,
union_r;
int4 size_alpha,
int32 size_alpha,
size_beta;
int4 size_waste,
int32 size_waste,
waste = -1;
int4 nbytes;
int32 nbytes;
OffsetNumber seed_1 = 0,
seed_2 = 0;
OffsetNumber *left,