Commit 28a898ad authored by Tom Lane's avatar Tom Lane

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.
parent bf1f2e54
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.38 2002/04/21 19:48:12 thomas Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.39 2002/04/23 15:45:30 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -21,17 +21,6 @@ ...@@ -21,17 +21,6 @@
#include "utils/int8.h" #include "utils/int8.h"
/* this should be set in pg_config.h, but just in case it wasn't: */
#ifndef INT64_FORMAT
#warning "Broken pg_config.h should have defined INT64_FORMAT"
#define INT64_FORMAT "%ld"
#endif
#ifdef HAVE_LL_CONSTANTS
#define INT64CONST(x) ((int64) x##LL)
#else
#define INT64CONST(x) ((int64) x)
#endif
#define MAXINT8LEN 25 #define MAXINT8LEN 25
......
This diff is collapsed.
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: c.h,v 1.116 2002/04/21 19:48:18 thomas Exp $ * $Id: c.h,v 1.117 2002/04/23 15:45:30 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -302,6 +302,17 @@ typedef unsigned long int uint64; ...@@ -302,6 +302,17 @@ typedef unsigned long int uint64;
#endif /* not HAVE_LONG_INT_64 and not HAVE_LONG_LONG_INT_64 */ #endif /* not HAVE_LONG_INT_64 and not HAVE_LONG_LONG_INT_64 */
/* Decide if we need to decorate 64-bit constants */
#ifdef HAVE_LL_CONSTANTS
#define INT64CONST(x) ((int64) x##LL)
#define UINT64CONST(x) ((uint64) x##LL)
#else
#define INT64CONST(x) ((int64) x)
#define UINT64CONST(x) ((uint64) x)
#endif
/* Select timestamp representation (float8 or int64) */
#if defined(USE_INTEGER_DATETIMES) && !defined(INT64_IS_BUSTED) #if defined(USE_INTEGER_DATETIMES) && !defined(INT64_IS_BUSTED)
#define HAVE_INT64_TIMESTAMP #define HAVE_INT64_TIMESTAMP
#endif #endif
......
...@@ -7,14 +7,13 @@ ...@@ -7,14 +7,13 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: date.h,v 1.18 2002/04/21 19:48:31 thomas Exp $ * $Id: date.h,v 1.19 2002/04/23 15:45:30 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#ifndef DATE_H #ifndef DATE_H
#define DATE_H #define DATE_H
#include "c.h"
#include "fmgr.h" #include "fmgr.h"
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: int8.h,v 1.32 2002/04/21 19:48:31 thomas Exp $ * $Id: int8.h,v 1.33 2002/04/23 15:45:30 tgl Exp $
* *
* NOTES * NOTES
* These data types are supported on all 64-bit architectures, and may * These data types are supported on all 64-bit architectures, and may
...@@ -20,21 +20,15 @@ ...@@ -20,21 +20,15 @@
#ifndef INT8_H #ifndef INT8_H
#define INT8_H #define INT8_H
#include "c.h"
#include "fmgr.h" #include "fmgr.h"
/* this should be set in pg_config.h, but just in case it wasn't: */ /* this should be set in pg_config.h, but just in case it wasn't: */
#ifndef INT64_FORMAT #ifndef INT64_FORMAT
#warning "Broken pg_config.h should have defined INT64_FORMAT" #warning "Broken pg_config.h should have defined INT64_FORMAT"
#define INT64_FORMAT "%ld" #define INT64_FORMAT "%ld"
#endif #endif
#ifdef HAVE_LL_CONSTANTS
#define INT64CONST(x) ((int64) x##LL)
#else
#define INT64CONST(x) ((int64) x)
#endif
extern Datum int8in(PG_FUNCTION_ARGS); extern Datum int8in(PG_FUNCTION_ARGS);
extern Datum int8out(PG_FUNCTION_ARGS); extern Datum int8out(PG_FUNCTION_ARGS);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: pg_crc.h,v 1.6 2001/11/05 17:46:36 momjian Exp $ * $Id: pg_crc.h,v 1.7 2002/04/23 15:45:30 tgl Exp $
*/ */
#ifndef PG_CRC_H #ifndef PG_CRC_H
#define PG_CRC_H #define PG_CRC_H
...@@ -78,23 +78,16 @@ extern const uint32 crc_table1[]; ...@@ -78,23 +78,16 @@ extern const uint32 crc_table1[];
#else /* int64 works */ #else /* int64 works */
/* decide if we need to decorate constants */
#ifdef HAVE_LL_CONSTANTS
#define INT64CONST(x) x##LL
#else
#define INT64CONST(x) x
#endif
typedef struct crc64 typedef struct crc64
{ {
uint64 crc0; uint64 crc0;
} crc64; } crc64;
/* Initialize a CRC accumulator */ /* Initialize a CRC accumulator */
#define INIT_CRC64(crc) ((crc).crc0 = INT64CONST(0xffffffffffffffff)) #define INIT_CRC64(crc) ((crc).crc0 = UINT64CONST(0xffffffffffffffff))
/* Finish a CRC calculation */ /* Finish a CRC calculation */
#define FIN_CRC64(crc) ((crc).crc0 ^= INT64CONST(0xffffffffffffffff)) #define FIN_CRC64(crc) ((crc).crc0 ^= UINT64CONST(0xffffffffffffffff))
/* Accumulate some (more) bytes into a CRC */ /* Accumulate some (more) bytes into a CRC */
#define COMP_CRC64(crc, data, len) \ #define COMP_CRC64(crc, data, len) \
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: timestamp.h,v 1.25 2002/04/21 19:48:31 thomas Exp $ * $Id: timestamp.h,v 1.26 2002/04/23 15:45:30 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include <limits.h> #include <limits.h>
#include <float.h> #include <float.h>
#include "c.h"
#include "fmgr.h" #include "fmgr.h"
#ifdef HAVE_INT64_TIMESTAMP #ifdef HAVE_INT64_TIMESTAMP
#include "utils/int8.h" #include "utils/int8.h"
...@@ -31,7 +30,7 @@ ...@@ -31,7 +30,7 @@
* relative to an absolute time. * relative to an absolute time.
* *
* Note that Postgres uses "time interval" to mean a bounded interval, * Note that Postgres uses "time interval" to mean a bounded interval,
* consisting of a beginning and ending time, not a time span - thomas 97/03/20 * consisting of a beginning and ending time, not a time span - thomas 97/03/20
*/ */
#ifdef HAVE_INT64_TIMESTAMP #ifdef HAVE_INT64_TIMESTAMP
...@@ -56,10 +55,12 @@ typedef struct ...@@ -56,10 +55,12 @@ typedef struct
/* /*
* Macros for fmgr-callable functions. * Macros for fmgr-callable functions.
* *
* For Timestamp, we make use of the same support routines as for float8. * For Timestamp, we make use of the same support routines as for int64
* Therefore Timestamp is pass-by-reference if and only if float8 is! * or float8. Therefore Timestamp is pass-by-reference if and only if
* int64 or float8 is!
*/ */
#ifdef HAVE_INT64_TIMESTAMP #ifdef HAVE_INT64_TIMESTAMP
#define DatumGetTimestamp(X) ((Timestamp) DatumGetInt64(X)) #define DatumGetTimestamp(X) ((Timestamp) DatumGetInt64(X))
#define DatumGetTimestampTz(X) ((TimestampTz) DatumGetInt64(X)) #define DatumGetTimestampTz(X) ((TimestampTz) DatumGetInt64(X))
#define DatumGetIntervalP(X) ((Interval *) DatumGetPointer(X)) #define DatumGetIntervalP(X) ((Interval *) DatumGetPointer(X))
...@@ -80,6 +81,7 @@ typedef struct ...@@ -80,6 +81,7 @@ typedef struct
#define DT_NOEND (INT64CONST(0x7fffffffffffffff)) #define DT_NOEND (INT64CONST(0x7fffffffffffffff))
#else #else
#define DatumGetTimestamp(X) ((Timestamp) DatumGetFloat8(X)) #define DatumGetTimestamp(X) ((Timestamp) DatumGetFloat8(X))
#define DatumGetTimestampTz(X) ((TimestampTz) DatumGetFloat8(X)) #define DatumGetTimestampTz(X) ((TimestampTz) DatumGetFloat8(X))
#define DatumGetIntervalP(X) ((Interval *) DatumGetPointer(X)) #define DatumGetIntervalP(X) ((Interval *) DatumGetPointer(X))
...@@ -103,7 +105,9 @@ typedef struct ...@@ -103,7 +105,9 @@ typedef struct
#define DT_NOBEGIN (-DBL_MAX) #define DT_NOBEGIN (-DBL_MAX)
#define DT_NOEND (DBL_MAX) #define DT_NOEND (DBL_MAX)
#endif #endif
#endif
#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)
...@@ -118,15 +122,16 @@ typedef struct ...@@ -118,15 +122,16 @@ typedef struct
#define MAX_INTERVAL_PRECISION 6 #define MAX_INTERVAL_PRECISION 6
#ifdef HAVE_INT64_TIMESTAMP #ifdef HAVE_INT64_TIMESTAMP
typedef int32 fsec_t; typedef int32 fsec_t;
#define SECONDS_TO_TIMESTAMP(x) (INT64CONST(x000000))
#else #else
typedef double fsec_t; typedef double fsec_t;
#define SECONDS_TO_TIMESTAMP(x) (xe0)
#define TIME_PREC_INV 1000000.0 #define TIME_PREC_INV 1000000.0
#define JROUND(j) (rint(((double) (j))*TIME_PREC_INV)/TIME_PREC_INV) #define JROUND(j) (rint(((double) (j))*TIME_PREC_INV)/TIME_PREC_INV)
#endif #endif
......
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