From 3c7f9e7ba496617a356b19a21e9917c44558c1db Mon Sep 17 00:00:00 2001 From: ehofman Date: Mon, 1 Dec 2003 18:57:32 +0000 Subject: [PATCH] A first attempt on detecting endianness and number of bits --- simgear/nasal/Makefile.am | 2 ++ simgear/nasal/nasal.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/simgear/nasal/Makefile.am b/simgear/nasal/Makefile.am index 8fbfe561..ce1cfe40 100644 --- a/simgear/nasal/Makefile.am +++ b/simgear/nasal/Makefile.am @@ -17,3 +17,5 @@ libsgnasal_a_SOURCES = \ parse.c \ string.c \ vector.c + +INCLUDES = -I$(top_srcdir) diff --git a/simgear/nasal/nasal.h b/simgear/nasal/nasal.h index 57b0372d..da10dabd 100644 --- a/simgear/nasal/nasal.h +++ b/simgear/nasal/nasal.h @@ -4,6 +4,39 @@ extern "C" { #endif +#ifndef BYTE_ORDER + +# if (BSD >= 199103) +# include +# elif defined(__CYGWIN__) || defined(__MINGW32__) +# include +# elif defined(linux) +# include +# else +# ifndef LITTLE_ENDIAN +# define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ +# endif +# ifndef BIG_ENDIAN +# define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ +# endif + +# if defined(ultrix) || defined(__alpha__) || defined(__alpha) || \ + defined(__i386__) || defined(__i486__) || defined(_X86_) || \ + defined(sun386) +# define BYTE_ORDER LITTLE_ENDIAN +# else +# define BYTE_ORDER BIG_ENDIAN +# endif +# endif /* BSD */ +#endif /* BYTE_ORDER */ + +#if BYTE_ORDER == BIG_ENDIAN +# include +# if (LONG_MAX == 2147483647) +# define NASAL_BIG_ENDIAN_32_BIT 1 +# endif +#endif + // This is a nasal "reference". They are always copied by value, and // contain either a pointer to a garbage-collectable nasal object // (string, vector, hash) or a floating point number. Keeping the -- 2.39.2