Index: /branches/eam_branches/Ohana.20100606/src/libohana/Makefile
===================================================================
--- /branches/eam_branches/Ohana.20100606/src/libohana/Makefile	(revision 28234)
+++ /branches/eam_branches/Ohana.20100606/src/libohana/Makefile	(revision 28235)
@@ -1,5 +1,5 @@
 default: install
 help:
-	@echo "make options: install libohana clean dist"
+	@echo "make options: install libohana clean dist test typetest"
 
 include ../../Makefile.System
@@ -19,5 +19,5 @@
 TFLAGS        = $(FULL_CFLAGS) $(FULL_CPPFLAGS) $(FULL_LDFLAGS) -lohana -ltap_ohana
 
-install: $(DESTLIB)/libohana.a $(DESTLIB)/libohana.$(DLLTYPE)
+install: $(DESTLIB)/libohana.a $(DESTLIB)/libohana.$(DLLTYPE) typetest
 libohana: $(LIB)/libohana.$(ARCH).a $(LIB)/libohana.$(ARCH).$(DLLTYPE)
 
@@ -40,4 +40,12 @@
 $(SRC)/CommOps.$(ARCH).o	 \
 $(SRC)/version.$(ARCH).o
+
+TYPETEST = \
+$(TESTDIR)/typetest.$(ARCH)
+
+$(TYPETEST) : $(LIB)/libohana.$(ARCH).a
+
+typetest: $(TYPETEST)
+	for i in $(TYPETEST); do $$i || exit 1; done
 
 TEST = \
Index: /branches/eam_branches/Ohana.20100606/src/libohana/include/ohana.h
===================================================================
--- /branches/eam_branches/Ohana.20100606/src/libohana/include/ohana.h	(revision 28234)
+++ /branches/eam_branches/Ohana.20100606/src/libohana/include/ohana.h	(revision 28235)
@@ -94,4 +94,31 @@
 };
 
+/* note: in the Ohana tree, the byte order is determined by the ARCH variable
+   if you have a small endian machine that is not listed here, the test
+   program 'typestest' should fail */
+# ifndef BYTE_SWAP
+# ifdef linux
+# define BYTE_SWAP
+# endif
+
+# ifdef lin64
+# define BYTE_SWAP
+# endif
+
+# ifdef sid
+# define BYTE_SWAP
+# endif
+
+# ifdef darwin_x86
+# define BYTE_SWAP
+# endif
+
+# ifdef dec
+# define BYTE_SWAP
+# endif
+# else
+# define NOT_BYTE_SWAP
+# endif /* BYTE_SWAP */
+
 # ifndef NAN
 # ifndef BYTE_SWAP
@@ -103,4 +130,19 @@
     __attribute_used__ = { __nan_bytes };
 # define NAN    (__nan_union.__d)
+# endif
+
+/* if your build crashes on OFF_T_MODE, you probably need to add your 64bit hardware to this list */
+# ifdef _LARGEFILE_SOURCE
+# define OFF_T_FMT "%jd"
+# endif
+# ifdef lin64
+# define OFF_T_FMT "%jd"
+# endif
+# ifndef OFF_T_FMT
+# define OFF_T_FMT "%ld"
+# endif
+
+# ifndef isfinite
+# define isfinite(A) (!isnan(A))
 # endif
 
Index: /branches/eam_branches/Ohana.20100606/src/libohana/test/typetest.c
===================================================================
--- /branches/eam_branches/Ohana.20100606/src/libohana/test/typetest.c	(revision 28235)
+++ /branches/eam_branches/Ohana.20100606/src/libohana/test/typetest.c	(revision 28235)
@@ -0,0 +1,73 @@
+# include "ohana.h"
+
+enum
+{
+    OHANA_LITTLE_ENDIAN = 0x03020100ul,
+    OHANA_BIG_ENDIAN    = 0x00010203ul,
+};
+
+static const union { 
+    unsigned char bytes[4]; 
+    int value; 
+} ohana_host_order = { { 0, 1, 2, 3 } };
+
+# define OHANA_HOST_ORDER (ohana_host_order.value)
+
+// we need to verify some type-related issues:
+int main (int argc, char **argv) {
+
+    int status;
+
+    status = 0;
+
+    // 1) have we defined BYTE_SWAP correctly?
+
+# ifdef BYTE_SWAP
+    if (OHANA_HOST_ORDER == OHANA_BIG_ENDIAN) {
+	fprintf (stderr, "ERROR: BYTE_SWAP is defined on a big endian machine\n");
+	fprintf (stderr, "(see libohana/include/ohana.h)\n");
+	status = 1;
+    } else {
+	fprintf (stderr, "BYTE_SWAP is small endian\n");
+    }	
+# else
+    if (OHANA_HOST_ORDER == OHANA_BIG_ENDIAN) {
+	fprintf (stderr, "NOT_BYTE_SWAP is big endian\n");
+    } else {
+	fprintf (stderr, "ERROR: BYTE_SWAP not defined on a small endian machine\n");
+	fprintf (stderr, "(see libohana/include/ohana.h)\n");
+	status = 1;
+    }	
+# endif 
+
+    // 2) have we defined NAN correctly?
+    {
+	float fvalue;
+	double dvalue;
+    
+	fvalue = NAN;
+	dvalue = NAN;
+
+	if (isfinite(fvalue)) {
+	    fprintf (stderr, "ERROR: NAN definition fails for float\n");
+	    fprintf (stderr, "fvalue: %e\n", fvalue);
+	    status = 1;
+	}
+	if (isfinite(dvalue)) {
+	    fprintf (stderr, "ERROR: NAN definition fails for double\n");
+	    fprintf (stderr, "dvalue: %e\n", dvalue);
+	    status = 1;
+	}
+
+	fprintf (stderr, "fvalue: %e (isfinite: %d)\n", fvalue, isfinite(fvalue));
+	fprintf (stderr, "dvalue: %e (isfinite: %d)\n", dvalue, isfinite(dvalue));
+
+# ifdef __STDC_VERSION__
+	fprintf (stderr, "STDC_VERSION: %ld\n", __STDC_VERSION__);
+# else
+	fprintf (stderr, "STDC_VERSION is not set\n");
+# endif
+
+    }
+    exit (status);
+}
