Revision: 1864
http://sourceforge.net/p/r-gregmisc/code/1864
Author: warnes
Date: 2014-07-21 16:28:35 +0000 (Mon, 21 Jul 2014)
Log Message:
-----------
Use conditional compilation to map-out byte-swapping code on bigendian systems, where it is not needed.
Modified Paths:
--------------
trunk/SASxport/src/to_bigend.h
Modified: trunk/SASxport/src/to_bigend.h
===================================================================
--- trunk/SASxport/src/to_bigend.h 2014-07-21 16:23:28 UTC (rev 1863)
+++ trunk/SASxport/src/to_bigend.h 2014-07-21 16:28:35 UTC (rev 1864)
@@ -18,11 +18,22 @@
void to_bigend( unsigned char *intp, size_t size);
-/* Convert (if necessary) to Big-Endian */
-#define TO_BIGEND_SHORT(a) to_bigend( (unsigned char*) &a, sizeof(short) )
-#define TO_BIGEND_INT(a) to_bigend( (unsigned char*) &a, sizeof(int) )
-#define TO_BIGEND_DOUBLE(a) to_bigend( (unsigned char*) &a, sizeof(double) )
+#ifdef WORDS_BIGENDIAN
+ /* This is a big-endian system, so conversion is NOOP
+# define TO_BIGEND_SHORT(a) ( a )
+# define TO_BIGEND_INT(a) ( a )
+# define TO_BIGEND_DOUBLE(a) ( a )
+
+#else
+
+ /* We're on little-endian so use to_bigend to convert
+# define TO_BIGEND_SHORT(a) to_bigend( (unsigned char*) &a, sizeof(short) )
+# define TO_BIGEND_INT(a) to_bigend( (unsigned char*) &a, sizeof(int) )
+# define TO_BIGEND_DOUBLE(a) to_bigend( (unsigned char*) &a, sizeof(double) )
+
+#endif /* WORDS_BIGENDIAN */
+
/* Alternative definition using system functions: */
/* #define TO_BIGEND_SHORT(a) (a) = htons( a ) */
/* #define TO_BIGEND_INT(a) (a) = htonl( a ) */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|