diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-04-06 05:36:51 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-04-06 05:36:51 +0000 |
commit | 37a609b27fcb67c28ff34d02ae3e82cd9903dd13 (patch) | |
tree | 037c29effb24f829edcf52ad172a4c0af0fcc14a /src/backend | |
parent | 3e23b68dac006e8deb0afa327e855258df8de064 (diff) | |
download | postgresql-37a609b27fcb67c28ff34d02ae3e82cd9903dd13.tar.gz postgresql-37a609b27fcb67c28ff34d02ae3e82cd9903dd13.zip |
Now that core functionality is depending on autoconf's AC_C_BIGENDIAN to be
right, there seems precious little reason to have a pile of hand-maintained
endianness definitions in src/include/port/*.h. Get rid of those, and make
the couple of places that used them depend on WORDS_BIGENDIAN instead.
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/libpq/pqformat.c | 51 |
1 files changed, 20 insertions, 31 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; |