| 1 |
/*
|
| 2 |
* This file has been modified for the cdrkit suite.
|
| 3 |
*
|
| 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).
|
| 6 |
*
|
| 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.
|
| 10 |
*
|
| 11 |
*/
|
| 12 |
|
| 13 |
/* @(#)btorder.h 1.16 03/06/15 Copyright 1996 J. Schilling */
|
| 14 |
/*
|
| 15 |
* Definitions for Bit and Byte ordering
|
| 16 |
*
|
| 17 |
* Copyright (c) 1996 J. Schilling
|
| 18 |
*/
|
| 19 |
/*
|
| 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.
|
| 23 |
*
|
| 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.
|
| 28 |
*
|
| 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.
|
| 32 |
*/
|
| 33 |
|
| 34 |
|
| 35 |
#ifndef _BTORDER_H
|
| 36 |
#define _BTORDER_H
|
| 37 |
|
| 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
|
| 41 |
#endif
|
| 42 |
|
| 43 |
#ifndef _MCONFIG_H
|
| 44 |
#include <mconfig.h> /* load bit/byte-oder from xmconfig.h*/
|
| 45 |
#endif
|
| 46 |
|
| 47 |
/*
|
| 48 |
* Convert bit-order definitions from xconfig.h into our values
|
| 49 |
* and verify them.
|
| 50 |
*/
|
| 51 |
#if defined(HAVE_C_BITFIELDS) && \
|
| 52 |
defined(BITFIELDS_LTOH)
|
| 53 |
#define _BIT_FIELDS_LTOH
|
| 54 |
#endif
|
| 55 |
|
| 56 |
#if defined(HAVE_C_BITFIELDS) && \
|
| 57 |
defined(BITFIELDS_HTOL)
|
| 58 |
#define _BIT_FIELDS_HTOL
|
| 59 |
#endif
|
| 60 |
|
| 61 |
#if defined(HAVE_C_BITFIELDS) && \
|
| 62 |
!defined(BITFIELDS_HTOL)
|
| 63 |
#define BITFIELDS_LTOH
|
| 64 |
#define _BIT_FIELDS_LTOH
|
| 65 |
#endif
|
| 66 |
|
| 67 |
#if defined(_BIT_FIELDS_LTOH) && defined(_BIT_FIELDS_HTOL)
|
| 68 |
/*
|
| 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.
|
| 72 |
*/
|
| 73 |
error Only one of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL may be defined
|
| 74 |
#endif
|
| 75 |
|
| 76 |
|
| 77 |
/*
|
| 78 |
* Convert byte-order definitions from xconfig.h into our values
|
| 79 |
* and verify them.
|
| 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.
|
| 82 |
*/
|
| 83 |
#if defined(HAVE_C_BIGENDIAN) && \
|
| 84 |
!defined(WORDS_BIGENDIAN)
|
| 85 |
#define WORDS_LITTLEENDIAN
|
| 86 |
/*#define _LITTLE_ENDIAN*/
|
| 87 |
#endif
|
| 88 |
|
| 89 |
#if defined(HAVE_C_BIGENDIAN) && \
|
| 90 |
defined(WORDS_BIGENDIAN)
|
| 91 |
#undef WORDS_LITTLEENDIAN
|
| 92 |
/*#define _BIG_ENDIAN*/
|
| 93 |
#endif
|
| 94 |
|
| 95 |
#if defined(_BIT_FIELDS_LTOH) || defined(_BIT_FIELDS_HTOL)
|
| 96 |
/*
|
| 97 |
* Bitorder is already known.
|
| 98 |
*/
|
| 99 |
#else
|
| 100 |
/*
|
| 101 |
* Bitorder not yet known.
|
| 102 |
*/
|
| 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
|
| 107 |
# endif
|
| 108 |
|
| 109 |
# if defined(__sgi) && defined(__mips)
|
| 110 |
# define _BIT_FIELDS_HTOL
|
| 111 |
# endif
|
| 112 |
|
| 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
|
| 117 |
# endif
|
| 118 |
|
| 119 |
# if defined(__ppc__) || defined(ppc) || defined(__ppc) || \
|
| 120 |
defined(__PPC) || defined(powerpc) || defined(__powerpc__)
|
| 121 |
|
| 122 |
# if defined(__BIG_ENDIAN__)
|
| 123 |
# define _BIT_FIELDS_HTOL
|
| 124 |
# else
|
| 125 |
# define _BIT_FIELDS_LTOH
|
| 126 |
# endif
|
| 127 |
# endif
|
| 128 |
#endif
|
| 129 |
|
| 130 |
#endif /* _BTORDER_H */
|