1 /* @(#)btorder.h 1.22 12/12/03 Copyright 1996-2012 J. Schilling */
3 * Definitions for Bit and Byte ordering
5 * Copyright (c) 1996-2012 J. Schilling
8 * The contents of this file are subject to the terms of the
9 * Common Development and Distribution License, Version 1.0 only
10 * (the "License"). You may not use this file except in compliance
13 * See the file CDDL.Schily.txt in this distribution for details.
15 * When distributing Covered Code, include this CDDL HEADER in each
16 * file and include the License file CDDL.Schily.txt from this distribution.
20 #ifndef _SCHILY_BTORDER_H
21 #define _SCHILY_BTORDER_H
23 #ifndef _SCHILY_MCONFIG_H
24 #include <schily/mconfig.h> /* load bit/byte-oder from xmconfig.h */
27 #ifndef _SCHILY_TYPES_H
28 #include <schily/types.h> /* try to load isa_defs.h on Solaris */
36 * Convert bit-order definitions from xconfig.h into our values
39 #if defined(HAVE_C_BITFIELDS) && \
40 defined(BITFIELDS_LTOH)
41 #define _BIT_FIELDS_LTOH
44 #if defined(HAVE_C_BITFIELDS) && \
45 defined(BITFIELDS_HTOL)
46 #define _BIT_FIELDS_HTOL
49 #if defined(HAVE_C_BITFIELDS) && \
50 !defined(BITFIELDS_HTOL)
51 #define BITFIELDS_LTOH
52 #define _BIT_FIELDS_LTOH
55 #if defined(_BIT_FIELDS_LTOH) && defined(_BIT_FIELDS_HTOL)
57 * #error will not work for all compilers (e.g. sunos4)
58 * The following line will abort compilation on all compilers
59 * if none of the above is defined. And that's what we want.
61 error Only one of _BIT_FIELDS_LTOH
or _BIT_FIELDS_HTOL may be defined
63 #include <schily/err_bit.h> /* Avoid "unknown directive" with K&R */
68 * Convert byte-order definitions from xconfig.h into our values
70 * Note that we cannot use the definitions _LITTLE_ENDIAN and _BIG_ENDIAN
71 * because they are used on IRIX-6.5 with different meaning.
73 #if defined(HAVE_C_BIGENDIAN) && \
74 !defined(WORDS_BIGENDIAN)
75 #define WORDS_LITTLEENDIAN
76 /* #define _LITTLE_ENDIAN */
79 #if defined(HAVE_C_BIGENDIAN) && \
80 defined(WORDS_BIGENDIAN)
81 #undef WORDS_LITTLEENDIAN
82 /* #define _BIG_ENDIAN */
85 #if defined(_BIT_FIELDS_LTOH) || defined(_BIT_FIELDS_HTOL)
87 * Bitorder is already known.
91 * Bitorder not yet known.
93 # if defined(sun3) || defined(mc68000) || \
94 defined(sun4) || defined(__sparc) || defined(sparc) || \
95 defined(__hppa) || defined(_ARCH_PPC) || defined(_IBMR2)
96 # define _BIT_FIELDS_HTOL
99 # if defined(__sgi) && defined(__mips)
100 # define _BIT_FIELDS_HTOL
103 # if defined(__i386__) || defined(__i386) || defined(i386) || \
104 defined(__alpha__) || defined(__alpha) || defined(alpha) || \
105 defined(__arm__) || defined(__arm) || defined(arm)
106 # define _BIT_FIELDS_LTOH
109 # if defined(__ppc__) || defined(ppc) || defined(__ppc) || \
110 defined(__PPC) || defined(powerpc) || defined(__powerpc__)
112 # if defined(__BIG_ENDIAN__)
113 # define _BIT_FIELDS_HTOL
115 # define _BIT_FIELDS_LTOH
124 #endif /* _SCHILY_BTORDER_H */