Fix for bug 736 -- added sizeof/alignment for C++ and Fortran types
This commit was SVN r784.
Этот коммит содержится в:
родитель
fd9994a31d
Коммит
0b2313082c
@ -8,6 +8,7 @@ dnl
|
||||
# LAM/MPI-specific tests
|
||||
#
|
||||
|
||||
sinclude(config/c_get_alignment.m4)
|
||||
sinclude(config/c_weak_symbols.m4)
|
||||
|
||||
sinclude(config/cxx_find_template_parameters.m4)
|
||||
@ -16,6 +17,8 @@ sinclude(config/cxx_have_exceptions.m4)
|
||||
sinclude(config/cxx_find_exception_flags.m4)
|
||||
|
||||
sinclude(config/f77_find_ext_symbol_convention.m4)
|
||||
sinclude(config/f77_get_alignment.m4)
|
||||
sinclude(config/f77_get_sizeof.m4)
|
||||
|
||||
sinclude(config/lam_case_sensitive_fs_setup.m4)
|
||||
sinclude(config/lam_check_optflags.m4)
|
||||
@ -23,7 +26,6 @@ sinclude(config/lam_config_subdir.m4)
|
||||
sinclude(config/lam_config_subdir_args.m4)
|
||||
sinclude(config/lam_configure_options.m4)
|
||||
sinclude(config/lam_functions.m4)
|
||||
sinclude(config/lam_get_sizeof_fortran_type.m4)
|
||||
sinclude(config/lam_get_version.m4)
|
||||
sinclude(config/lam_get_libtool_linker_flags.m4)
|
||||
sinclude(config/lam_mca.m4)
|
||||
|
@ -6,12 +6,15 @@
|
||||
include $(top_srcdir)/config/Makefile.options
|
||||
|
||||
EXTRA_DIST = \
|
||||
c_get_alignment.m4 \
|
||||
c_weak_symbols.m4 \
|
||||
cxx_find_template_parameters.m4 \
|
||||
cxx_find_template_repository.m4 \
|
||||
cxx_find_exception_flags.m4 \
|
||||
cxx_have_exceptions.m4 \
|
||||
f77_find_ext_symbol_convention.m4 \
|
||||
f77_get_alignment.m4 \
|
||||
f77_get_sizeof.m4 \
|
||||
lam_case_sensitive_fs_setup.m4 \
|
||||
lam_check_optflags.m4 \
|
||||
lam_check_pthread_pids.m4 \
|
||||
@ -22,7 +25,6 @@ EXTRA_DIST = \
|
||||
lam_config_threads.m4 \
|
||||
lam_configure_options.m4 \
|
||||
lam_functions.m4 \
|
||||
lam_get_sizeof_fortran_type.m4 \
|
||||
lam_get_version.m4 \
|
||||
lam_get_version.sh \
|
||||
lam_mca.m4 \
|
||||
|
38
config/c_get_alignment.m4
Обычный файл
38
config/c_get_alignment.m4
Обычный файл
@ -0,0 +1,38 @@
|
||||
dnl -*- shell-script -*-
|
||||
dnl
|
||||
dnl $HEADER$
|
||||
dnl
|
||||
|
||||
AC_DEFUN([LAM_C_GET_ALIGNMENT],[
|
||||
# Determine datatype alignment.
|
||||
# First arg is type, 2nd arg is config var to define.
|
||||
AC_MSG_CHECKING([alignment of $1])
|
||||
AC_TRY_RUN([
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
struct foo { char c; $1 x; };
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
struct foo *p = (struct foo *) malloc(sizeof(struct foo));
|
||||
int diff;
|
||||
FILE *f=fopen("conftestval", "w");
|
||||
if (!f) exit(1);
|
||||
diff = ((char *)&p->x) - ((char *)&p->c);
|
||||
fprintf(f, "%d\n", (diff >= 0) ? diff : -diff);
|
||||
return 0;
|
||||
}],[lam_ac_align=`cat conftestval`],[lam_ac_align=-1],[lam_ac_align=-1])
|
||||
|
||||
if test "`expr $lam_ac_align \<= 0`" = "1"; then
|
||||
AC_MSG_WARN([*** Problem running configure test!])
|
||||
AC_MSG_WARN([*** See config.log for details.])
|
||||
AC_MSG_ERROR([*** Cannot continue.])
|
||||
fi
|
||||
|
||||
AC_MSG_RESULT([$lam_ac_align])
|
||||
AC_DEFINE_UNQUOTED($2, $lam_ac_align, [Alignment of type $1])
|
||||
eval "$2=$lam_ac_align"
|
||||
unset lam_ac_align
|
||||
|
||||
/bin/rm -f conftest*])dnl
|
@ -1,118 +0,0 @@
|
||||
dnl -*- shell-script -*-
|
||||
dnl
|
||||
dnl Copyright (c) 2001-2002 The Trustees of Indiana University.
|
||||
dnl All rights reserved.
|
||||
dnl Copyright (c) 1998-2001 University of Notre Dame.
|
||||
dnl All rights reserved.
|
||||
dnl Copyright (c) 1994-1998 The Ohio State University.
|
||||
dnl All rights reserved.
|
||||
dnl
|
||||
dnl This file is part of the LAM/MPI software package. For license
|
||||
dnl information, see the LICENSE file in the top level directory of the
|
||||
dnl LAM/MPI source distribution.
|
||||
dnl
|
||||
dnl $Id: lam_get_sizeof_fortran_type.m4,v 1.1 2004/01/16 22:16:25 pkambadu Exp $
|
||||
dnl
|
||||
|
||||
define(LAM_GET_SIZEOF_FORTRAN_TYPE,[
|
||||
# Determine FORTRAN datatype size.
|
||||
# First arg is type, 2nd (optional) arg is config var to define.
|
||||
AC_MSG_CHECKING([size of FORTRAN $1])
|
||||
lam_ac_size_fn=
|
||||
if test "x$lam_ac_doubleunder" = xy || test "x$lam_ac_singleunder" = xy; then
|
||||
lam_ac_size_fn=size_
|
||||
else
|
||||
if test "x$lam_ac_nounder" = xy; then
|
||||
lam_ac_size_fn=size
|
||||
else
|
||||
if test "x$lam_ac_caps" = xy; then
|
||||
lam_ac_size_fn=SIZE
|
||||
else
|
||||
AC_MSG_WARN([*** FORTRAN external naming convention undefined])
|
||||
AC_MSG_ERROR([*** Cannot continue.])
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# Cannot use standard AC_TRY macros because we need two different .o
|
||||
# files here, and link them together
|
||||
#
|
||||
|
||||
#
|
||||
# Fortran module
|
||||
#
|
||||
|
||||
cat > conftestf.f <<EOF
|
||||
program fsize
|
||||
external SIZE
|
||||
$1 x(2)
|
||||
call SIZE(x(1),x(2))
|
||||
end
|
||||
EOF
|
||||
|
||||
#
|
||||
# C module
|
||||
#
|
||||
|
||||
if test -f conftest.h; then
|
||||
lam_conftest_h="#include \"conftest.h\""
|
||||
else
|
||||
lam_conftest_h=""
|
||||
fi
|
||||
cat > conftest.c <<EOF
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
$lam_conftest_h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void $lam_ac_size_fn(char *a, char *b)
|
||||
{
|
||||
int diff = (int) (b - a);
|
||||
FILE *f=fopen("conftestval", "w");
|
||||
if (!f) exit(1);
|
||||
fprintf(f, "%d\n", diff);
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
EOF
|
||||
|
||||
#
|
||||
# Try the compilation and run. Can't use AC_TRY_RUN because it's two
|
||||
# module files.
|
||||
#
|
||||
|
||||
LAM_LOG_COMMAND([$CC $CFLAGS -I. -c conftest.c],
|
||||
LAM_LOG_COMMAND([$F77 $FFLAGS conftestf.f conftest.o -o conftest],
|
||||
LAM_LOG_COMMAND([./conftest],[HAPPY=1],[HAPPY=0]),
|
||||
[HAPPY=0]),
|
||||
[HAPPY=0])
|
||||
|
||||
if test "$HAPPY" = "1" -a -f conftestval; then
|
||||
lam_ac_fortsize=`cat conftestval`
|
||||
AC_MSG_RESULT([$lam_ac_fortsize])
|
||||
if test -n "$2"; then
|
||||
eval "$2=$lam_ac_fortsize"
|
||||
fi
|
||||
else
|
||||
AC_MSG_RESULT([unknown])
|
||||
|
||||
LAM_LOG_MSG([here is the C program:], 1)
|
||||
LAM_LOG_FILE([conftest.c])
|
||||
if test -f conftest.h; then
|
||||
LAM_LOG_MSG([here is contest.h:], 1)
|
||||
LAM_LOG_FILE([conftest.h])
|
||||
fi
|
||||
LAM_LOG_MSG([here is the fortran program:], 1)
|
||||
LAM_LOG_FILE([conftestf.f])
|
||||
|
||||
AC_MSG_WARN([*** Problem running configure test!])
|
||||
AC_MSG_WARN([*** See config.log for details.])
|
||||
AC_MSG_ERROR([*** Cannot continue.])
|
||||
fi
|
||||
|
||||
unset lam_ac_fortsize HAPPY lam_conftest_h
|
||||
/bin/rm -f conftest*])dnl
|
69
configure.ac
69
configure.ac
@ -132,9 +132,10 @@ AM_ENABLE_STATIC
|
||||
|
||||
LAM_SETUP_CC
|
||||
|
||||
# force ANSI prototypes
|
||||
# check for STDC
|
||||
# check for some types
|
||||
#
|
||||
# Check for some types
|
||||
#
|
||||
|
||||
AC_CHECK_TYPES(long long)
|
||||
AC_CHECK_TYPES(int8_t)
|
||||
AC_CHECK_TYPES(uint8_t)
|
||||
@ -146,14 +147,36 @@ AC_CHECK_TYPES(int64_t)
|
||||
AC_CHECK_TYPES(uint64_t)
|
||||
AC_CHECK_TYPES(intptr_t)
|
||||
AC_CHECK_TYPES(uintptr_t)
|
||||
# check for type sizes
|
||||
|
||||
#
|
||||
# Check for type sizes
|
||||
#
|
||||
|
||||
AC_CHECK_SIZEOF(char)
|
||||
AC_CHECK_SIZEOF(short)
|
||||
AC_CHECK_SIZEOF(int)
|
||||
AC_CHECK_SIZEOF(long)
|
||||
AC_CHECK_SIZEOF(long long)
|
||||
AC_CHECK_SIZEOF(void *)
|
||||
# check for type alignments
|
||||
|
||||
#
|
||||
# Check for type alignments
|
||||
#
|
||||
|
||||
LAM_C_GET_ALIGNMENT(char, LAM_ALIGNMENT_CHAR)
|
||||
LAM_C_GET_ALIGNMENT(short, LAM_ALIGNMENT_SHORT)
|
||||
LAM_C_GET_ALIGNMENT(wchar_t, LAM_ALIGNMENT_WCHAR)
|
||||
LAM_C_GET_ALIGNMENT(int, LAM_ALIGNMENT_INT)
|
||||
LAM_C_GET_ALIGNMENT(long, LAM_ALIGNMENT_LONG)
|
||||
LAM_C_GET_ALIGNMENT(long long, LAM_ALIGNMENT_LONG_LONG)
|
||||
LAM_C_GET_ALIGNMENT(float, LAM_ALIGNMENT_FLOAT)
|
||||
LAM_C_GET_ALIGNMENT(double, LAM_ALIGNMENT_DOUBLE)
|
||||
LAM_C_GET_ALIGNMENT(long double, LAM_ALIGNMENT_LONG_DOUBLE)
|
||||
LAM_C_GET_ALIGNMENT(void *, LAM_ALIGNMENT_VOID_P)
|
||||
|
||||
#
|
||||
# Check for other compiler characteristics
|
||||
#
|
||||
|
||||
AC_C_INLINE
|
||||
AC_C_RESTRICT
|
||||
@ -210,12 +233,16 @@ AC_DEFINE_UNQUOTED(LAM_HAVE_WEAK_SYMBOLS, $LAM_C_HAVE_WEAK_SYMBOLS,
|
||||
|
||||
LAM_SETUP_CXX
|
||||
|
||||
# check for STL
|
||||
# check for bool (and corresponding C type)
|
||||
# check for true/false
|
||||
# check for type sizes
|
||||
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_CPLUSPLUS
|
||||
AC_CHECK_SIZEOF(bool)
|
||||
|
||||
# check for type alignments
|
||||
# check for template repository
|
||||
|
||||
LAM_C_GET_ALIGNMENT(bool, LAM_ALIGNMENT_CXX_BOOL)
|
||||
AC_LANG_RESTORE
|
||||
|
||||
|
||||
##################################
|
||||
@ -230,10 +257,30 @@ if test "$F77" != "none" ; then
|
||||
# MPI_Fint. This is needed for C bindings and hence there is no
|
||||
# bearing of --enable-fortran flag on this test.
|
||||
|
||||
LAM_SIZEOF_FORTRAN_INT=0
|
||||
LAM_GET_SIZEOF_FORTRAN_TYPE(INTEGER, LAM_SIZEOF_FORTRAN_INT)
|
||||
LAM_F77_GET_SIZEOF(INTEGER, LAM_SIZEOF_FORTRAN_INT)
|
||||
fi
|
||||
|
||||
# If we want fortran support, then get the sizes and alignments of all
|
||||
# the rest of the fortran types
|
||||
|
||||
if test "$F77" != "none" -a "$WANT_MPI_F77" = "1"; then
|
||||
# INTEGER is already done, per above
|
||||
LAM_F77_GET_SIZEOF(REAL, LAM_SIZEOF_FORTRAN_REAL)
|
||||
LAM_F77_GET_SIZEOF(DOUBLE PRECISION, LAM_SIZEOF_FORTRAN_DBLPREC)
|
||||
LAM_F77_GET_SIZEOF(COMPLEX, LAM_SIZEOF_FORTRAN_COMPLEX)
|
||||
LAM_F77_GET_SIZEOF(DOUBLE COMPLEX, LAM_SIZEOF_FORTRAN_DBLCOMPLEX)
|
||||
|
||||
LAM_F77_GET_ALIGNMENT(INTEGER, LAM_ALIGNMENT_FORTRAN_INT)
|
||||
LAM_F77_GET_ALIGNMENT(REAL, LAM_ALIGNMENT_FORTRAN_REAL)
|
||||
LAM_F77_GET_ALIGNMENT(DOUBLE PRECISION, LAM_ALIGNMENT_FORTRAN_DBLPREC)
|
||||
LAM_F77_GET_ALIGNMENT(COMPLEX, LAM_ALIGNMENT_FORTRAN_COMPLEX)
|
||||
LAM_F77_GET_ALIGNMENT(DOUBLE COMPLEX, LAM_ALIGNMENT_FORTRAN_DBLCOMPLEX)
|
||||
fi
|
||||
|
||||
#
|
||||
# Fortran 90 setup
|
||||
#
|
||||
|
||||
LAM_SETUP_F90
|
||||
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user