1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-24 14:22:24 +03:00

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.
This commit is contained in:
Tom Lane
2007-04-06 05:36:51 +00:00
parent 3e23b68dac
commit 37a609b27f
22 changed files with 66 additions and 295 deletions

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -1,5 +1,2 @@
#define CLASS_CONFLICT
#define DISABLE_XOPEN_NLS
#include <sys/machine.h> /* ENDIAN definitions for network
* communication */

View File

@ -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 */

View File

@ -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 */

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -1,6 +1,3 @@
#ifndef BYTE_ORDER
#ifdef MIPSEB
#define BYTE_ORDER BIG_ENDIAN
#endif
/* $PostgreSQL */
#endif
/* nothing needed */

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"