*/
/* Machine endianness */
-#define XDR 0
-#define NDR 1
+#define XDR 0 /* big endian */
+#define NDR 1 /* little endian */
extern char getMachineEndian(void);
/* Raise an lwerror if srids do not match */
#include "liblwgeom_internal.h"
#include "lwgeom_log.h"
-#include <sys/param.h>
/**
* Used for passing the parse state between the parsing functions.
/* Check the endianness of our input */
s->swap_bytes = LW_FALSE;
- if( BYTE_ORDER == LITTLE_ENDIAN ) /* Machine arch is little */
+ if( getMachineEndian() == NDR ) /* Machine arch is little */
{
if ( ! wkb_little_endian ) /* Data is big! */
s->swap_bytes = LW_TRUE;
#include "liblwgeom_internal.h"
#include "lwgeom_log.h"
-#include <sys/param.h>
static uint8_t* lwgeom_to_wkb_buf(const LWGEOM *geom, uint8_t *buf, uint8_t variant);
static size_t lwgeom_to_wkb_size(const LWGEOM *geom, uint8_t variant);
static inline int wkb_swap_bytes(uint8_t variant)
{
/* If requested variant matches machine arch, we don't have to swap! */
- if ( ((variant & WKB_NDR) && (BYTE_ORDER == LITTLE_ENDIAN)) ||
- ((! (variant & WKB_NDR)) && (BYTE_ORDER == BIG_ENDIAN)) )
+ if ( ((variant & WKB_NDR) && (getMachineEndian() == NDR)) ||
+ ((! (variant & WKB_NDR)) && (getMachineEndian() == XDR)) )
{
return LW_FALSE;
}
if ( ! (variant & WKB_NDR || variant & WKB_XDR) ||
(variant & WKB_NDR && variant & WKB_XDR) )
{
- if ( BYTE_ORDER == LITTLE_ENDIAN )
+ if ( getMachineEndian() == NDR )
variant = variant | WKB_NDR;
else
variant = variant | WKB_XDR;
static int endian_check_int = 1; /* dont modify this!!! */
return *((char *) &endian_check_int); /* 0 = big endian | xdr,
- * 1 = little endian | ndr
- */
+ * 1 = little endian | ndr
+ */
}