Implement MPI::SEEK_{SET, END, POS} for the C++ bindings, working around
some issues with the C #defines SEEK_{SET, END, POS}. The workaround involves some hackery that should work in almost every common use case for the C stdio constants (and all the legal issues of the MPI constants). The one issue is that the C stdio constants are now const ints instead of #defines, which means that #ifdef checks will fail for the constants. Behavior can be disabled at either configure time or build time. Refs trac:387 This commit was SVN r12121. The following Trac tickets were found above: Ticket 387 --> https://svn.open-mpi.org/trac/ompi/ticket/387
Этот коммит содержится в:
родитель
9adde4f7b8
Коммит
e7a7a64e4c
@ -259,6 +259,19 @@ else
|
||||
WANT_MPI_CXX_SUPPORT=0
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([if want MPI::SEEK_SET support])
|
||||
AC_ARG_ENABLE([mpi-cxx-seek],
|
||||
[AC_HELP_STRING([--enable-mpi-cxx-seek],
|
||||
[enable support for MPI::SEEK_SET, MPI::SEEK_END, and MPI::SEEK_POS in C++ bindings (default: enabled)])])
|
||||
if test "$enable_mpi_cxx_seek" != "no" ; then
|
||||
AC_MSG_RESULT([yes])
|
||||
OMPI_WANT_MPI_CXX_SEEK=1
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
OMPI_WANT_MPI_CXX_SEEK=0
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED([OMPI_WANT_MPI_CXX_SEEK], [$OMPI_WANT_MPI_CXX_SEEK],
|
||||
[do we want to try to work around C++ bindings SEEK_* issue?])
|
||||
|
||||
#
|
||||
# Do we want to disable weak symbols for some reason?
|
||||
|
@ -74,6 +74,9 @@
|
||||
/* Whether we want MPI cxx support or not */
|
||||
#undef OMPI_WANT_CXX_BINDINGS
|
||||
|
||||
/* do we want to try to work around C++ bindings SEEK_* issue? */
|
||||
#undef OMPI_WANT_MPI_CXX_SEEK
|
||||
|
||||
/* Whether a const_cast on a 2-d array will work with the C++ compiler */
|
||||
#undef OMPI_CXX_SUPPORTS_2D_CONST_CAST
|
||||
|
||||
|
@ -249,6 +249,12 @@ OMPI_DECLSPEC extern const int MODE_SEQUENTIAL;
|
||||
|
||||
OMPI_DECLSPEC extern const int DISPLACEMENT_CURRENT;
|
||||
|
||||
#if !defined(OMPI_IGNORE_CXX_SEEK) && OMPI_WANT_MPI_CXX_SEEK
|
||||
OMPI_DECLSPEC extern const int SEEK_SET;
|
||||
OMPI_DECLSPEC extern const int SEEK_CUR;
|
||||
OMPI_DECLSPEC extern const int SEEK_END;
|
||||
#endif
|
||||
|
||||
OMPI_DECLSPEC extern const int MAX_DATAREP_STRING;
|
||||
|
||||
// one-sided constants
|
||||
|
@ -18,8 +18,20 @@
|
||||
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
static const int ompi_stdio_seek_set = SEEK_SET;
|
||||
static const int ompi_stdio_seek_cur = SEEK_CUR;
|
||||
static const int ompi_stdio_seek_end = SEEK_END;
|
||||
|
||||
#include "mpicxx.h"
|
||||
|
||||
#if OMPI_WANT_MPI_CXX_SEEK
|
||||
|
||||
const int SEEK_SET = ompi_stdio_seek_set;
|
||||
const int SEEK_CUR = ompi_stdio_seek_cur;
|
||||
const int SEEK_END = ompi_stdio_seek_end;
|
||||
#endif
|
||||
|
||||
namespace MPI {
|
||||
|
||||
#if ! OMPI_HAVE_CXX_EXCEPTION_SUPPORT
|
||||
@ -259,6 +271,12 @@ const int MODE_SEQUENTIAL = MPI_MODE_SEQUENTIAL;
|
||||
|
||||
const int DISPLACEMENT_CURRENT = MPI_DISPLACEMENT_CURRENT;
|
||||
|
||||
#if OMPI_WANT_MPI_CXX_SEEK
|
||||
const int SEEK_SET = MPI_SEEK_SET;
|
||||
const int SEEK_CUR = MPI_SEEK_CUR;
|
||||
const int SEEK_END = MPI_SEEK_END;
|
||||
#endif
|
||||
|
||||
const int MAX_DATAREP_STRING = MPI_MAX_DATAREP_STRING;
|
||||
|
||||
// one-sided constants
|
||||
|
@ -36,6 +36,23 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#if !defined(OMPI_IGNORE_CXX_SEEK) & OMPI_WANT_MPI_CXX_SEEK
|
||||
// include so that we can smash SEEK_* properly
|
||||
#include <stdio.h>
|
||||
|
||||
// smash SEEK_* #defines
|
||||
#ifdef SEEK_SET
|
||||
#undef SEEK_SET
|
||||
#undef SEEK_CUR
|
||||
#undef SEEK_END
|
||||
#endif
|
||||
|
||||
// make globally scoped constants to replace smashed #defines
|
||||
extern const int SEEK_SET;
|
||||
extern const int SEEK_CUR;
|
||||
extern const int SEEK_END;
|
||||
#endif
|
||||
|
||||
// forward declare so that we can still do inlining
|
||||
struct opal_mutex_t;
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user