diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/access/transam/xlog.c | 2 | ||||
-rw-r--r-- | src/backend/tsearch/wparser_def.c | 6 | ||||
-rw-r--r-- | src/backend/utils/adt/int8.c | 2 | ||||
-rw-r--r-- | src/backend/utils/adt/numutils.c | 2 | ||||
-rw-r--r-- | src/backend/utils/adt/timestamp.c | 8 | ||||
-rw-r--r-- | src/backend/utils/adt/tsrank.c | 3 | ||||
-rw-r--r-- | src/backend/utils/adt/txid.c | 2 | ||||
-rw-r--r-- | src/include/c.h | 41 | ||||
-rw-r--r-- | src/include/datatype/timestamp.h | 4 | ||||
-rw-r--r-- | src/include/executor/instrument.h | 2 | ||||
-rw-r--r-- | src/include/nodes/parsenodes.h | 2 | ||||
-rw-r--r-- | src/include/pg_config_manual.h | 4 | ||||
-rw-r--r-- | src/include/port/atomics.h | 4 | ||||
-rw-r--r-- | src/include/storage/predicate_internals.h | 2 | ||||
-rw-r--r-- | src/include/utils/date.h | 6 |
15 files changed, 62 insertions, 28 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 2c6ae12b8d6..751253ba03c 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -1408,7 +1408,7 @@ WALInsertLockAcquireExclusive(void) { LWLockAcquireWithVar(&WALInsertLocks[i].l.lock, &WALInsertLocks[i].l.insertingAt, - UINT64CONST(0xFFFFFFFFFFFFFFFF)); + UINT64_MAX); } LWLockAcquireWithVar(&WALInsertLocks[i].l.lock, &WALInsertLocks[i].l.insertingAt, diff --git a/src/backend/tsearch/wparser_def.c b/src/backend/tsearch/wparser_def.c index ca5b54358ac..d95fdb1fabc 100644 --- a/src/backend/tsearch/wparser_def.c +++ b/src/backend/tsearch/wparser_def.c @@ -14,6 +14,8 @@ #include "postgres.h" +#include <limits.h> + #include "catalog/pg_collation.h" #include "commands/defrem.h" #include "tsearch/ts_locale.h" @@ -2047,7 +2049,7 @@ hlCover(HeadlineParsedText *prs, TSQuery query, int *p, int *q) int pos = *p; *q = -1; - *p = 0x7fffffff; + *p = INT_MAX; for (j = 0; j < query->size; j++) { @@ -2258,7 +2260,7 @@ mark_hl_fragments(HeadlineParsedText *prs, TSQuery query, int highlight, for (f = 0; f < max_fragments; f++) { maxitems = 0; - minwords = 0x7fffffff; + minwords = INT32_MAX; minI = -1; /* diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c index 56d909a4f65..b3a11918870 100644 --- a/src/backend/utils/adt/int8.c +++ b/src/backend/utils/adt/int8.c @@ -78,7 +78,7 @@ scanint8(const char *str, bool errorOK, int64 *result) */ if (strncmp(ptr, "9223372036854775808", 19) == 0) { - tmp = -INT64CONST(0x7fffffffffffffff) - 1; + tmp = INT64_MIN; ptr += 19; goto gotdigits; } diff --git a/src/backend/utils/adt/numutils.c b/src/backend/utils/adt/numutils.c index d77799acfe3..585da1e7322 100644 --- a/src/backend/utils/adt/numutils.c +++ b/src/backend/utils/adt/numutils.c @@ -190,7 +190,7 @@ pg_lltoa(int64 value, char *a) * Avoid problems with the most negative integer not being representable * as a positive integer. */ - if (value == (-INT64CONST(0x7FFFFFFFFFFFFFFF) - 1)) + if (value == INT64_MIN) { memcpy(a, "-9223372036854775808", 21); return; diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index 723c67087e5..33e859d35e1 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -44,14 +44,6 @@ #define SAMESIGN(a,b) (((a) < 0) == ((b) < 0)) -#ifndef INT64_MAX -#define INT64_MAX INT64CONST(0x7FFFFFFFFFFFFFFF) -#endif - -#ifndef INT64_MIN -#define INT64_MIN (-INT64CONST(0x7FFFFFFFFFFFFFFF) - 1) -#endif - /* Set at postmaster start */ TimestampTz PgStartTime; diff --git a/src/backend/utils/adt/tsrank.c b/src/backend/utils/adt/tsrank.c index 733203ec7b5..a3066fa7948 100644 --- a/src/backend/utils/adt/tsrank.c +++ b/src/backend/utils/adt/tsrank.c @@ -13,6 +13,7 @@ */ #include "postgres.h" +#include <limits.h> #include <math.h> #include "tsearch/ts_utils.h" @@ -555,7 +556,7 @@ Cover(DocRepresentation *doc, int len, QueryRepresentation *qr, CoverExt *ext) memset(qr->operandexist, 0, sizeof(bool) * qr->query->size); - ext->p = 0x7fffffff; + ext->p = INT_MAX; ext->q = 0; ptr = doc + ext->pos; diff --git a/src/backend/utils/adt/txid.c b/src/backend/utils/adt/txid.c index f973ef936c5..31f8033ae48 100644 --- a/src/backend/utils/adt/txid.c +++ b/src/backend/utils/adt/txid.c @@ -34,7 +34,7 @@ /* txid will be signed int8 in database, so must limit to 63 bits */ -#define MAX_TXID UINT64CONST(0x7FFFFFFFFFFFFFFF) +#define MAX_TXID ((uint64) INT64_MAX) /* Use unsigned variant internally */ typedef uint64 txid; diff --git a/src/include/c.h b/src/include/c.h index 744721860c5..e7ee5105a27 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -249,6 +249,36 @@ typedef uint8 bits8; /* >= 8 bits */ typedef uint16 bits16; /* >= 16 bits */ typedef uint32 bits32; /* >= 32 bits */ +/* should be defined in stdint.h, but we guarantee them here */ +#ifndef INT8_MIN +#define INT8_MIN (-0x7F-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (0x7F) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-0x7FFF-1) +#endif +#ifndef INT16_MAX +#define INT16_MAX (0x7FFF) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-0x7FFFFFFF-1) +#endif +#ifndef INT32_MAX +#define INT32_MAX (0x7FFFFFFF) +#endif + +#ifndef UINT8_MAX +#define UINT8_MAX (0xFF) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (0xFFFF) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (0xFFFFFFFF) +#endif + /* * 64-bit integers */ @@ -284,6 +314,17 @@ typedef unsigned long long int uint64; #define UINT64CONST(x) ((uint64) x) #endif +/* should be defined in stdint.h, but we guarantee them here */ +#ifndef INT64_MIN +#define INT64_MIN (-INT64CONST(0x7FFFFFFFFFFFFFFF) - 1) +#endif +#ifndef INT64_MAX +#define INT64_MAX INT64CONST(0x7FFFFFFFFFFFFFFF) +#endif +#ifndef UINT64_MAX +#define UINT64_MAX UINT64CONST(0xFFFFFFFFFFFFFFFF) +#endif + /* snprintf format strings to use for 64-bit integers */ #define INT64_FORMAT "%" INT64_MODIFIER "d" #define UINT64_FORMAT "%" INT64_MODIFIER "u" diff --git a/src/include/datatype/timestamp.h b/src/include/datatype/timestamp.h index 6dfaf23cc56..d3450d69a8e 100644 --- a/src/include/datatype/timestamp.h +++ b/src/include/datatype/timestamp.h @@ -119,8 +119,8 @@ typedef struct * DT_NOBEGIN represents timestamp -infinity; DT_NOEND represents +infinity */ #ifdef HAVE_INT64_TIMESTAMP -#define DT_NOBEGIN (-INT64CONST(0x7fffffffffffffff) - 1) -#define DT_NOEND (INT64CONST(0x7fffffffffffffff)) +#define DT_NOBEGIN INT64_MIN +#define DT_NOEND INT64_MAX #else /* !HAVE_INT64_TIMESTAMP */ #ifdef HUGE_VAL #define DT_NOBEGIN (-HUGE_VAL) diff --git a/src/include/executor/instrument.h b/src/include/executor/instrument.h index 1c3b2b0ffb1..db9d1e8ff05 100644 --- a/src/include/executor/instrument.h +++ b/src/include/executor/instrument.h @@ -38,7 +38,7 @@ typedef enum InstrumentOption INSTRUMENT_TIMER = 1 << 0, /* needs timer (and row counts) */ INSTRUMENT_BUFFERS = 1 << 1, /* needs buffer usage */ INSTRUMENT_ROWS = 1 << 2, /* needs row count */ - INSTRUMENT_ALL = 0x7FFFFFFF + INSTRUMENT_ALL = INT32_MAX } InstrumentOption; typedef struct Instrumentation diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index ec0d0eaa4ac..2893ceff183 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -587,7 +587,7 @@ typedef enum TableLikeOption CREATE_TABLE_LIKE_INDEXES = 1 << 2, CREATE_TABLE_LIKE_STORAGE = 1 << 3, CREATE_TABLE_LIKE_COMMENTS = 1 << 4, - CREATE_TABLE_LIKE_ALL = 0x7FFFFFFF + CREATE_TABLE_LIKE_ALL = INT32_MAX } TableLikeOption; /* diff --git a/src/include/pg_config_manual.h b/src/include/pg_config_manual.h index 5cfc0ae1e80..d3e9888b7b9 100644 --- a/src/include/pg_config_manual.h +++ b/src/include/pg_config_manual.h @@ -48,7 +48,7 @@ /* * Set the upper and lower bounds of sequence values. */ -#define SEQ_MAXVALUE INT64CONST(0x7FFFFFFFFFFFFFFF) +#define SEQ_MAXVALUE INT64_MAX #define SEQ_MINVALUE (-SEQ_MAXVALUE) /* @@ -185,7 +185,7 @@ * the older rand() function, which is often different from --- and * considerably inferior to --- random(). */ -#define MAX_RANDOM_VALUE (0x7FFFFFFF) +#define MAX_RANDOM_VALUE INT32_MAX /* * On PPC machines, decide whether to use the mutex hint bit in LWARX diff --git a/src/include/port/atomics.h b/src/include/port/atomics.h index 89868b59c3a..99173644a43 100644 --- a/src/include/port/atomics.h +++ b/src/include/port/atomics.h @@ -489,7 +489,7 @@ STATIC_IF_INLINE uint64 pg_atomic_fetch_sub_u64(volatile pg_atomic_uint64 *ptr, int64 sub_) { AssertPointerAlignment(ptr, 8); - Assert(sub_ != -INT64CONST(0x7FFFFFFFFFFFFFFF) - 1); + Assert(sub_ != INT64_MIN); return pg_atomic_fetch_sub_u64_impl(ptr, sub_); } @@ -518,7 +518,7 @@ STATIC_IF_INLINE uint64 pg_atomic_sub_fetch_u64(volatile pg_atomic_uint64 *ptr, int64 sub_) { AssertPointerAlignment(ptr, 8); - Assert(sub_ != -INT64CONST(0x7FFFFFFFFFFFFFFF) - 1); + Assert(sub_ != INT64_MIN); return pg_atomic_sub_fetch_u64_impl(ptr, sub_); } diff --git a/src/include/storage/predicate_internals.h b/src/include/storage/predicate_internals.h index 2aaf58060d5..8ecf923b1fb 100644 --- a/src/include/storage/predicate_internals.h +++ b/src/include/storage/predicate_internals.h @@ -33,7 +33,7 @@ typedef uint64 SerCommitSeqNo; * at that point. It's earlier than all normal sequence numbers, * and is only used by recovered prepared transactions */ -#define InvalidSerCommitSeqNo ((SerCommitSeqNo) UINT64CONST(0xFFFFFFFFFFFFFFFF)) +#define InvalidSerCommitSeqNo ((SerCommitSeqNo) UINT64_MAX) #define RecoverySerCommitSeqNo ((SerCommitSeqNo) 1) #define FirstNormalSerCommitSeqNo ((SerCommitSeqNo) 2) diff --git a/src/include/utils/date.h b/src/include/utils/date.h index b57f4bb3ea2..f07011c3851 100644 --- a/src/include/utils/date.h +++ b/src/include/utils/date.h @@ -35,11 +35,9 @@ typedef struct /* * Infinity and minus infinity must be the max and min values of DateADT. - * We could use INT_MIN and INT_MAX here, but seems better to not assume that - * int32 == int. */ -#define DATEVAL_NOBEGIN ((DateADT) (-0x7fffffff - 1)) -#define DATEVAL_NOEND ((DateADT) 0x7fffffff) +#define DATEVAL_NOBEGIN ((DateADT) INT32_MIN) +#define DATEVAL_NOEND ((DateADT) INT32_MAX) #define DATE_NOBEGIN(j) ((j) = DATEVAL_NOBEGIN) #define DATE_IS_NOBEGIN(j) ((j) == DATEVAL_NOBEGIN) |