diff --git a/config/ompi_setup_cc.m4 b/config/ompi_setup_cc.m4 index 40340fc7a7..cace63c866 100644 --- a/config/ompi_setup_cc.m4 +++ b/config/ompi_setup_cc.m4 @@ -37,10 +37,6 @@ BASECC="`basename $CC`" CFLAGS="$ompi_cflags_save" AC_DEFINE_UNQUOTED(OMPI_CC, "$CC", [OMPI underlying C compiler]) -# When building OMPI, we need this everywhere - -CPPFLAGS="$CPPFLAGS -DOMPI_BUILDING=1" - # Check for compilers that impersonate gcc AC_MSG_CHECKING([for compilers that impersonate gcc]) diff --git a/configure.ac b/configure.ac index 83c67e05d8..acf5a1376c 100644 --- a/configure.ac +++ b/configure.ac @@ -1176,11 +1176,7 @@ AC_DEFINE_UNQUOTED(ompi_fortran_dblprec_t, $MPI_FORTRAN_DBLPREC_TYPE, MPI_OFFSET_TYPE="not found" MPI_OFFSET_DATATYPE="not found" AC_MSG_CHECKING([checking for type of MPI_Offset]) -if test "$ac_cv_type_int64_t" = "yes"; then - MPI_OFFSET_TYPE=int64_t - # Need to figure out MPI_OFFSET_DATATYPE below - MPI_OFFSET_SIZE=8 -elif test "$ac_cv_type_long_long" = "yes" -a "$ac_cv_sizeof_long_long" = 8; then +if test "$ac_cv_type_long_long" = "yes" -a "$ac_cv_sizeof_long_long" = 8; then MPI_OFFSET_TYPE="long long" MPI_OFFSET_DATATYPE=MPI_LONG_LONG MPI_OFFSET_SIZE=8 @@ -1192,10 +1188,6 @@ elif test "ac_cv_sizeof_int" = 8; then MPI_OFFSET_TYPE=int MPI_OFFSET_DATATYPE=MPI_INT MPI_OFFSET_SIZE=8 -elif test "$ac_cv_type_int32_t" = "yes"; then - MPI_OFFSET_TYPE=int32_t - # Need to figure out MPI_OFFSET_DATATYPE below - MPI_OFFSET_SIZE=4 elif test "$ac_cv_type_long_long" = "yes" -a "$ac_cv_sizeof_long_long" = 4; then MPI_OFFSET_TYPE="long long" MPI_OFFSET_DATATYPE=MPI_LONG_LONG @@ -1218,30 +1210,9 @@ AC_DEFINE_UNQUOTED(MPI_Offset, $MPI_OFFSET_TYPE, [Type of MPI_Offset]) # # If we haven't already, figure out an MPI datatype that corresponds -# to the back-end C type of MPI_Offset. We'll only not have figured -# this out already if the type of MPI_Offset is int32_t or int64_t. +# to the back-end C type of MPI_Offset. # - AC_MSG_CHECKING([checking for an MPI datatype for MPI_Offset]) -if test "$MPI_OFFSET_DATATYPE" = "not found"; then - if test "$MPI_OFFSET_TYPE" = "int64_t"; then - if test "$ac_cv_type_long_long" = "yes" -a "$ac_cv_sizeof_long_long" = 8; then - MPI_OFFSET_DATATYPE=MPI_LONG_LONG - elif test "$ac_cv_type_long" = "yes" -a "$ac_cv_sizeof_long" = 8; then - MPI_OFFSET_DATATYPE=MPI_LONG - elif test "ac_cv_sizeof_int" = 8; then - MPI_OFFSET_DATATYPE=MPI_INT - fi - elif test "$MPI_OFFSET_TYPE" = "int32_t"; then - if test "$ac_cv_type_long_long" = "yes" -a "$ac_cv_sizeof_long_long" = 4; then - MPI_OFFSET_DATATYPE=MPI_LONG_LONG - elif test "$ac_cv_type_long" = "yes" -a "$ac_cv_sizeof_long" = 4; then - MPI_OFFSET_DATATYPE=MPI_LONG - elif test "ac_cv_sizeof_int" = 4; then - MPI_OFFSET_DATATYPE=MPI_INT - fi - fi -fi AC_MSG_RESULT([$MPI_OFFSET_DATATYPE]) if test "$MPI_OFFSET_DATATYPE" = "not found"; then AC_MSG_WARN([*** Unable to find an MPI datatype corresponding to MPI_Offset]) diff --git a/include/mpi.h b/include/mpi.h index 8f67fe157f..36bda981d2 100644 --- a/include/mpi.h +++ b/include/mpi.h @@ -17,6 +17,16 @@ #ifndef OMPI_MPI_H #define OMPI_MPI_H +/* + * Turn off OMPI_BUILDING if we were included before ompi_config.h, + * which should happen whenever an MPI application is involved. This + * will turn off most of the includes / compatibility code in + * ompi_config_bottom.h, giving the user an expected experience. + */ +#ifndef OMPI_BUILDING +#define OMPI_BUILDING 0 +#endif + #include "ompi_config.h" /* @@ -34,7 +44,7 @@ * To accomodate programs written for MPI implementations that use a * straight ROMIO import */ -#if !defined(OMPI_BUILDING) || !OMPI_BUILDING +#if !OMPI_BUILDING #define MPIO_Request MPI_Request #define MPIO_Test MPI_Test #define MPIO_Wait MPI_Wait @@ -1636,12 +1646,10 @@ OMPI_DECLSPEC double PMPI_Wtime(void); * - We are using a C++ compiler */ -#if defined(OMPI_WANT_CXX_BINDINGS) -#if !defined(OMPI_BUILDING) || !OMPI_BUILDING +#if defined(OMPI_WANT_CXX_BINDINGS) && !OMPI_BUILDING #if defined(__cplusplus) || defined(c_plusplus) #include "mpi/cxx/mpicxx.h" #endif #endif -#endif #endif /* OMPI_MPI_H */ diff --git a/include/ompi_config_bottom.h b/include/ompi_config_bottom.h index 732246de70..0143ef261d 100644 --- a/include/ompi_config_bottom.h +++ b/include/ompi_config_bottom.h @@ -22,42 +22,82 @@ * need to #ifndef/#endif protection here. */ -#ifndef OMPI_CONFIG_BOTTOM_H -#define OMPI_CONFIG_BOTTOM_H - -#if defined(WIN32) && defined(OMPI_BUILDING) && OMPI_BUILDING -#include "win32/win_compat.h" -#define OMPI_COMP_EXPORT __declspec(dllexport) +#ifndef OMPI_CONFIG_H +#error "ompi_config_bottom.h should only be included from ompi_config.h" #endif -#if defined(WIN32) -# if defined(OMPI_BUILDING) -# if OMPI_BUILDING -# define OMPI_DECLSPEC __declspec(dllexport) -# else -# define OMPI_DECLSPEC __declspec(dllimport) -# endif -# endif -# ifndef OMPI_DECLSPEC - /* this is for the applications. here WIN32 is defined, but no OMPI_BUILDING */ -# define OMPI_DECLSPEC __declspec(dllimport) -# endif +/* + * OMPI_BUILDING will be true whenever ompi_config.h is included in a + * file that is "internal" to Open MPI, meaning something that is + * below the MPI layer. It will be false whenever we should provide + * the most "untampered" environment possible. The user is free to + * override this before including either mpi.h or ompi_config.h, if so + * desired. + */ +#ifndef OMPI_BUILDING +#define OMPI_BUILDING 1 #endif -#ifndef OMPI_DECLSPEC -#define OMPI_DECLSPEC +/*********************************************************************** + * + * code that should be in ompi_config_bottom.h regardless of build + * status + * + **********************************************************************/ + +/* Do we have thread support? */ +#define OMPI_HAVE_THREAD_SUPPORT (OMPI_ENABLE_MPI_THREADS || OMPI_ENABLE_PROGRESS_THREADS) + +/* * C type for Fortran COMPLEX */ +typedef struct { + ompi_fortran_real_t real; + ompi_fortran_real_t imag; +} ompi_fortran_complex_t; + + +/* * C type for Fortran DOUBLE COMPLEX */ +typedef struct { + ompi_fortran_dblprec_t real; + ompi_fortran_dblprec_t imag; +} ompi_fortran_dblcomplex_t; + + +/*********************************************************************** + * + * Windows library interface declaration code + * + **********************************************************************/ + +#if defined(WIN32) +# if OMPI_BUILDING +# include "win32/win_compat.h" +# define OMPI_COMP_EXPORT __declspec(dllexport) +# define OMPI_DECLSPEC __declspec(dllexport) +# else +# define OMPI_COMP_EXPORT +# define OMPI_DECLSPEC __declspec(dllimport) +# endif +#else +# define OMPI_COMP_EXPORT +# define OMPI_DECLSPEC #endif -#ifndef OMPI_COMP_EXPORT -#define OMPI_COMP_EXPORT -#endif + +/*********************************************************************** + * + * Code that is only for when building Open MPI or utilities that are + * using the internals of Open MPI. It should not be included when + * building MPI applicatiosn + * + **********************************************************************/ +#if OMPI_BUILDING /* * If we're in C, we may need to bring in the bool type and true/false * constants. OMPI_NEED_C_BOOL will be true if the compiler either * needs or doesn't define the bool type at all. */ -#if !defined(__cplusplus) && defined(OMPI_BUILDING) +#if !defined(__cplusplus) # if OMPI_NEED_C_BOOL # if OMPI_USE_STDBOOL_H /* If we're using , there is an implicit @@ -103,11 +143,6 @@ typedef long long bool; #define OMPI_PATH_MAX 256 #endif -/* - * Do we have thread support? - */ -#define OMPI_HAVE_THREAD_SUPPORT (OMPI_ENABLE_MPI_THREADS || OMPI_ENABLE_PROGRESS_THREADS) - /* * Do we have ? */ @@ -135,10 +170,10 @@ typedef long long bool; * So for 1, everyone must include first. For 2, the * C++ bindings will never include -- they will only * include , which includes , but after - * OMPI_MPI_H is defined. For 3, it's the same as 1 -- just include + * setting OMPI_BUILDING to 0 For 3, it's the same as 1 -- just include * first. */ -#if OMPI_ENABLE_MEM_DEBUG && defined(OMPI_BUILDING) && OMPI_BUILDING && !defined(OMPI_MPI_H) +#if OMPI_ENABLE_MEM_DEBUG /* It is safe to include util/malloc.h here because a) it will only happen when we are building OMPI and therefore have a full OMPI @@ -173,29 +208,10 @@ typedef long long bool; #endif -/* - * C type for Fortran COMPLEX - */ -typedef struct { - ompi_fortran_real_t real; - ompi_fortran_real_t imag; -} ompi_fortran_complex_t; - - -/* - * C type for Fortran DOUBLE COMPLEX - */ -typedef struct { - ompi_fortran_dblprec_t real; - ompi_fortran_dblprec_t imag; -} ompi_fortran_dblcomplex_t; - /* * printf functions for portability (only when building Open MPI) */ - -#if defined(OMPI_BUILDING) && OMPI_BUILDING #if !defined(HAVE_VASPRINTF) || !defined(HAVE_VSNPRINTF) #include #include @@ -220,7 +236,6 @@ typedef struct { #ifndef HAVE_VSNPRINTF # define vsnprintf ompi_vsnprintf #endif -#endif /* * Define __func__-preprocessor directive if the compiler does not @@ -229,9 +244,8 @@ typedef struct { * coming from (assuming that __func__ is typically used for * printf-style debugging). */ - -#if defined(OMPI_BUILDING) && OMPI_BUILDING && defined(HAVE_DECL___FUNC__) && !HAVE_DECL___FUNC__ +#if defined(HAVE_DECL___FUNC__) && !HAVE_DECL___FUNC__ #define __func__ __FILE__ #endif -#endif /* OMPI_CONFIG_BOTTOM_H */ +#endif /* OMPI_BUILDING */ diff --git a/src/mca/io/romio/romio-dist/adio/common/Makefile.am b/src/mca/io/romio/romio-dist/adio/common/Makefile.am index 6254cfb8a6..0f6a74e03b 100644 --- a/src/mca/io/romio/romio-dist/adio/common/Makefile.am +++ b/src/mca/io/romio/romio-dist/adio/common/Makefile.am @@ -17,6 +17,7 @@ include $(top_ompi_srcdir)/config/Makefile.options AM_CPPFLAGS = \ + -DOMPI_BUILDING=1 \ -I$(top_ompi_builddir)/include \ -I$(top_ompi_srcdir)/src \ -I$(top_ompi_srcdir)/src/include \ diff --git a/test/asm/atomic_barrier.c b/test/asm/atomic_barrier.c index 47bdd16807..9c8f656f31 100644 --- a/test/asm/atomic_barrier.c +++ b/test/asm/atomic_barrier.c @@ -14,7 +14,7 @@ * $HEADER$ */ -#undef OMPI_BUILDING +#define OMPI_BUILDING 0 #include "ompi_config.h" #include "include/sys/atomic.h" diff --git a/test/asm/atomic_cmpset.c b/test/asm/atomic_cmpset.c index b684c067fc..6ee851cb65 100644 --- a/test/asm/atomic_cmpset.c +++ b/test/asm/atomic_cmpset.c @@ -14,7 +14,7 @@ * $HEADER$ */ -#undef OMPI_BUILDING +#define OMPI_BUILDING 0 #include "ompi_config.h" #undef NDEBUG diff --git a/test/asm/atomic_math.c b/test/asm/atomic_math.c index fffb63917a..aadd555b49 100644 --- a/test/asm/atomic_math.c +++ b/test/asm/atomic_math.c @@ -14,7 +14,7 @@ * $HEADER$ */ -#undef OMPI_BUILDING +#define OMPI_BUILDING 0 #include "ompi_config.h" #ifdef HAVE_PTHREAD_H diff --git a/test/asm/atomic_spinlock.c b/test/asm/atomic_spinlock.c index 00ccff9be3..2754e09b8b 100644 --- a/test/asm/atomic_spinlock.c +++ b/test/asm/atomic_spinlock.c @@ -14,7 +14,7 @@ * $HEADER$ */ -#undef OMPI_BUILDING +#define OMPI_BUILDING 0 #include "ompi_config.h" #ifdef HAVE_PTHREAD_H