]> rtime.felk.cvut.cz Git - orte.git/commitdiff
Endianness test extended to use "sys/param.h" if available.
authorPavel Pisa <pisa@cmp.felk.cvut.cz>
Thu, 12 Sep 2013 19:42:27 +0000 (21:42 +0200)
committerPavel Pisa <pisa@cmp.felk.cvut.cz>
Thu, 12 Sep 2013 19:42:27 +0000 (21:42 +0200)
The "sys/param.h" file is expected to be more portable.
It should exist on Mac OS X, RTEMS and BSD.

Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
configure.ac
orte/include/orte/orte_config_omk_linux.h

index 4adef0fd69c39bb64d231e2c065362082c19960b..ce6c0a2a9dcee9f7a65cb839cda2cb52129fce1a 100644 (file)
@@ -236,19 +236,38 @@ AC_SUBST(INCLUDES)
 
 ###############################
 # Checks for typedefs, structures, and compiler characteristics.
-need_endian_test=no
-AC_CHECK_HEADERS([endian.h], [], [],[])
+need_endian_test=yes
+AC_CHECK_HEADERS([endian.h sys/param.h], [], [],[])
+
+if test "$ac_cv_header_sys_param_h" == 'yes' ; then
+    AC_MSG_CHECKING([whether BYTE_ORDER defined in sys/param.h])
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/param.h>], [
+                        unsigned int a=BYTE_ORDER;
+                        unsigned int b=BIG_ENDIAN;
+                        unsigned int c=LITTLE_ENDIAN;])],
+                      [AC_MSG_RESULT([yes])
+                       need_endian_test=no],[AC_MSG_RESULT([no])])
+
+    if test "$need_endian_test" == 'yes' ; then
+        AC_MSG_CHECKING([whether __BYTE_ORDER defined in sys/param.h])
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/param.h>], [
+                        unsigned int a=__BYTE_ORDER;
+                        unsigned int b=__BIG_ENDIAN;
+                        unsigned int c=__LITTLE_ENDIAN;])],
+                      [AC_MSG_RESULT([yes])
+                       need_endian_test=no],[AC_MSG_RESULT([no])])
+    fi
+fi
 if test "$ac_cv_header_endian_h" == 'yes' ; then
-    AC_MSG_CHECKING([whether endian can be determined from endian.h])
-    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <endian.h>], [
+    if test "$need_endian_test" == 'yes' ; then
+        AC_MSG_CHECKING([whether endian can be determined from endian.h])
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <endian.h>], [
                         unsigned int a=__BYTE_ORDER;
                         unsigned int b=__BIG_ENDIAN;
                         unsigned int c=__LITTLE_ENDIAN;])],
-                      [AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])
-                      need_endian_test=yes
-                      ])
-else
-  need_endian_test=yes
+                      [AC_MSG_RESULT([yes])
+                       need_endian_test=no],[AC_MSG_RESULT([no])])
+    fi
 fi
 
 if test "$need_endian_test" == 'yes' ; then
@@ -256,14 +275,20 @@ if test "$need_endian_test" == 'yes' ; then
 fi
 
 AH_BOTTOM([
-#ifdef HAVE_ENDIAN_H
-  #include <endian.h>
-  #ifdef __BYTE_ORDER
+#if defined(HAVE_ENDIAN_H) || defined(HAVE_SYS_PARAM_H)
+  #ifdef HAVE_SYS_PARAM_H
+    #include <sys/param.h>
+  #endif
+  #if defined(HAVE_ENDIAN_H) && !defined(BYTE_ORDER) && !defined(__BYTE_ORDER)
+    #include <endian.h>
+  #endif
+  #if defined(__BYTE_ORDER)
     #if __BYTE_ORDER == __BIG_ENDIAN
       #define WORDS_BIGENDIAN 1
     #endif
-    #if __BYTE_ORDER == __LITTLE_ENDIAN
-      #undef WORDS_BIGENDIAN
+  #elif defined(BYTE_ORDER)
+    #if BYTE_ORDER == BIG_ENDIAN
+      #define WORDS_BIGENDIAN 1
     #endif
   #endif
 #endif
index 280afef16569b40d5703d8cbb77890e658539a3b..080641c351627d6dc8009f99f1f61a63dd01a536 100644 (file)
 /* Define to 1 if you have the <sys/ioctl.h> header file. */
 #define HAVE_SYS_IOCTL_H 1
 
+/* Define to 1 if you have the <sys/param.h> header file. */
+#define HAVE_SYS_PARAM_H 1
+
 /* Define to 1 if you have the <sys/socket.h> header file. */
 #define HAVE_SYS_SOCKET_H 1
 
 #endif
 
 
-#ifdef HAVE_ENDIAN_H
-  #include <endian.h>
-  #ifdef __BYTE_ORDER
+#if defined(HAVE_ENDIAN_H) || defined(HAVE_SYS_PARAM_H)
+  #ifdef HAVE_SYS_PARAM_H
+    #include <sys/param.h>
+  #endif
+  #if defined(HAVE_ENDIAN_H) && !defined(BYTE_ORDER) && !defined(__BYTE_ORDER)
+    #include <endian.h>
+  #endif
+  #if defined(__BYTE_ORDER)
     #if __BYTE_ORDER == __BIG_ENDIAN
       #define WORDS_BIGENDIAN 1
     #endif
-    #if __BYTE_ORDER == __LITTLE_ENDIAN
-      #undef WORDS_BIGENDIAN
+  #elif defined(BYTE_ORDER)
+    #if BYTE_ORDER == BIG_ENDIAN
+      #define WORDS_BIGENDIAN 1
     #endif
   #endif
 #endif