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 */
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"
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+
121126typedef int32 fsec_t ;
122127
123- #define SECONDS_TO_TIMESTAMP (x ) (INT64CONST(x000000))
124128#else
129+
125130typedef 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