Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b8b2e3b

Browse files
committed
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.
1 parent 7eb8c78 commit b8b2e3b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+411
-404
lines changed

contrib/btree_gist/btree_int2.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ gbt_int2key_cmp(const void *a, const void *b)
7777
static float8
7878
gbt_int2_dist(const void *a, const void *b)
7979
{
80-
return GET_FLOAT_DISTANCE(int2, a, b);
80+
return GET_FLOAT_DISTANCE(int16, a, b);
8181
}
8282

8383

@@ -100,10 +100,10 @@ Datum int2_dist(PG_FUNCTION_ARGS);
100100
Datum
101101
int2_dist(PG_FUNCTION_ARGS)
102102
{
103-
int2 a = PG_GETARG_INT16(0);
104-
int2 b = PG_GETARG_INT16(1);
105-
int2 r;
106-
int2 ra;
103+
int16 a = PG_GETARG_INT16(0);
104+
int16 b = PG_GETARG_INT16(1);
105+
int16 r;
106+
int16 ra;
107107

108108
r = a - b;
109109
ra = Abs(r);

contrib/btree_gist/btree_int4.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ gbt_int4key_cmp(const void *a, const void *b)
7878
static float8
7979
gbt_int4_dist(const void *a, const void *b)
8080
{
81-
return GET_FLOAT_DISTANCE(int4, a, b);
81+
return GET_FLOAT_DISTANCE(int32, a, b);
8282
}
8383

8484

@@ -101,10 +101,10 @@ Datum int4_dist(PG_FUNCTION_ARGS);
101101
Datum
102102
int4_dist(PG_FUNCTION_ARGS)
103103
{
104-
int4 a = PG_GETARG_INT32(0);
105-
int4 b = PG_GETARG_INT32(1);
106-
int4 r;
107-
int4 ra;
104+
int32 a = PG_GETARG_INT32(0);
105+
int32 b = PG_GETARG_INT32(1);
106+
int32 r;
107+
int32 ra;
108108

109109
r = a - b;
110110
ra = Abs(r);

contrib/cube/cube.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ cube_subset(PG_FUNCTION_ARGS)
266266
(errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
267267
errmsg("cannot work with arrays containing NULLs")));
268268

269-
dx = (int4 *) ARR_DATA_PTR(idx);
269+
dx = (int32 *) ARR_DATA_PTR(idx);
270270

271271
dim = ARRNELEMS(idx);
272272
size = offsetof(NDBOX, x[0]) +sizeof(double) * 2 * dim;
@@ -1360,7 +1360,7 @@ cube_enlarge(PG_FUNCTION_ARGS)
13601360
{
13611361
NDBOX *a = PG_GETARG_NDBOX(0);
13621362
double r = PG_GETARG_FLOAT8(1);
1363-
int4 n = PG_GETARG_INT32(2);
1363+
int32 n = PG_GETARG_INT32(2);
13641364
NDBOX *result;
13651365
int dim = 0;
13661366
int size;

contrib/hstore/hstore.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ typedef struct
159159
bool needfree; /* need to pfree the value? */
160160
} Pairs;
161161

162-
extern int hstoreUniquePairs(Pairs *a, int4 l, int4 *buflen);
163-
extern HStore *hstorePairs(Pairs *pairs, int4 pcount, int4 buflen);
162+
extern int hstoreUniquePairs(Pairs *a, int32 l, int32 *buflen);
163+
extern HStore *hstorePairs(Pairs *pairs, int32 pcount, int32 buflen);
164164

165165
extern size_t hstoreCheckKeyLen(size_t len);
166166
extern size_t hstoreCheckValLen(size_t len);

contrib/hstore/hstore_gist.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ typedef char *BITVECP;
4040
typedef struct
4141
{
4242
int32 vl_len_; /* varlena header (do not touch directly!) */
43-
int4 flag;
43+
int32 flag;
4444
char data[1];
4545
} GISTTYPE;
4646

4747
#define ALLISTRUE 0x04
4848

4949
#define ISALLTRUE(x) ( ((GISTTYPE*)x)->flag & ALLISTRUE )
5050

51-
#define GTHDRSIZE (VARHDRSZ + sizeof(int4))
51+
#define GTHDRSIZE (VARHDRSZ + sizeof(int32))
5252
#define CALCGTSIZE(flag) ( GTHDRSIZE+(((flag) & ALLISTRUE) ? 0 : SIGLEN) )
5353

5454
#define GETSIGN(x) ( (BITVECP)( (char*)x+GTHDRSIZE ) )
@@ -143,7 +143,7 @@ ghstore_compress(PG_FUNCTION_ARGS)
143143
}
144144
else if (!ISALLTRUE(DatumGetPointer(entry->key)))
145145
{
146-
int4 i;
146+
int32 i;
147147
GISTTYPE *res;
148148
BITVECP sign = GETSIGN(DatumGetPointer(entry->key));
149149

@@ -192,7 +192,7 @@ ghstore_same(PG_FUNCTION_ARGS)
192192
*result = false;
193193
else
194194
{
195-
int4 i;
195+
int32 i;
196196
BITVECP sa = GETSIGN(a),
197197
sb = GETSIGN(b);
198198

@@ -209,10 +209,10 @@ ghstore_same(PG_FUNCTION_ARGS)
209209
PG_RETURN_POINTER(result);
210210
}
211211

212-
static int4
212+
static int32
213213
sizebitvec(BITVECP sign)
214214
{
215-
int4 size = 0,
215+
int32 size = 0,
216216
i;
217217

218218
LOOPBYTE
@@ -253,10 +253,10 @@ hemdist(GISTTYPE *a, GISTTYPE *b)
253253
return hemdistsign(GETSIGN(a), GETSIGN(b));
254254
}
255255

256-
static int4
256+
static int32
257257
unionkey(BITVECP sbase, GISTTYPE *add)
258258
{
259-
int4 i;
259+
int32 i;
260260
BITVECP sadd = GETSIGN(add);
261261

262262
if (ISALLTRUE(add))
@@ -270,12 +270,12 @@ Datum
270270
ghstore_union(PG_FUNCTION_ARGS)
271271
{
272272
GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
273-
int4 len = entryvec->n;
273+
int32 len = entryvec->n;
274274

275275
int *size = (int *) PG_GETARG_POINTER(1);
276276
BITVEC base;
277-
int4 i;
278-
int4 flag = 0;
277+
int32 i;
278+
int32 flag = 0;
279279
GISTTYPE *result;
280280

281281
MemSet((void *) base, 0, sizeof(BITVEC));
@@ -316,7 +316,7 @@ ghstore_penalty(PG_FUNCTION_ARGS)
316316
typedef struct
317317
{
318318
OffsetNumber pos;
319-
int4 cost;
319+
int32 cost;
320320
} SPLITCOST;
321321

322322
static int
@@ -339,11 +339,11 @@ ghstore_picksplit(PG_FUNCTION_ARGS)
339339
*datum_r;
340340
BITVECP union_l,
341341
union_r;
342-
int4 size_alpha,
342+
int32 size_alpha,
343343
size_beta;
344-
int4 size_waste,
344+
int32 size_waste,
345345
waste = -1;
346-
int4 nbytes;
346+
int32 nbytes;
347347
OffsetNumber seed_1 = 0,
348348
seed_2 = 0;
349349
OffsetNumber *left,

contrib/hstore/hstore_io.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ typedef struct
3636
do { \
3737
if ( state->cur - state->word + 1 >= state->wordlen ) \
3838
{ \
39-
int4 clen = state->cur - state->word; \
39+
int32 clen = state->cur - state->word; \
4040
state->wordlen *= 2; \
4141
state->word = (char*)repalloc( (void*)state->word, state->wordlen ); \
4242
state->cur = state->word + clen; \
@@ -74,7 +74,7 @@ get_val(HSParser *state, bool ignoreeq, bool *escaped)
7474
}
7575
else if (*(state->ptr) == '=' && !ignoreeq)
7676
{
77-
elog(ERROR, "Syntax error near '%c' at position %d", *(state->ptr), (int4) (state->ptr - state->begin));
77+
elog(ERROR, "Syntax error near '%c' at position %d", *(state->ptr), (int32) (state->ptr - state->begin));
7878
}
7979
else if (*(state->ptr) == '\\')
8080
{
@@ -215,7 +215,7 @@ parse_hstore(HSParser *state)
215215
}
216216
else if (!isspace((unsigned char) *(state->ptr)))
217217
{
218-
elog(ERROR, "Syntax error near '%c' at position %d", *(state->ptr), (int4) (state->ptr - state->begin));
218+
elog(ERROR, "Syntax error near '%c' at position %d", *(state->ptr), (int32) (state->ptr - state->begin));
219219
}
220220
}
221221
else if (st == WGT)
@@ -230,7 +230,7 @@ parse_hstore(HSParser *state)
230230
}
231231
else
232232
{
233-
elog(ERROR, "Syntax error near '%c' at position %d", *(state->ptr), (int4) (state->ptr - state->begin));
233+
elog(ERROR, "Syntax error near '%c' at position %d", *(state->ptr), (int32) (state->ptr - state->begin));
234234
}
235235
}
236236
else if (st == WVAL)
@@ -263,7 +263,7 @@ parse_hstore(HSParser *state)
263263
}
264264
else if (!isspace((unsigned char) *(state->ptr)))
265265
{
266-
elog(ERROR, "Syntax error near '%c' at position %d", *(state->ptr), (int4) (state->ptr - state->begin));
266+
elog(ERROR, "Syntax error near '%c' at position %d", *(state->ptr), (int32) (state->ptr - state->begin));
267267
}
268268
}
269269
else
@@ -304,7 +304,7 @@ comparePairs(const void *a, const void *b)
304304
* and (b) who knows whether they might be needed by some caller.
305305
*/
306306
int
307-
hstoreUniquePairs(Pairs *a, int4 l, int4 *buflen)
307+
hstoreUniquePairs(Pairs *a, int32 l, int32 *buflen)
308308
{
309309
Pairs *ptr,
310310
*res;
@@ -367,14 +367,14 @@ hstoreCheckValLen(size_t len)
367367

368368

369369
HStore *
370-
hstorePairs(Pairs *pairs, int4 pcount, int4 buflen)
370+
hstorePairs(Pairs *pairs, int32 pcount, int32 buflen)
371371
{
372372
HStore *out;
373373
HEntry *entry;
374374
char *ptr;
375375
char *buf;
376-
int4 len;
377-
int4 i;
376+
int32 len;
377+
int32 i;
378378

379379
len = CALCDATASIZE(pcount, buflen);
380380
out = palloc(len);
@@ -402,7 +402,7 @@ Datum
402402
hstore_in(PG_FUNCTION_ARGS)
403403
{
404404
HSParser state;
405-
int4 buflen;
405+
int32 buflen;
406406
HStore *out;
407407

408408
state.begin = PG_GETARG_CSTRING(0);
@@ -422,11 +422,11 @@ Datum hstore_recv(PG_FUNCTION_ARGS);
422422
Datum
423423
hstore_recv(PG_FUNCTION_ARGS)
424424
{
425-
int4 buflen;
425+
int32 buflen;
426426
HStore *out;
427427
Pairs *pairs;
428-
int4 i;
429-
int4 pcount;
428+
int32 i;
429+
int32 pcount;
430430
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
431431

432432
pcount = pq_getmsgint(buf, 4);
@@ -518,7 +518,7 @@ Datum hstore_from_arrays(PG_FUNCTION_ARGS);
518518
Datum
519519
hstore_from_arrays(PG_FUNCTION_ARGS)
520520
{
521-
int4 buflen;
521+
int32 buflen;
522522
HStore *out;
523523
Pairs *pairs;
524524
Datum *key_datums;
@@ -632,7 +632,7 @@ hstore_from_array(PG_FUNCTION_ARGS)
632632
ArrayType *in_array = PG_GETARG_ARRAYTYPE_P(0);
633633
int ndims = ARR_NDIM(in_array);
634634
int count;
635-
int4 buflen;
635+
int32 buflen;
636636
HStore *out;
637637
Pairs *pairs;
638638
Datum *in_datums;
@@ -737,7 +737,7 @@ Datum
737737
hstore_from_record(PG_FUNCTION_ARGS)
738738
{
739739
HeapTupleHeader rec;
740-
int4 buflen;
740+
int32 buflen;
741741
HStore *out;
742742
Pairs *pairs;
743743
Oid tupType;

contrib/intarray/_int.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#define MAXNUMRANGE 100
1111

1212
/* useful macros for accessing int4 arrays */
13-
#define ARRPTR(x) ( (int4 *) ARR_DATA_PTR(x) )
13+
#define ARRPTR(x) ( (int32 *) ARR_DATA_PTR(x) )
1414
#define ARRNELEMS(x) ArrayGetNItems(ARR_NDIM(x), ARR_DIMS(x))
1515

1616
/* reject arrays we can't handle; to wit, those containing nulls */
@@ -71,15 +71,15 @@ typedef char *BITVECP;
7171
typedef struct
7272
{
7373
int32 vl_len_; /* varlena header (do not touch directly!) */
74-
int4 flag;
74+
int32 flag;
7575
char data[1];
7676
} GISTTYPE;
7777

7878
#define ALLISTRUE 0x04
7979

8080
#define ISALLTRUE(x) ( ((GISTTYPE*)x)->flag & ALLISTRUE )
8181

82-
#define GTHDRSIZE (VARHDRSZ + sizeof(int4))
82+
#define GTHDRSIZE (VARHDRSZ + sizeof(int32))
8383
#define CALCGTSIZE(flag) ( GTHDRSIZE+(((flag) & ALLISTRUE) ? 0 : SIGLEN) )
8484

8585
#define GETSIGN(x) ( (BITVECP)( (char*)x+GTHDRSIZE ) )
@@ -93,7 +93,7 @@ typedef void (*formfloat) (ArrayType *, float *);
9393
/*
9494
* useful functions
9595
*/
96-
bool isort(int4 *a, int len);
96+
bool isort(int32 *a, int len);
9797
ArrayType *new_intArrayType(int num);
9898
ArrayType *copy_intArrayType(ArrayType *a);
9999
ArrayType *resize_intArrayType(ArrayType *a, int num);
@@ -123,15 +123,15 @@ void gensign(BITVEC sign, int *a, int len);
123123
*/
124124
typedef struct ITEM
125125
{
126-
int2 type;
127-
int2 left;
128-
int4 val;
126+
int16 type;
127+
int16 left;
128+
int32 val;
129129
} ITEM;
130130

131131
typedef struct QUERYTYPE
132132
{
133133
int32 vl_len_; /* varlena header (do not touch directly!) */
134-
int4 size; /* number of ITEMs */
134+
int32 size; /* number of ITEMs */
135135
ITEM items[1]; /* variable length array */
136136
} QUERYTYPE;
137137

@@ -167,7 +167,7 @@ int compDESC(const void *a, const void *b);
167167
do { \
168168
int _nelems_ = ARRNELEMS(a); \
169169
if (_nelems_ > 1) \
170-
qsort((void*) ARRPTR(a), _nelems_, sizeof(int4), \
170+
qsort((void*) ARRPTR(a), _nelems_, sizeof(int32), \
171171
(direction) ? compASC : compDESC ); \
172172
} while(0)
173173

0 commit comments

Comments
 (0)