2 * This file has been modified for the cdrkit suite.
4 * The behaviour and appearence of the program code below can differ to a major
5 * extent from the version distributed by the original author(s).
7 * For details, see Changelog file distributed with the cdrkit package. If you
8 * received this file from another source then ask the distributing person for
9 * a log of modifications.
13 /* @(#)btorder.h 1.16 03/06/15 Copyright 1996 J. Schilling */
15 * Definitions for Bit and Byte ordering
17 * Copyright (c) 1996 J. Schilling
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License version 2
22 * as published by the Free Software Foundation.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License along with
30 * this program; see the file COPYING. If not, write to the Free Software
31 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
38 #ifndef _INCL_SYS_TYPES_H
39 #include <sys/types.h> /* try to load isa_defs.h on Solaris */
40 #define _INCL_SYS_TYPES_H
44 #include <mconfig.h> /* load bit/byte-oder from xmconfig.h*/
48 * Convert bit-order definitions from xconfig.h into our values
51 #if defined(HAVE_C_BITFIELDS) && \
52 defined(BITFIELDS_LTOH)
53 #define _BIT_FIELDS_LTOH
56 #if defined(HAVE_C_BITFIELDS) && \
57 defined(BITFIELDS_HTOL)
58 #define _BIT_FIELDS_HTOL
61 #if defined(HAVE_C_BITFIELDS) && \
62 !defined(BITFIELDS_HTOL)
63 #define BITFIELDS_LTOH
64 #define _BIT_FIELDS_LTOH
67 #if defined(_BIT_FIELDS_LTOH) && defined(_BIT_FIELDS_HTOL)
69 * #error will not work for all compilers (e.g. sunos4)
70 * The following line will abort compilation on all compilers
71 * if none of the above is defines. And that's what we want.
73 error Only one of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL may be defined
78 * Convert byte-order definitions from xconfig.h into our values
80 * Note that we cannot use the definitions _LITTLE_ENDIAN and _BIG_ENDIAN
81 * because they are used on IRIX-6.5 with different meaning.
83 #if defined(HAVE_C_BIGENDIAN) && \
84 !defined(WORDS_BIGENDIAN)
85 #define WORDS_LITTLEENDIAN
86 /*#define _LITTLE_ENDIAN*/
89 #if defined(HAVE_C_BIGENDIAN) && \
90 defined(WORDS_BIGENDIAN)
91 #undef WORDS_LITTLEENDIAN
92 /*#define _BIG_ENDIAN*/
95 #if defined(_BIT_FIELDS_LTOH) || defined(_BIT_FIELDS_HTOL)
97 * Bitorder is already known.
101 * Bitorder not yet known.
103 # if defined(sun3) || defined(mc68000) || \
104 defined(sun4) || defined(__sparc) || defined(sparc) || \
105 defined(__hppa) || defined(_ARCH_PPC) || defined(_IBMR2)
106 # define _BIT_FIELDS_HTOL
109 # if defined(__sgi) && defined(__mips)
110 # define _BIT_FIELDS_HTOL
113 # if defined(__i386__) || defined(__i386) || defined(i386) || \
114 defined(__alpha__) || defined(__alpha) || defined(alpha) || \
115 defined(__arm__) || defined(__arm) || defined(arm)
116 # define _BIT_FIELDS_LTOH
119 # if defined(__ppc__) || defined(ppc) || defined(__ppc) || \
120 defined(__PPC) || defined(powerpc) || defined(__powerpc__)
122 # if defined(__BIG_ENDIAN__)
123 # define _BIT_FIELDS_HTOL
125 # define _BIT_FIELDS_LTOH
130 #endif /* _BTORDER_H */