4 * Copyright (C) 1998, 1999 D. Hugh Redelmeier.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * RCSID $Id: endian.h,v 1.5 1999/12/13 00:40:51 dhr Exp $
19 /* sets BYTE_ORDER, LITTLE_ENDIAN, and BIG_ENDIAN */
21 #if defined(__OpenBSD__) || defined(__NetBSD__)
22 # include <machine/endian.h>
24 # if defined(i386) && !defined(__i386__)
26 # define MYHACKFORTHIS 1
28 # include_next <endian.h>
29 # ifdef USE_ASM_BYTEORDER /* kernel's <asm/byteorder.h> clashes with glibc's <netinet/in.h> */
30 /* The problem (in RedHat 5.0) is the typing of the "longs" (32-bit values)
31 * in the [nh]to[hn]l functions:
32 * - <asm/byteorder.h> uses unsigned long
33 * - <netinet/in.h> uses u_int32_t which is unsigned int
34 * Since 64-bit machines are supported, <asm/byteorder.h> should be changed.
35 * For now, we simply don't use <asm/byteorder.h>.
37 # include <asm/byteorder.h>
43 #elif !(defined(BIG_ENDIAN) && defined(LITTLE_ENDIAN) && defined(BYTE_ORDER))
44 /* we don't know how to do this, so we require the macros to be defined
45 * with compiler flags:
46 * -DBIG_ENDIAN=4321 -DLITTLE_ENDIAN=1234 -DBYTE_ORDER=BIG_ENDIAN
47 * or -DBIG_ENDIAN=4321 -DLITTLE_ENDIAN=1234 -DBYTE_ORDER=LITTLE_ENDIAN
48 * Thse match the GNU definitions
50 # include <sys/endian.h>
54 #error BIG_ENDIAN must be defined
58 #error LITTLE_ENDIAN must be defined
62 #error BYTE_ORDER must be defined
65 #endif /*__ENDIAN__H__ */