[MOAB-dev] r3258 - in MOAB/trunk: m4 parallel

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Mon Nov 2 16:08:52 CST 2009


Author: kraftche
Date: 2009-11-02 16:08:52 -0600 (Mon, 02 Nov 2009)
New Revision: 3258

Added:
   MOAB/trunk/m4/macro_val.m4
Modified:
   MOAB/trunk/m4/mpi.m4
   MOAB/trunk/parallel/MBmpi.h
   MOAB/trunk/parallel/MBmpi_config.h.in
Log:
In the case where MPICH_IGNORE_CXX_SEEK is not sufficient to enable inclusion
of mpi.h in c++ code w/out conflicting with C stdio headers, fix the
undef/redef code such that SEEK_SET and friends are set to numeric values
detected by the configure script.



Added: MOAB/trunk/m4/macro_val.m4
===================================================================
--- MOAB/trunk/m4/macro_val.m4	                        (rev 0)
+++ MOAB/trunk/m4/macro_val.m4	2009-11-02 22:08:52 UTC (rev 3258)
@@ -0,0 +1,38 @@
+# Macro to determine the unsigned integer value of a 
+# preprocessor macro.  Arguments are:
+#   header, macro, variable, upper bound
+# where 'header' is the header in which the macro value
+# is defined, 'macro' is the name of the preprocessor macro
+# for which the value is to be determined, 'variable' is the
+# name of the shell variable in which to store the value,
+# and 'upper bound' is the largest value up to which to search
+AC_DEFUN([FATHOM_MACRO_VALUE],[
+  header="$1"
+  macro="$2"
+  upper="$4"
+  lower="0"
+  while test "$lower" -lt "$upper"; do
+    curr=$(( ($lower + $upper)/2 ))
+    AC_PREPROC_IFELSE(
+      [AC_LANG_PROGRAM([#include <${header}>
+                        #if $macro >= $curr
+                        # error choke me
+                        #endif],[])],
+      [upper=$curr],
+      [AC_PREPROC_IFELSE(
+        [AC_LANG_PROGRAM([#include <${header}>
+                          #if $macro < $curr
+                          # error choke me
+                          #endif],[])],
+        [break],
+        [lower=$curr])])
+  done
+  AC_PREPROC_IFELSE(
+    [AC_LANG_PROGRAM([#include <${header}>
+                      #if $curr != $macro
+                      # error choke me
+                      #endif],[])],
+    [$3=$curr],
+    [AC_MSG_ERROR([Unable to determine value of $macro defined in $header])])
+])
+

Modified: MOAB/trunk/m4/mpi.m4
===================================================================
--- MOAB/trunk/m4/mpi.m4	2009-11-02 22:06:12 UTC (rev 3257)
+++ MOAB/trunk/m4/mpi.m4	2009-11-02 22:08:52 UTC (rev 3258)
@@ -57,7 +57,24 @@
                           #define MPICH_IGNORE_CXX_SEEK
                           #include <mpi.h>],[])],
         [MPI_CXX_HELP_NEEDED=no; AC_MSG_RESULT([MPICH_IGNORE_CXX_SEEK])],
-        [MPI_CXX_HELP_NEEDED=yes; AC_MSG_RESULT([yes])])
+        [MPI_CXX_HELP_NEEDED=yes
+         AC_MSG_RESULT([yes])
+
+         AC_MSG_CHECKING([value of SEEK_SET])
+         FATHOM_MACRO_VALUE([stdio.h],[SEEK_SET],[SEEK_SET],[16])
+         AC_MSG_RESULT([$SEEK_SET])
+         AC_DEFINE_UNQUOTED([MB_SEEK_SET],[$SEEK_SET],["Value of C SEEK_SET"])
+
+         AC_MSG_CHECKING([value of SEEK_CUR])
+         FATHOM_MACRO_VALUE([stdio.h],[SEEK_CUR],[SEEK_CUR],[16])
+         AC_MSG_RESULT([$SEEK_CUR])
+         AC_DEFINE_UNQUOTED([MB_SEEK_CUR],[$SEEK_CUR],["Value of C SEEK_CUR"])
+
+         AC_MSG_CHECKING([value of SEEK_END])
+         FATHOM_MACRO_VALUE([stdio.h],[SEEK_END],[SEEK_END],[16])
+         AC_MSG_RESULT([$SEEK_END])
+         AC_DEFINE_UNQUOTED([MB_SEEK_END],[$SEEK_END],["Value of C SEEK_END"])
+       ])
     ])
     AC_LANG_POP([C++])
   fi

Modified: MOAB/trunk/parallel/MBmpi.h
===================================================================
--- MOAB/trunk/parallel/MBmpi.h	2009-11-02 22:06:12 UTC (rev 3257)
+++ MOAB/trunk/parallel/MBmpi.h	2009-11-02 22:08:52 UTC (rev 3258)
@@ -13,21 +13,35 @@
 #else
 #  include <stdio.h>
 #  ifdef SEEK_SET
-#    define MB_SEEK_SET SEEK_SET
-#    define MB_SEEK_CUR SEEK_CUR
-#    define MB_SEEK_END SEEK_END
 #    undef SEEK_SET
+#    ifdef MB_SEEK_SET
+#      define MB_RESTORE_SEEK_SET
+#    endif
+#  endif
+#  ifdef SEEK_CUR
 #    undef SEEK_CUR
+#    ifdef MB_SEEK_CUR
+#      define MB_RESTORE_SEEK_CUR
+#    endif
+#  endif
+#  ifdef SEEK_END
 #    undef SEEK_END
+#    ifdef MB_SEEK_END
+#      define MB_RESTORE_SEEK_END
+#    endif
 #  endif
 #  include <mpi.h>
-#  ifdef MB_SEEK_SET
+#  ifdef MB_RESTORE_SEEK_SET
+#    undef MB_RESTORE_SEEK_SET
 #    define SEEK_SET MB_SEEK_SET
+#  endif
+#  ifdef MB_RESTORE_SEEK_CUR
+#    undef MB_RESTORE_SEEK_CUR
 #    define SEEK_CUR MB_SEEK_CUR
+#  endif
+#  ifdef MB_RESTORE_SEEK_END
+#    undef MB_RESTORE_SEEK_END
 #    define SEEK_END MB_SEEK_END
-#    undef MB_SEEK_SET
-#    undef MB_SEEK_CUR
-#    undef MB_SEEK_END
 #  endif
 #endif
 

Modified: MOAB/trunk/parallel/MBmpi_config.h.in
===================================================================
--- MOAB/trunk/parallel/MBmpi_config.h.in	2009-11-02 22:06:12 UTC (rev 3257)
+++ MOAB/trunk/parallel/MBmpi_config.h.in	2009-11-02 22:08:52 UTC (rev 3258)
@@ -1,2 +1,11 @@
 /* MPICH_IGNORE_CXX_SEEK is not sufficient to avoid conflicts */
 #undef MB_MPI_CXX_CONFLICT
+
+/* "Value of C SEEK_CUR" */
+#undef MB_SEEK_CUR
+
+/* "Value of C SEEK_END" */
+#undef MB_SEEK_END
+
+/* "Value of C SEEK_SET" */
+#undef MB_SEEK_SET



More information about the moab-dev mailing list