Remove all the special-case code for INT64_IS_BUSTED, per decision that
authorTom Lane <[email protected]>
Thu, 7 Jan 2010 04:53:35 +0000 (04:53 +0000)
committerTom Lane <[email protected]>
Thu, 7 Jan 2010 04:53:35 +0000 (04:53 +0000)
we're not going to support that anymore.

I did keep the 64-bit-CRC-with-32-bit-arithmetic code, since it has a
performance excuse to live.  It's a bit moot since that's all ifdef'd
out, of course.

16 files changed:
contrib/btree_gin/btree_gin.c
src/backend/access/hash/hashfunc.c
src/backend/libpq/pqformat.c
src/backend/utils/adt/int8.c
src/backend/utils/adt/numeric.c
src/backend/utils/adt/txid.c
src/backend/utils/adt/varbit.c
src/backend/utils/fmgr/fmgr.c
src/backend/utils/hash/pg_crc.c
src/backend/utils/misc/guc.c
src/bin/pg_dump/pg_backup_tar.c
src/include/c.h
src/include/commands/sequence.h
src/include/pg_config_manual.h
src/include/utils/pg_crc.h
src/interfaces/ecpg/include/pgtypes_interval.h

index 7245fd88a0a22579e61c010c54eb6bcea187801a..d4ce676937bcbc0c11c108915fd687bcf8a9c18e 100644 (file)
@@ -214,8 +214,7 @@ static Datum
 leftmostvalue_int8(void)
 {
    /*
-    * Use sequence's definition to keep compatibility. Another way may make a
-    * problem with INT64_IS_BUSTED
+    * Use sequence's definition to keep compatibility.
     */
    return Int64GetDatum(SEQ_MINVALUE);
 }
@@ -245,8 +244,7 @@ static Datum
 leftmostvalue_money(void)
 {
    /*
-    * Use sequence's definition to keep compatibility. Another way may make a
-    * problem with INT64_IS_BUSTED
+    * Use sequence's definition to keep compatibility.
     */
    return Int64GetDatum(SEQ_MINVALUE);
 }
index 93714e6fe2813036fa4188326f7770d233b6a6e4..405037d1341011ca22f6f6d693e7fc98d43128aa 100644 (file)
@@ -59,7 +59,6 @@ hashint8(PG_FUNCTION_ARGS)
     * value if the sign is positive, or the complement of the high half when
     * the sign is negative.
     */
-#ifndef INT64_IS_BUSTED
    int64       val = PG_GETARG_INT64(0);
    uint32      lohalf = (uint32) val;
    uint32      hihalf = (uint32) (val >> 32);
@@ -67,10 +66,6 @@ hashint8(PG_FUNCTION_ARGS)
    lohalf ^= (val >= 0) ? hihalf : ~hihalf;
 
    return hash_uint32(lohalf);
-#else
-   /* here if we can't count on "x >> 32" to work sanely */
-   return hash_uint32((int32) PG_GETARG_INT64(0));
-#endif
 }
 
 Datum
index 28083845f5d12e1e8cabf56755ecbe014d18f039..a601d80dc139d9dd36555df5604b593c624b781e 100644 (file)
@@ -272,12 +272,7 @@ pq_sendint64(StringInfo buf, int64 i)
    uint32      n32;
 
    /* High order half first, since we're doing MSB-first */
-#ifdef INT64_IS_BUSTED
-   /* don't try a right shift of 32 on a 32-bit word */
-   n32 = (i < 0) ? -1 : 0;
-#else
    n32 = (uint32) (i >> 32);
-#endif
    n32 = htonl(n32);
    appendBinaryStringInfo(buf, (char *) &n32, 4);
 
@@ -327,27 +322,6 @@ pq_sendfloat4(StringInfo buf, float4 f)
 void
 pq_sendfloat8(StringInfo buf, float8 f)
 {
-#ifdef INT64_IS_BUSTED
-   union
-   {
-       float8      f;
-       uint32      h[2];
-   }           swap;
-
-   swap.f = f;
-   swap.h[0] = htonl(swap.h[0]);
-   swap.h[1] = htonl(swap.h[1]);
-
-#ifdef WORDS_BIGENDIAN
-   /* machine seems to be big-endian, send h[0] first */
-   appendBinaryStringInfo(buf, (char *) &swap.h[0], 4);
-   appendBinaryStringInfo(buf, (char *) &swap.h[1], 4);
-#else
-   /* machine seems to be little-endian, send h[1] first */
-   appendBinaryStringInfo(buf, (char *) &swap.h[1], 4);
-   appendBinaryStringInfo(buf, (char *) &swap.h[0], 4);
-#endif
-#else                          /* INT64 works */
    union
    {
        float8      f;
@@ -356,7 +330,6 @@ pq_sendfloat8(StringInfo buf, float8 f)
 
    swap.f = f;
    pq_sendint64(buf, swap.i);
-#endif
 }
 
 /* --------------------------------
@@ -520,18 +493,9 @@ pq_getmsgint64(StringInfo msg)
    h32 = ntohl(h32);
    l32 = ntohl(l32);
 
-#ifdef INT64_IS_BUSTED
-   /* error out if incoming value is wider than 32 bits */
-   result = l32;
-   if ((result < 0) ? (h32 != -1) : (h32 != 0))
-       ereport(ERROR,
-               (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
-                errmsg("binary value is out of range for type bigint")));
-#else
    result = h32;
    result <<= 32;
    result |= l32;
-#endif
 
    return result;
 }
@@ -564,24 +528,6 @@ pq_getmsgfloat4(StringInfo msg)
 float8
 pq_getmsgfloat8(StringInfo msg)
 {
-#ifdef INT64_IS_BUSTED
-   union
-   {
-       float8      f;
-       uint32      h[2];
-   }           swap;
-
-#ifdef WORDS_BIGENDIAN
-   /* machine seems to be big-endian, receive h[0] first */
-   swap.h[0] = pq_getmsgint(msg, 4);
-   swap.h[1] = pq_getmsgint(msg, 4);
-#else
-   /* machine seems to be little-endian, receive h[1] first */
-   swap.h[1] = pq_getmsgint(msg, 4);
-   swap.h[0] = pq_getmsgint(msg, 4);
-#endif
-   return swap.f;
-#else                          /* INT64 works */
    union
    {
        float8      f;
@@ -590,7 +536,6 @@ pq_getmsgfloat8(StringInfo msg)
 
    swap.i = pq_getmsgint64(msg);
    return swap.f;
-#endif
 }
 
 /* --------------------------------
index db8c4462a9ef34d13bf54b4769d1037367fa2510..b46b26c0832f3fa9de742c7a494c5d8a8eb1c099 100644 (file)
@@ -76,15 +76,12 @@ scanint8(const char *str, bool errorOK, int64 *result)
         * Do an explicit check for INT64_MIN.  Ugly though this is, it's
         * cleaner than trying to get the loop below to handle it portably.
         */
-#ifndef INT64_IS_BUSTED
        if (strncmp(ptr, "9223372036854775808", 19) == 0)
        {
            tmp = -INT64CONST(0x7fffffffffffffff) - 1;
            ptr += 19;
            goto gotdigits;
        }
-#endif
-
        sign = -1;
    }
    else if (*ptr == '+')
@@ -575,12 +572,9 @@ int8mul(PG_FUNCTION_ARGS)
     * Since the division is likely much more expensive than the actual
     * multiplication, we'd like to skip it where possible.  The best bang for
     * the buck seems to be to check whether both inputs are in the int32
-    * range; if so, no overflow is possible.  (But that only works if we
-    * really have a 64-bit int64 datatype...)
+    * range; if so, no overflow is possible.
     */
-#ifndef INT64_IS_BUSTED
    if (arg1 != (int64) ((int32) arg1) || arg2 != (int64) ((int32) arg2))
-#endif
    {
        if (arg2 != 0 &&
            (result / arg2 != arg1 || (arg2 == -1 && arg1 < 0 && result < 0)))
index 5802a81145441e4138a5d232a9511748e271c5fa..d62888f5a3e70fd26dfc7ed35a9729d0504495a4 100644 (file)
@@ -2808,16 +2808,8 @@ int8_sum(PG_FUNCTION_ARGS)
 
 typedef struct Int8TransTypeData
 {
-#ifndef INT64_IS_BUSTED
    int64       count;
    int64       sum;
-#else
-   /* "int64" isn't really 64 bits, so fake up properly-aligned fields */
-   int32       count;
-   int32       pad1;
-   int32       sum;
-   int32       pad2;
-#endif
 } Int8TransTypeData;
 
 Datum
index 617f677c2bc8df4f5236e69e463ad0eb624438b5..76f105f1d8cc635ea31021d581bda3ec275c7cbc 100644 (file)
 #include "utils/snapmgr.h"
 
 
-#ifndef INT64_IS_BUSTED
 /* txid will be signed int8 in database, so must limit to 63 bits */
 #define MAX_TXID   UINT64CONST(0x7FFFFFFFFFFFFFFF)
-#else
-/* we only really have 32 bits to work with :-( */
-#define MAX_TXID   UINT64CONST(0x7FFFFFFF)
-#endif
 
 /* Use unsigned variant internally */
 typedef uint64 txid;
@@ -97,7 +92,6 @@ load_xid_epoch(TxidEpoch *state)
 static txid
 convert_xid(TransactionId xid, const TxidEpoch *state)
 {
-#ifndef INT64_IS_BUSTED
    uint64      epoch;
 
    /* return special xid's as-is */
@@ -114,10 +108,6 @@ convert_xid(TransactionId xid, const TxidEpoch *state)
        epoch++;
 
    return (epoch << 32) | xid;
-#else                          /* INT64_IS_BUSTED */
-   /* we can't do anything with the epoch, so ignore it */
-   return (txid) xid & MAX_TXID;
-#endif   /* INT64_IS_BUSTED */
 }
 
 /*
index 45d86385c2563ba585450442d82ed61f5f2a0762..c6320bc2144a1b81de9510dc8b6d5ea78b32e5e3 100644 (file)
@@ -1414,11 +1414,7 @@ bitfromint8(PG_FUNCTION_ARGS)
 
    r = VARBITS(result);
    destbitsleft = typmod;
-#ifndef INT64_IS_BUSTED
    srcbitsleft = 64;
-#else
-   srcbitsleft = 32;           /* don't try to shift more than 32 */
-#endif
    /* drop any input bits that don't fit */
    srcbitsleft = Min(srcbitsleft, destbitsleft);
    /* sign-fill any excess bytes in output */
index 57f27e2a9c5684ad1f05a9bdc40af4fb7a579fc1..03a185503c73063a5b11d8d332fc3dfabc05c330 100644 (file)
@@ -2112,24 +2112,10 @@ fmgr(Oid procedureId,...)
 Datum
 Int64GetDatum(int64 X)
 {
-#ifndef INT64_IS_BUSTED
    int64      *retval = (int64 *) palloc(sizeof(int64));
 
    *retval = X;
    return PointerGetDatum(retval);
-#else                          /* INT64_IS_BUSTED */
-
-   /*
-    * On a machine with no 64-bit-int C datatype, sizeof(int64) will not be
-    * 8, but we want Int64GetDatum to return an 8-byte object anyway, with
-    * zeroes in the unused bits.  This is needed so that, for example, hash
-    * join of int8 will behave properly.
-    */
-   int64      *retval = (int64 *) palloc0(Max(sizeof(int64), 8));
-
-   *retval = X;
-   return PointerGetDatum(retval);
-#endif   /* INT64_IS_BUSTED */
 }
 #endif   /* USE_FLOAT8_BYVAL */
 
index 593d9f69b587097e5d5dfe4b63e7d0c95f9dada7..712c48bbf3713b2d90aaf1e5ff03c6cbdaa5c428 100644 (file)
@@ -115,7 +115,7 @@ const uint32 pg_crc32_table[256] = {
  * (ECMA-182, available from http://www.ecma.ch/ecma1/STAND/ECMA-182.HTM)
  */
 
-#ifdef INT64_IS_BUSTED
+#if SIZEOF_VOID_P < 8      /* this test must match the one in pg_crc.h */
 
 const uint32 pg_crc64_table0[256] = {
    0x00000000, 0xA9EA3693,
@@ -378,7 +378,8 @@ const uint32 pg_crc64_table1[256] = {
    0x5DEDC41A, 0x1F1D25F1,
    0xD80C07CD, 0x9AFCE626
 };
-#else                          /* int64 works */
+
+#else                          /* use int64 implementation */
 
 const uint64 pg_crc64_table[256] = {
    UINT64CONST(0x0000000000000000), UINT64CONST(0x42F0E1EBA9EA3693),
@@ -510,6 +511,6 @@ const uint64 pg_crc64_table[256] = {
    UINT64CONST(0x5DEDC41A34BBEEB2), UINT64CONST(0x1F1D25F19D51D821),
    UINT64CONST(0xD80C07CD676F8394), UINT64CONST(0x9AFCE626CE85B507)
 };
-#endif   /* INT64_IS_BUSTED */
+#endif   /* SIZEOF_VOID_P < 8 */
 
 #endif   /* PROVIDE_64BIT_CRC */
index 9d78df0ead5ca27ee6f52a927d1850320d3f5172..3a854dad7f5035f314ef06f45cebea1892b7a5e5 100644 (file)
@@ -4240,10 +4240,6 @@ parse_int(const char *value, int *result, int flags, const char **hintmsg)
        /*
         * Note: the multiple-switch coding technique here is a bit tedious,
         * but seems necessary to avoid intermediate-value overflows.
-        *
-        * If INT64_IS_BUSTED (ie, it's really int32) we will fail to detect
-        * overflow due to units conversion, but there are few enough such
-        * machines that it does not seem worth trying to be smarter.
         */
        if (flags & GUC_UNIT_MEMORY)
        {
@@ -6627,10 +6623,7 @@ _ShowOption(struct config_generic * record, bool use_units)
                {
                    /*
                     * Use int64 arithmetic to avoid overflows in units
-                    * conversion.  If INT64_IS_BUSTED we might overflow
-                    * anyway and print bogus answers, but there are few
-                    * enough such machines that it doesn't seem worth trying
-                    * harder.
+                    * conversion.
                     */
                    int64       result = *conf->variable;
                    const char *unit;
index b5e0c43e8806e6c16a30052b87b1ce2f930ce3a8..5cbc3653d21e65652e9238139cbe9dc007bf12ae 100644 (file)
@@ -75,13 +75,9 @@ typedef struct
 /*
  * Maximum file size for a tar member: The limit inherent in the
  * format is 2^33-1 bytes (nearly 8 GB).  But we don't want to exceed
- * what we can represent by an pgoff_t.
+ * what we can represent in pgoff_t.
  */
-#ifdef INT64_IS_BUSTED
-#define MAX_TAR_MEMBER_FILELEN INT_MAX
-#else
 #define MAX_TAR_MEMBER_FILELEN (((int64) 1 << Min(33, sizeof(pgoff_t)*8 - 1)) - 1)
-#endif
 
 typedef struct
 {
index 78a24b76b32d46304f3e5a92c4aa9d4e341bc81d..f32ec295c508a59e1ffa72ba33f9b954ae75dbea 100644 (file)
@@ -270,6 +270,7 @@ typedef long int int64;
 #ifndef HAVE_UINT64
 typedef unsigned long int uint64;
 #endif
+
 #elif defined(HAVE_LONG_LONG_INT_64)
 /* We have working support for "long long int", use that */
 
@@ -279,21 +280,12 @@ typedef long long int int64;
 #ifndef HAVE_UINT64
 typedef unsigned long long int uint64;
 #endif
-#else                          /* not HAVE_LONG_INT_64 and not
-                                * HAVE_LONG_LONG_INT_64 */
 
-/* Won't actually work, but fall back to long int so that code compiles */
-#ifndef HAVE_INT64
-typedef long int int64;
-#endif
-#ifndef HAVE_UINT64
-typedef unsigned long int uint64;
+#else
+/* neither HAVE_LONG_INT_64 nor HAVE_LONG_LONG_INT_64 */
+#error must have a working 64-bit integer datatype
 #endif
 
-#define INT64_IS_BUSTED
-#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)
@@ -305,7 +297,7 @@ typedef unsigned long int uint64;
 
 
 /* Select timestamp representation (float8 or int64) */
-#if defined(USE_INTEGER_DATETIMES) && !defined(INT64_IS_BUSTED)
+#ifdef USE_INTEGER_DATETIMES
 #define HAVE_INT64_TIMESTAMP
 #endif
 
index d47b9fa50452d68862e75acee35a50a5bd6ab1f2..6e8907c0d8bdfbbbe21f381a3f8a63b10ccaa191 100644 (file)
 #include "fmgr.h"
 
 
-/*
- * On a machine with no 64-bit-int C datatype, sizeof(int64) will not be 8,
- * but we need this struct type to line up with the way that a sequence
- * table is defined --- and pg_type will say that int8 is 8 bytes anyway.
- * So, we need padding.  Ugly but necessary.
- */
 typedef struct FormData_pg_sequence
 {
    NameData    sequence_name;
-#ifndef INT64_IS_BUSTED
    int64       last_value;
    int64       start_value;
    int64       increment_by;
@@ -36,22 +29,6 @@ typedef struct FormData_pg_sequence
    int64       min_value;
    int64       cache_value;
    int64       log_cnt;
-#else
-   int32       last_value;
-   int32       pad1;
-   int32       start_value;
-   int32       pad2;
-   int32       increment_by;
-   int32       pad3;
-   int32       max_value;
-   int32       pad4;
-   int32       min_value;
-   int32       pad5;
-   int32       cache_value;
-   int32       pad6;
-   int32       log_cnt;
-   int32       pad7;
-#endif
    bool        is_cycled;
    bool        is_called;
 } FormData_pg_sequence;
index f034be9515129a04cc90b50c9392317f99b3e90b..c5c1228829da0c1ac1f4497e2ccbd7f4fb28397b 100644 (file)
 /*
  * Set the upper and lower bounds of sequence values.
  */
-#ifndef INT64_IS_BUSTED
 #define SEQ_MAXVALUE   INT64CONST(0x7FFFFFFFFFFFFFFF)
-#else                          /* INT64_IS_BUSTED */
-#define SEQ_MAXVALUE   ((int64) 0x7FFFFFFF)
-#endif   /* INT64_IS_BUSTED */
-
 #define SEQ_MINVALUE   (-SEQ_MAXVALUE)
 
 /*
index f329a78944c868a3a6533543c57f43d441350d81..6dc2171ea7a96d77167b03322099608dbd542edf 100644 (file)
@@ -60,15 +60,14 @@ extern CRCDLLIMPORT const uint32 pg_crc32_table[];
 #ifdef PROVIDE_64BIT_CRC
 
 /*
- * If we have a 64-bit integer type, then a 64-bit CRC looks just like the
- * usual sort of implementation.  If we have no working 64-bit type, then
- * fake it with two 32-bit registers.  (Note: experience has shown that the
- * two-32-bit-registers code is as fast as, or even much faster than, the
- * 64-bit code on all but true 64-bit machines.  INT64_IS_BUSTED is therefore
- * probably the wrong control symbol to use to select the implementation.)
+ * If we use a 64-bit integer type, then a 64-bit CRC looks just like the
+ * usual sort of implementation.  However, we can also fake it with two
+ * 32-bit registers.  Experience has shown that the two-32-bit-registers code
+ * is as fast as, or even much faster than, the 64-bit code on all but true
+ * 64-bit machines.  We use SIZEOF_VOID_P to check the native word width.
  */
 
-#ifdef INT64_IS_BUSTED
+#if SIZEOF_VOID_P < 8
 
 /*
  * crc0 represents the LSBs of the 64-bit value, crc1 the MSBs.  Note that
@@ -114,7 +113,8 @@ do { \
 /* Constant table for CRC calculation */
 extern CRCDLLIMPORT const uint32 pg_crc64_table0[];
 extern CRCDLLIMPORT const uint32 pg_crc64_table1[];
-#else                          /* int64 works */
+
+#else                          /* use int64 implementation */
 
 typedef struct pg_crc64
 {
@@ -147,7 +147,7 @@ do { \
 
 /* Constant table for CRC calculation */
 extern CRCDLLIMPORT const uint64 pg_crc64_table[];
-#endif   /* INT64_IS_BUSTED */
+#endif   /* SIZEOF_VOID_P < 8 */
 #endif   /* PROVIDE_64BIT_CRC */
 
 #endif   /* PG_CRC_H */
index 0e03c4ebf5fe1b5a4f9dc7d12a8cf841e6c8be8d..e8cbc2fa5911b25b761635c70101c04e6df50912 100644 (file)
 typedef long int int64;
 #endif
 #elif defined(HAVE_LONG_LONG_INT_64)
-/* We have working support for "long long int", use that */
-
 #ifndef HAVE_INT64
 typedef long long int int64;
 #endif
-#else                          /* not HAVE_LONG_INT_64 and not
-                                * HAVE_LONG_LONG_INT_64 */
-
-/* Won't actually work, but fall back to long int so that code compiles */
-#ifndef HAVE_INT64
-typedef long int int64;
+#else
+/* neither HAVE_LONG_INT_64 nor HAVE_LONG_LONG_INT_64 */
+#error must have a working 64-bit integer datatype
 #endif
 
-#define INT64_IS_BUSTED
-#endif   /* not HAVE_LONG_INT_64 and not
-                                * HAVE_LONG_LONG_INT_64 */
-#endif   /* C_H */
-
-#if defined(USE_INTEGER_DATETIMES) && !defined(INT64_IS_BUSTED)
+#ifdef USE_INTEGER_DATETIMES
 #define HAVE_INT64_TIMESTAMP
 #endif
 
+#endif   /* C_H */
+
 typedef struct
 {
 #ifdef HAVE_INT64_TIMESTAMP