Commit e458ebfd authored by Tom Lane's avatar Tom Lane

When using 'long long int' for int64 type, check to see if the compiler

accepts nnnLL syntax for long long constants.  If so, decorate the CRC64
constants with LL to avoid warnings and/or erroneous results from certain
non-standards-compliant compilers.
parent 32924c1c
This diff is collapsed.
...@@ -979,6 +979,19 @@ if test x"$HAVE_LONG_INT_64" = x"no" ; then ...@@ -979,6 +979,19 @@ if test x"$HAVE_LONG_INT_64" = x"no" ; then
fi fi
dnl If we need to use "long long int", figure out whether nnnLL notation works.
if [[ x"$HAVE_LONG_LONG_INT_64" = xyes ]] ; then
AC_TRY_COMPILE([
#define INT64CONST(x) x##LL
long long int foo = INT64CONST(0x1234567890123456);
],
[],
[AC_DEFINE(HAVE_LL_CONSTANTS)],
[])
fi
dnl If we found "long int" is 64 bits, assume snprintf handles it. dnl If we found "long int" is 64 bits, assume snprintf handles it.
dnl If we found we need to use "long long int", better check. dnl If we found we need to use "long long int", better check.
dnl We cope with snprintfs that use either %lld or %qd as the format. dnl We cope with snprintfs that use either %lld or %qd as the format.
......
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* or in config.h afterwards. Of course, if you edit config.h, then your * or in config.h afterwards. Of course, if you edit config.h, then your
* changes will be overwritten the next time you run configure. * changes will be overwritten the next time you run configure.
* *
* $Id: config.h.in,v 1.160 2001/03/01 05:05:29 ishii Exp $ * $Id: config.h.in,v 1.161 2001/03/23 18:42:12 tgl Exp $
*/ */
#ifndef CONFIG_H #ifndef CONFIG_H
...@@ -591,6 +591,9 @@ extern int fdatasync(int fildes); ...@@ -591,6 +591,9 @@ extern int fdatasync(int fildes);
/* Set to 1 if type "long long int" works and is 64 bits */ /* Set to 1 if type "long long int" works and is 64 bits */
#undef HAVE_LONG_LONG_INT_64 #undef HAVE_LONG_LONG_INT_64
/* Set to 1 if type "long long int" constants should be suffixed by LL */
#undef HAVE_LL_CONSTANTS
/* Define this as the appropriate snprintf format for 64-bit ints, if any */ /* Define this as the appropriate snprintf format for 64-bit ints, if any */
#undef INT64_FORMAT #undef INT64_FORMAT
......
...@@ -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.2 2001/03/22 04:01:14 momjian Exp $ * $Id: pg_crc.h,v 1.3 2001/03/23 18:42:12 tgl Exp $
*/ */
#ifndef PG_CRC_H #ifndef PG_CRC_H
#define PG_CRC_H #define PG_CRC_H
...@@ -78,16 +78,23 @@ extern const uint32 crc_table1[]; ...@@ -78,16 +78,23 @@ 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 = (uint64) 0xffffffffffffffff) #define INIT_CRC64(crc) ((crc).crc0 = INT64CONST(0xffffffffffffffff))
/* Finish a CRC calculation */ /* Finish a CRC calculation */
#define FIN_CRC64(crc) ((crc).crc0 ^= (uint64) 0xffffffffffffffff) #define FIN_CRC64(crc) ((crc).crc0 ^= INT64CONST(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) \
......
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