Skip to content

Commit 28a898a

Browse files
committed
Clean up INT64CONST conflicts. Make the pg_crc code use a macro called
UINT64CONST, since unsigned was what it wanted anyway. Centralize macro definitions into c.h.
1 parent bf1f2e5 commit 28a898a

File tree

7 files changed

+161
-170
lines changed

7 files changed

+161
-170
lines changed

src/backend/utils/adt/int8.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.38 2002/04/21 19:48:12 thomas Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.39 2002/04/23 15:45:30 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -21,17 +21,6 @@
2121

2222
#include "utils/int8.h"
2323

24-
/* this should be set in pg_config.h, but just in case it wasn't: */
25-
#ifndef INT64_FORMAT
26-
#warning "Broken pg_config.h should have defined INT64_FORMAT"
27-
#define INT64_FORMAT "%ld"
28-
#endif
29-
30-
#ifdef HAVE_LL_CONSTANTS
31-
#define INT64CONST(x) ((int64) x##LL)
32-
#else
33-
#define INT64CONST(x) ((int64) x)
34-
#endif
3524

3625
#define MAXINT8LEN 25
3726

src/backend/utils/hash/pg_crc.c

Lines changed: 129 additions & 129 deletions
Large diffs are not rendered by default.

src/include/c.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
15-
* $Id: c.h,v 1.116 2002/04/21 19:48:18 thomas Exp $
15+
* $Id: c.h,v 1.117 2002/04/23 15:45:30 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -302,6 +302,17 @@ typedef unsigned long int uint64;
302302

303303
#endif /* not HAVE_LONG_INT_64 and not HAVE_LONG_LONG_INT_64 */
304304

305+
/* Decide if we need to decorate 64-bit constants */
306+
#ifdef HAVE_LL_CONSTANTS
307+
#define INT64CONST(x) ((int64) x##LL)
308+
#define UINT64CONST(x) ((uint64) x##LL)
309+
#else
310+
#define INT64CONST(x) ((int64) x)
311+
#define UINT64CONST(x) ((uint64) x)
312+
#endif
313+
314+
315+
/* Select timestamp representation (float8 or int64) */
305316
#if defined(USE_INTEGER_DATETIMES) && !defined(INT64_IS_BUSTED)
306317
#define HAVE_INT64_TIMESTAMP
307318
#endif

src/include/utils/date.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: date.h,v 1.18 2002/04/21 19:48:31 thomas Exp $
10+
* $Id: date.h,v 1.19 2002/04/23 15:45:30 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
1414
#ifndef DATE_H
1515
#define DATE_H
1616

17-
#include "c.h"
1817
#include "fmgr.h"
1918

2019

src/include/utils/int8.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: int8.h,v 1.32 2002/04/21 19:48:31 thomas Exp $
10+
* $Id: int8.h,v 1.33 2002/04/23 15:45:30 tgl Exp $
1111
*
1212
* NOTES
1313
* These data types are supported on all 64-bit architectures, and may
@@ -20,21 +20,15 @@
2020
#ifndef INT8_H
2121
#define INT8_H
2222

23-
#include "c.h"
2423
#include "fmgr.h"
2524

25+
2626
/* this should be set in pg_config.h, but just in case it wasn't: */
2727
#ifndef INT64_FORMAT
2828
#warning "Broken pg_config.h should have defined INT64_FORMAT"
2929
#define INT64_FORMAT "%ld"
3030
#endif
3131

32-
#ifdef HAVE_LL_CONSTANTS
33-
#define INT64CONST(x) ((int64) x##LL)
34-
#else
35-
#define INT64CONST(x) ((int64) x)
36-
#endif
37-
3832
extern Datum int8in(PG_FUNCTION_ARGS);
3933
extern Datum int8out(PG_FUNCTION_ARGS);
4034

src/include/utils/pg_crc.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: pg_crc.h,v 1.6 2001/11/05 17:46:36 momjian Exp $
9+
* $Id: pg_crc.h,v 1.7 2002/04/23 15:45:30 tgl Exp $
1010
*/
1111
#ifndef PG_CRC_H
1212
#define PG_CRC_H
@@ -78,23 +78,16 @@ extern const uint32 crc_table1[];
7878

7979
#else /* int64 works */
8080

81-
/* decide if we need to decorate constants */
82-
#ifdef HAVE_LL_CONSTANTS
83-
#define INT64CONST(x) x##LL
84-
#else
85-
#define INT64CONST(x) x
86-
#endif
87-
8881
typedef struct crc64
8982
{
9083
uint64 crc0;
9184
} crc64;
9285

9386
/* Initialize a CRC accumulator */
94-
#define INIT_CRC64(crc) ((crc).crc0 = INT64CONST(0xffffffffffffffff))
87+
#define INIT_CRC64(crc) ((crc).crc0 = UINT64CONST(0xffffffffffffffff))
9588

9689
/* Finish a CRC calculation */
97-
#define FIN_CRC64(crc) ((crc).crc0 ^= INT64CONST(0xffffffffffffffff))
90+
#define FIN_CRC64(crc) ((crc).crc0 ^= UINT64CONST(0xffffffffffffffff))
9891

9992
/* Accumulate some (more) bytes into a CRC */
10093
#define COMP_CRC64(crc, data, len) \

src/include/utils/timestamp.h

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: timestamp.h,v 1.25 2002/04/21 19:48:31 thomas Exp $
9+
* $Id: timestamp.h,v 1.26 2002/04/23 15:45:30 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -18,7 +18,6 @@
1818
#include <limits.h>
1919
#include <float.h>
2020

21-
#include "c.h"
2221
#include "fmgr.h"
2322
#ifdef HAVE_INT64_TIMESTAMP
2423
#include "utils/int8.h"
@@ -31,7 +30,7 @@
3130
* relative to an absolute time.
3231
*
3332
* Note that Postgres uses "time interval" to mean a bounded interval,
34-
* consisting of a beginning and ending time, not a time span - thomas 97/03/20
33+
* consisting of a beginning and ending time, not a time span - thomas 97/03/20
3534
*/
3635

3736
#ifdef HAVE_INT64_TIMESTAMP
@@ -56,10 +55,12 @@ typedef struct
5655
/*
5756
* Macros for fmgr-callable functions.
5857
*
59-
* For Timestamp, we make use of the same support routines as for float8.
60-
* Therefore Timestamp is pass-by-reference if and only if float8 is!
58+
* For Timestamp, we make use of the same support routines as for int64
59+
* or float8. Therefore Timestamp is pass-by-reference if and only if
60+
* int64 or float8 is!
6161
*/
6262
#ifdef HAVE_INT64_TIMESTAMP
63+
6364
#define DatumGetTimestamp(X) ((Timestamp) DatumGetInt64(X))
6465
#define DatumGetTimestampTz(X) ((TimestampTz) DatumGetInt64(X))
6566
#define DatumGetIntervalP(X) ((Interval *) DatumGetPointer(X))
@@ -80,6 +81,7 @@ typedef struct
8081
#define DT_NOEND (INT64CONST(0x7fffffffffffffff))
8182

8283
#else
84+
8385
#define DatumGetTimestamp(X) ((Timestamp) DatumGetFloat8(X))
8486
#define DatumGetTimestampTz(X) ((TimestampTz) DatumGetFloat8(X))
8587
#define DatumGetIntervalP(X) ((Interval *) DatumGetPointer(X))
@@ -103,7 +105,9 @@ typedef struct
103105
#define DT_NOBEGIN (-DBL_MAX)
104106
#define DT_NOEND (DBL_MAX)
105107
#endif
106-
#endif
108+
109+
#endif /* HAVE_INT64_TIMESTAMP */
110+
107111

108112
#define TIMESTAMP_NOBEGIN(j) do {j = DT_NOBEGIN;} while (0)
109113
#define TIMESTAMP_IS_NOBEGIN(j) ((j) == DT_NOBEGIN)
@@ -118,15 +122,16 @@ typedef struct
118122
#define MAX_INTERVAL_PRECISION 6
119123

120124
#ifdef HAVE_INT64_TIMESTAMP
125+
121126
typedef int32 fsec_t;
122127

123-
#define SECONDS_TO_TIMESTAMP(x) (INT64CONST(x000000))
124128
#else
129+
125130
typedef double fsec_t;
126131

127-
#define SECONDS_TO_TIMESTAMP(x) (xe0)
128132
#define TIME_PREC_INV 1000000.0
129133
#define JROUND(j) (rint(((double) (j))*TIME_PREC_INV)/TIME_PREC_INV)
134+
130135
#endif
131136

132137

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy