diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/libpq/pqformat.c | 51 | ||||
-rw-r--r-- | src/include/pg_config.h.in | 3 | ||||
-rw-r--r-- | src/include/pg_config.h.win32 | 3 | ||||
-rw-r--r-- | src/include/port/aix.h | 3 | ||||
-rw-r--r-- | src/include/port/dgux.h | 16 | ||||
-rw-r--r-- | src/include/port/hpux.h | 28 | ||||
-rw-r--r-- | src/include/port/sco.h | 14 | ||||
-rw-r--r-- | src/include/port/solaris.h | 24 | ||||
-rw-r--r-- | src/include/port/sunos4.h | 14 | ||||
-rw-r--r-- | src/include/port/svr4.h | 7 | ||||
-rw-r--r-- | src/include/port/ultrix4.h | 13 | ||||
-rw-r--r-- | src/include/port/univel.h | 14 | ||||
-rw-r--r-- | src/include/port/unixware.h | 14 | ||||
-rw-r--r-- | src/include/port/win32.h | 16 |
14 files changed, 28 insertions, 192 deletions
diff --git a/src/backend/libpq/pqformat.c b/src/backend/libpq/pqformat.c index c81dfa5b227..606bb14a698 100644 --- a/src/backend/libpq/pqformat.c +++ b/src/backend/libpq/pqformat.c @@ -24,7 +24,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/libpq/pqformat.c,v 1.44 2007/02/27 23:48:07 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/libpq/pqformat.c,v 1.45 2007/04/06 05:36:50 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -72,9 +72,6 @@ #include <sys/param.h> #include <netinet/in.h> #include <arpa/inet.h> -#ifdef HAVE_ENDIAN_H -#include <endian.h> -#endif #include "libpq/libpq.h" #include "libpq/pqformat.h" @@ -312,20 +309,16 @@ pq_sendfloat8(StringInfo buf, float8 f) swap.h[0] = htonl(swap.h[0]); swap.h[1] = htonl(swap.h[1]); - /* Have to figure out endianness by testing... */ - if (((uint32) 1) == htonl((uint32) 1)) - { - /* 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); - } +#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; @@ -549,21 +542,17 @@ pq_getmsgfloat8(StringInfo msg) uint32 h[2]; } swap; - /* Have to figure out endianness by testing... */ - if (((uint32) 1) == htonl((uint32) 1)) - { - /* 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); - } - return swap.f; +#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; diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index 35c1be6f9c1..b76dcd874f8 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -115,9 +115,6 @@ /* Define to 1 if you have the <editline/readline.h> header file. */ #undef HAVE_EDITLINE_READLINE_H -/* Define to 1 if you have the <endian.h> header file. */ -#undef HAVE_ENDIAN_H - /* Define to 1 if you have the `fcvt' function. */ #undef HAVE_FCVT diff --git a/src/include/pg_config.h.win32 b/src/include/pg_config.h.win32 index 9f3c1ac8699..a8f489d91d0 100644 --- a/src/include/pg_config.h.win32 +++ b/src/include/pg_config.h.win32 @@ -107,9 +107,6 @@ /* Define to 1 if you have the <editline/readline.h> header file. */ /* #undef HAVE_EDITLINE_READLINE_H */ -/* Define to 1 if you have the <endian.h> header file. */ -/* #undef HAVE_ENDIAN_H */ - /* Define to 1 if you have the `fcvt' function. */ #define HAVE_FCVT 1 diff --git a/src/include/port/aix.h b/src/include/port/aix.h index 0fde5763b87..5ce3d29a113 100644 --- a/src/include/port/aix.h +++ b/src/include/port/aix.h @@ -1,5 +1,2 @@ #define CLASS_CONFLICT #define DISABLE_XOPEN_NLS - -#include <sys/machine.h> /* ENDIAN definitions for network - * communication */ diff --git a/src/include/port/dgux.h b/src/include/port/dgux.h index 73096530f28..43ccbbbe531 100644 --- a/src/include/port/dgux.h +++ b/src/include/port/dgux.h @@ -1,15 +1,3 @@ -/* $PostgreSQL: pgsql/src/include/port/dgux.h,v 1.10 2006/03/11 04:38:38 momjian Exp $ */ +/* $PostgreSQL: pgsql/src/include/port/dgux.h,v 1.11 2007/04/06 05:36:51 tgl Exp $ */ -#ifndef BIG_ENDIAN -#define BIG_ENDIAN 4321 -#endif -#ifndef LITTLE_ENDIAN -#define LITTLE_ENDIAN 1234 -#endif -#ifndef PDP_ENDIAN -#define PDP_ENDIAN 3412 -#endif -#ifndef BYTE_ORDER -#define BYTE_ORDER BIG_ENDIAN - -#endif +/* nothing needed */ diff --git a/src/include/port/hpux.h b/src/include/port/hpux.h index 6c8cdeb2fb7..dc48e6dc143 100644 --- a/src/include/port/hpux.h +++ b/src/include/port/hpux.h @@ -1,27 +1,3 @@ -/* $PostgreSQL: pgsql/src/include/port/hpux.h,v 1.23 2006/03/11 04:38:38 momjian Exp $ */ +/* $PostgreSQL: pgsql/src/include/port/hpux.h,v 1.24 2007/04/06 05:36:51 tgl Exp $ */ -#ifndef BIG_ENDIAN -#define BIG_ENDIAN 4321 -#endif -#ifndef LITTLE_ENDIAN -#define LITTLE_ENDIAN 1234 -#endif -#ifndef PDP_ENDIAN -#define PDP_ENDIAN 3412 -#endif - -#if defined(__hppa) - -#ifndef BYTE_ORDER -#define BYTE_ORDER BIG_ENDIAN -#endif -#elif defined(__ia64) - -/* HPUX runs IA64 in big-endian mode */ -#ifndef BYTE_ORDER -#define BYTE_ORDER BIG_ENDIAN -#endif -#else -#error unrecognized CPU type for HP-UX - -#endif +/* nothing needed */ diff --git a/src/include/port/sco.h b/src/include/port/sco.h index b4e975c89d0..2f05116d3e1 100644 --- a/src/include/port/sco.h +++ b/src/include/port/sco.h @@ -2,17 +2,3 @@ #define SCO_ACCEPT_BUG #define USE_UNIVEL_CC - -#ifndef BIG_ENDIAN -#define BIG_ENDIAN 4321 -#endif -#ifndef LITTLE_ENDIAN -#define LITTLE_ENDIAN 1234 -#endif -#ifndef PDP_ENDIAN -#define PDP_ENDIAN 3412 -#endif -#ifndef BYTE_ORDER -#define BYTE_ORDER LITTLE_ENDIAN - -#endif diff --git a/src/include/port/solaris.h b/src/include/port/solaris.h index e13af401e36..3fd0fdbbdc0 100644 --- a/src/include/port/solaris.h +++ b/src/include/port/solaris.h @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/include/port/solaris.h,v 1.15 2007/01/10 18:22:50 tgl Exp $ */ +/* $PostgreSQL: pgsql/src/include/port/solaris.h,v 1.16 2007/04/06 05:36:51 tgl Exp $ */ /* * Sort this out for all operating systems some time. The __xxx @@ -25,28 +25,6 @@ #include <sys/isa_defs.h> #endif -#ifndef BIG_ENDIAN -#define BIG_ENDIAN 4321 -#endif -#ifndef LITTLE_ENDIAN -#define LITTLE_ENDIAN 1234 -#endif -#ifndef PDP_ENDIAN -#define PDP_ENDIAN 3412 -#endif - -#ifndef BYTE_ORDER -#ifdef __sparc__ -#define BYTE_ORDER BIG_ENDIAN -#endif -#ifdef __i386__ -#define BYTE_ORDER LITTLE_ENDIAN -#endif -#if defined(__amd64___) || defined(__x86_64__) -#define BYTE_ORDER LITTLE_ENDIAN -#endif -#endif - /* * Many versions of Solaris have broken strtod() --- see bug #4751182. * This has been fixed in current versions of Solaris: diff --git a/src/include/port/sunos4.h b/src/include/port/sunos4.h index f7545fc6fae..48fdbffb91c 100644 --- a/src/include/port/sunos4.h +++ b/src/include/port/sunos4.h @@ -1,16 +1,2 @@ /* sprintf() returns char *, not int, on SunOS 4.1.x */ #define SPRINTF_CHAR - -#ifndef BIG_ENDIAN -#define BIG_ENDIAN 4321 -#endif -#ifndef LITTLE_ENDIAN -#define LITTLE_ENDIAN 1234 -#endif -#ifndef PDP_ENDIAN -#define PDP_ENDIAN 3412 -#endif -#ifndef BYTE_ORDER -#define BYTE_ORDER BIG_ENDIAN - -#endif diff --git a/src/include/port/svr4.h b/src/include/port/svr4.h index 2c38612c4d8..7366299b8a2 100644 --- a/src/include/port/svr4.h +++ b/src/include/port/svr4.h @@ -1,6 +1,3 @@ -#ifndef BYTE_ORDER -#ifdef MIPSEB -#define BYTE_ORDER BIG_ENDIAN -#endif +/* $PostgreSQL */ -#endif +/* nothing needed */ diff --git a/src/include/port/ultrix4.h b/src/include/port/ultrix4.h index c199afcbea5..7df0abc34dc 100644 --- a/src/include/port/ultrix4.h +++ b/src/include/port/ultrix4.h @@ -1,19 +1,6 @@ #define NOFIXADE #define NEED_STRDUP -#ifndef BIG_ENDIAN -#define BIG_ENDIAN 4321 -#endif -#ifndef LITTLE_ENDIAN -#define LITTLE_ENDIAN 1234 -#endif -#ifndef PDP_ENDIAN -#define PDP_ENDIAN 3412 -#endif -#ifndef BYTE_ORDER -#define BYTE_ORDER LITTLE_ENDIAN -#endif - /* * Except for those system calls and library functions that are either * - covered by the C standard library and Posix.1 diff --git a/src/include/port/univel.h b/src/include/port/univel.h index d94e7f263b6..ca054166d19 100644 --- a/src/include/port/univel.h +++ b/src/include/port/univel.h @@ -3,17 +3,3 @@ * the native UNIXWARE C compiler. ***************************************/ #define USE_UNIVEL_CC - -#ifndef BIG_ENDIAN -#define BIG_ENDIAN 4321 -#endif -#ifndef LITTLE_ENDIAN -#define LITTLE_ENDIAN 1234 -#endif -#ifndef PDP_ENDIAN -#define PDP_ENDIAN 3412 -#endif -#ifndef BYTE_ORDER -#define BYTE_ORDER LITTLE_ENDIAN - -#endif diff --git a/src/include/port/unixware.h b/src/include/port/unixware.h index aef47166981..6cddddac2e0 100644 --- a/src/include/port/unixware.h +++ b/src/include/port/unixware.h @@ -6,17 +6,3 @@ * the native UNIXWARE C compiler. ***************************************/ #define USE_UNIVEL_CC - -#ifndef BIG_ENDIAN -#define BIG_ENDIAN 4321 -#endif -#ifndef LITTLE_ENDIAN -#define LITTLE_ENDIAN 1234 -#endif -#ifndef PDP_ENDIAN -#define PDP_ENDIAN 3412 -#endif -#ifndef BYTE_ORDER -#define BYTE_ORDER LITTLE_ENDIAN - -#endif diff --git a/src/include/port/win32.h b/src/include/port/win32.h index 96eaa57cf6a..fcf995ef8c0 100644 --- a/src/include/port/win32.h +++ b/src/include/port/win32.h @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.73 2007/03/23 08:30:55 mha Exp $ */ +/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.74 2007/04/06 05:36:51 tgl Exp $ */ #if defined(_MSC_VER) || defined(__BORLANDC__) #define WIN32_ONLY_COMPILER @@ -299,20 +299,6 @@ typedef unsigned short mode_t; #define isinf(x) ((_fpclass(x) == _FPCLASS_PINF) || (_fpclass(x) == _FPCLASS_NINF)) #define isnan(x) _isnan(x) -#ifndef BIG_ENDIAN -#define BIG_ENDIAN 4321 -#endif -#ifndef LITTLE_ENDIAN -#define LITTLE_ENDIAN 1234 -#endif -#ifndef PDP_ENDIAN -#define PDP_ENDIAN 3412 -#endif - -#ifndef BYTE_ORDER -#define BYTE_ORDER LITTLE_ENDIAN -#endif - /* Pulled from Makefile.port in mingw */ #define DLSUFFIX ".dll" |