1/* 2 --------------------------------------------------------------------------- 3 Copyright (c) 2003, Dr Brian Gladman, Worcester, UK. All rights reserved. 4 5 LICENSE TERMS 6 7 The free distribution and use of this software in both source and binary 8 form is allowed (with or without changes) provided that: 9 10 1. distributions of this source code include the above copyright 11 notice, this list of conditions and the following disclaimer; 12 13 2. distributions in binary form include the above copyright 14 notice, this list of conditions and the following disclaimer 15 in the documentation and/or other associated materials; 16 17 3. the copyright holder's name is not used to endorse products 18 built using this software without specific written permission. 19 20 ALTERNATIVELY, provided that this notice is retained in full, this product 21 may be distributed under the terms of the GNU General Public License (GPL), 22 in which case the provisions of the GPL apply INSTEAD OF those given above. 23 24 DISCLAIMER 25 26 This software is provided 'as is' with no explicit or implied warranties 27 in respect of its properties, including, but not limited to, correctness 28 and/or fitness for purpose. 29 --------------------------------------------------------------------------- 30 Issue 31/01/2006 31*/ 32 33#ifndef EDEFS_H 34#define EDEFS_H 35#if defined(__cplusplus) 36extern "C" 37{ 38#endif 39 40#define IS_LITTLE_ENDIAN 1234 /* byte 0 is least significant (i386) */ 41#define IS_BIG_ENDIAN 4321 /* byte 0 is most significant (mc68k) */ 42 43#if defined(__GNUC__) || defined(__GNU_LIBRARY__) 44# if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) 45# include <sys/endian.h> 46# elif defined( BSD ) && ( BSD >= 199103 ) || defined( __DJGPP__ ) || defined( __CYGWIN32__ ) 47# include <machine/endian.h> 48# elif defined(__APPLE__) 49# if defined(__BIG_ENDIAN__) && !defined( BIG_ENDIAN ) 50# define BIG_ENDIAN 51# elif defined(__LITTLE_ENDIAN__) && !defined( LITTLE_ENDIAN ) 52# define LITTLE_ENDIAN 53# endif 54# elif !defined( __MINGW32__ ) 55# include <endian.h> 56# if !defined(__BEOS__) 57# include <byteswap.h> 58# endif 59# endif 60#endif 61 62#if !defined(PLATFORM_BYTE_ORDER) 63# if defined(LITTLE_ENDIAN) || defined(BIG_ENDIAN) 64# if defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN) 65# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN 66# elif !defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN) 67# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN 68# elif defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN) 69# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN 70# elif defined(BYTE_ORDER) && (BYTE_ORDER == BIG_ENDIAN) 71# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN 72# endif 73# elif defined(_LITTLE_ENDIAN) || defined(_BIG_ENDIAN) 74# if defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN) 75# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN 76# elif !defined(_LITTLE_ENDIAN) && defined(_BIG_ENDIAN) 77# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN 78# elif defined(_BYTE_ORDER) && (_BYTE_ORDER == _LITTLE_ENDIAN) 79# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN 80# elif defined(_BYTE_ORDER) && (_BYTE_ORDER == _BIG_ENDIAN) 81# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN 82# endif 83# elif defined(__LITTLE_ENDIAN__) || defined(__BIG_ENDIAN__) 84# if defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) 85# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN 86# elif !defined(__LITTLE_ENDIAN__) && defined(__BIG_ENDIAN__) 87# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN 88# elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __LITTLE_ENDIAN__) 89# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN 90# elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __BIG_ENDIAN__) 91# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN 92# endif 93# endif 94#endif 95 96/* if the platform is still unknown, try to find its byte order */ 97/* from commonly used machine defines */ 98 99#if !defined(PLATFORM_BYTE_ORDER) 100 101#if defined( __alpha__ ) || defined( __alpha ) || defined( i386 ) || \ 102 defined( __i386__ ) || defined( _M_I86 ) || defined( _M_IX86 ) || \ 103 defined( __OS2__ ) || defined( sun386 ) || defined( __TURBOC__ ) || \ 104 defined( vax ) || defined( vms ) || defined( VMS ) || \ 105 defined( __VMS ) || defined( _M_X64 ) 106# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN 107 108#elif defined( AMIGA ) || defined( applec ) || defined( __AS400__ ) || \ 109 defined( _CRAY ) || defined( __hppa ) || defined( __hp9000 ) || \ 110 defined( ibm370 ) || defined( mc68000 ) || defined( m68k ) || \ 111 defined( __MRC__ ) || defined( __MVS__ ) || defined( __MWERKS__ ) || \ 112 defined( sparc ) || defined( __sparc) || defined( SYMANTEC_C ) || \ 113 defined( __TANDEM ) || defined( THINK_C ) || defined( __VMCMS__ ) || \ 114 defined( __VOS__ ) 115# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN 116 117#elif 0 /* **** EDIT HERE IF NECESSARY **** */ 118# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN 119#elif 0 /* **** EDIT HERE IF NECESSARY **** */ 120# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN 121#else 122# error Please edit edefs.h (lines 117 or 119) to set the platform byte order 123#endif 124 125#endif 126 127#if defined(__cplusplus) 128} 129#endif 130#endif 131