#if !defined( _endian_h )
#define _endian_h

#if defined( __cplusplus )
extern "C" {
#endif

/* This defaults to a run time endian test.  You can define BIG_ENDIAN
   or LITTLE_ENDIAN appropriately to speed things up.

   LITTLE_ENDIAN is the broken one: 80x86s, VAXs
   BIG_ENDIAN is: most unix machines, RISC chips, 68000, etc

   The endianess is stored in macros:

         little_endian
   and   big_endian

   These boolean values can be checked in your code in C expressions.

   They should NOT be tested with conditional macro statements (#ifdef
   etc). use BIG_ENDIAN and LITTLE_ENDIAN for this, if they are defined.

   Careful use should ensure the compiler compiles out code where
   possible
*/

#if defined( BIG_ENDIAN )
   #define little_endian 0
#elif defined( LITTLE_ENDIAN )
   #define little_endian 1
#else
   #define little_endian ( (* (long*) "\1\0\0\0" ) == 1 )
#endif

#define big_endian ( ! little_endian )

void swap_endian16( void*, int );
void swap_endian32( void*, int );

#define make_big_endian32( data, len ) \
    ( little_endian ? swap_endian32( data, len ) : 0 )

#define make_big_endian16( data, len ) \
    ( little_endian ? swap_endian16( data, len ) : 0 )

#define BURN( x, n ) memset( x, '\0', n )

#if defined( __cplusplus )
}
#endif

#endif
