[GRASS-dev] [bug #5391] (grass) Add dual-arch static copy of portable.h

this bug's URL: http://intevation.de/rt/webrt?serial_num=5391
-------------------------------------------------------------------------

Subject: Add dual-arch static copy of portable.h

Platform: Mac OSX
grass obtained from: CVS
grass binary for platform: Compiled from Sources
GRASS Version: 6.3.CVS.20061202

Another one for building Mac OS X universal binaries. lib/vector/diglib/portable.h for universal OS
X. I've simply taken a Pac PPC and Intel copy and merged them together. The correct version is
chosen by a #ifdef based on a Mac standard __LITTLE_ENDIAN__ macro. This will work in an all-at-
once universal build (specifying ppc and intel architectures on the same compile command) since
internally they are compiled separately, then joined, and so headers are processed for each arch.

I didn't work out makefile changes, but it would be something like the MINGW ifdef in the diglib
makefile. This would also need a platform.make setting to say it's a Mac build, and configure logic
to set it.

suggested lib/vector/diglib/portable/universal-macosx-gcc.h to be copied to portable.h at build
time:

/* Architecture: universal-apple-darwin */

/* Native machine sizes */
#define NATIVE_DOUBLE 8
#define NATIVE_FLOAT 4
#define NATIVE_LONG 4
#define NATIVE_INT 4
#define NATIVE_SHORT 2
#define NATIVE_CHAR 1

#ifdef __LITTLE_ENDIAN__

/* Native machine byte orders */
#define DOUBLE_ORDER 0
#define FLOAT_ORDER 0
#define LONG_ORDER 0
#define INT_ORDER 0
#define SHORT_ORDER 0

/* Translation matrices from little endian to native */

/* Double format: */
static int dbl_cnvrt = {7, 6, 5, 4, 3, 2, 1, 0};

/* Float format : */
static int flt_cnvrt = {3, 2, 1, 0};

/* Long format : */
static int lng_cnvrt = {3, 2, 1, 0};

/* Int format : */
static int int_cnvrt = {3, 2, 1, 0};

/* Short format : */
static int shrt_cnvrt = {1, 0};

#else

/* Native machine byte orders */
#define DOUBLE_ORDER 1
#define FLOAT_ORDER 1
#define LONG_ORDER 1
#define INT_ORDER 1
#define SHORT_ORDER 1

/* Translation matrices from big endian to native */

/* Double format: */
static int dbl_cnvrt = {0, 1, 2, 3, 4, 5, 6, 7};

/* Float format : */
static int flt_cnvrt = {0, 1, 2, 3};

/* Long format : */
static int lng_cnvrt = {0, 1, 2, 3};

/* Int format : */
static int int_cnvrt = {0, 1, 2, 3};

/* Short format : */
static int shrt_cnvrt = {0, 1};

#endif

-------------------------------------------- Managed by Request Tracker