Blame test/mpi/confdb/aclocal_attr_alias.m4

Packit 0848f5
dnl
Packit 0848f5
dnl Check for BSD or POSIZ style global symbol lister, nm.
Packit 0848f5
dnl If found, pac_path_NM_G contains the absolute athname of nm + options
Packit 0848f5
dnl pac_path_NM_G_type will be either POSIX or BSD.  NM_G will be
Packit 0848f5
dnl pac_path_NM_G without the absolute path.  Preference is BSD style.
Packit 0848f5
dnl
Packit 0848f5
dnl The test checks if nm accepts the known options and also if nm produces
Packit 0848f5
dnl the expected BSD or POSIX output format.
Packit 0848f5
dnl
Packit 0848f5
AC_DEFUN([PAC_PATH_NM_G],[
Packit 0848f5
AC_MSG_CHECKING([for BSD/POSIX style global symbol lister])
Packit 0848f5
AC_LANG_PUSH(C)
Packit 0848f5
AC_PATH_PROGS_FEATURE_CHECK(NM_G, nm, [
Packit 0848f5
    # Check if nm accepts -g and BSD or POSIX compatible flag.
Packit 0848f5
    # Use the `sed 1q' to avoid HP-UX's unknown option message:
Packit 0848f5
    #   nm: unknown option "B" ignored
Packit 0848f5
    # Tru64's nm complains that /dev/null is an invalid object file
Packit 0848f5
    #
Packit 0848f5
    # AIX's sed does not accept \+, 1) instead of doing 's|a\+||', do 's|aa*||'
Packit 0848f5
    # or 2) instead of 's|A \+B|AB|g', do 's|A  *B|AB|g' 
Packit 0848f5
Packit 0848f5
    # Check if nm accepts -g
Packit 0848f5
    case `${ac_path_NM_G} -g /dev/null 2>&1 | sed '1q'` in
Packit 0848f5
    */dev/null* | *'Invalid file or object type'*)
Packit 0848f5
        ac_path_NM_G="${ac_path_NM_G} -g"
Packit 0848f5
        # Check if nm accepts -B
Packit 0848f5
        case `${ac_path_NM_G} -B /dev/null 2>&1 | sed '1q'` in
Packit 0848f5
        */dev/null* | *'Invalid file or object type'*)
Packit 0848f5
            AC_COMPILE_IFELSE([
Packit 0848f5
                AC_LANG_SOURCE([int iglobal;])
Packit 0848f5
            ],[
Packit 0848f5
                changequote(,)
Packit 0848f5
                case `${ac_path_NM_G} -B conftest.$OBJEXT | sed -e 's|[0-9][0-9]*  *[A-Z]  *iglobal|XXXX|g'` in
Packit 0848f5
                *XXXX*)
Packit 0848f5
                    pac_path_NM_G="${ac_path_NM_G} -B"
Packit 0848f5
                    pac_path_NM_G_type="BSD"
Packit 0848f5
                    ;;
Packit 0848f5
                esac
Packit 0848f5
                changequote([,])
Packit 0848f5
            ])
Packit 0848f5
            ;;
Packit 0848f5
        *)
Packit 0848f5
            # Check if nm accepts -P
Packit 0848f5
            case `${ac_path_NM_G} -P /dev/null 2>&1 | sed '1q'` in
Packit 0848f5
            */dev/null* | *'Invalid file or object type'*)
Packit 0848f5
                AC_COMPILE_IFELSE([
Packit 0848f5
                    AC_LANG_SOURCE([int iglobal;])
Packit 0848f5
                ],[
Packit 0848f5
                    changequote(,)
Packit 0848f5
                    case `${ac_path_NM_G} -P conftest.$OBJEXT | sed -e 's|iglobal  *[A-Z]  *[0-9][0-9]*|XXXX|g'` in
Packit 0848f5
                    *XXXX*)
Packit 0848f5
                        pac_path_NM_G="${ac_path_NM_G} -P"
Packit 0848f5
                        pac_path_NM_G_type="POSIX"
Packit 0848f5
                        ;;
Packit 0848f5
                    esac
Packit 0848f5
                    changequote([,])
Packit 0848f5
                ])
Packit 0848f5
                ;;
Packit 0848f5
            esac  # Endof case `${ac_path_NM_G} -P
Packit 0848f5
            ;;
Packit 0848f5
        esac   # Endof case `${ac_path_NM_G} -B
Packit 0848f5
        ;;
Packit 0848f5
    esac  # Endof case `${ac_path_NM_G} -g
Packit 0848f5
    if test "X$pac_path_NM_G" != "X" ; then
Packit 0848f5
        AC_MSG_RESULT([$pac_path_NM_G_type style,$pac_path_NM_G])
Packit 0848f5
        NM_G="`echo $pac_path_NM_G | sed -e 's|^.*nm |nm |g'`"
Packit 0848f5
    else
Packit 0848f5
        AC_MSG_RESULT(no)
Packit 0848f5
    fi
Packit 0848f5
    ac_cv_path_NM_G=${ac_path_NM_G}
Packit 0848f5
    ac_path_NM_G_found=:
Packit 0848f5
], [AC_MSG_RESULT(no)],
Packit 0848f5
[$PATH$PATH_SEPARATOR/usr/ccs/bin/elf$PATH_SEPARATOR/usr/ccs/bin$PATH_SEPARATOR/usr/ucb$PATH_SEPARATOR/bin])
Packit 0848f5
AC_LANG_POP(C)
Packit 0848f5
]) dnl Endof AC_DEFUN([PAC_PATH_NM_G]
Packit 0848f5
dnl
Packit 0848f5
dnl PAC_C_MULTI_ATTR_ALIAS()
Packit 0848f5
dnl
Packit 0848f5
dnl The checks if multiple __attribute__((alias)) is available
Packit 0848f5
dnl If the multiple __attribute((alias)) support is found,
Packit 0848f5
dnl pac_c_multi_attr_alias=yes is set.
Packit 0848f5
dnl
Packit 0848f5
dnl The default is to do a runtime test.  When cross_compiling=yes,
Packit 0848f5
dnl pac_path_NM_G will be used to determine the test result.
Packit 0848f5
dnl If CFLAGS(or CPPFLAGS) contains ATTR_ALIAS_DEBUG, the runtime will print
Packit 0848f5
dnl out addresses of struct(s) for debugging purpose.
Packit 0848f5
dnl
Packit 0848f5
dnl
Packit 0848f5
AC_DEFUN([PAC_C_MULTI_ATTR_ALIAS],[
Packit 0848f5
AC_REQUIRE([PAC_PATH_NM_G])
Packit 0848f5
AC_LANG_PUSH(C)
Packit 0848f5
AC_CHECK_HEADERS([stdio.h])
Packit 0848f5
AC_MSG_CHECKING([for multiple __attribute__((alias)) support])
Packit 0848f5
Packit 0848f5
#Compile the "other" __attribute__ object file.
Packit 0848f5
AC_COMPILE_IFELSE([
Packit 0848f5
    AC_LANG_SOURCE([
Packit 0848f5
#if defined(HAVE_STDIO_H) || defined(STDC_HEADERS)
Packit 0848f5
#include <stdio.h>
Packit 0848f5
#endif
Packit 0848f5
Packit 0848f5
struct mpif_cmblk_t_ { int imember; };
Packit 0848f5
typedef struct mpif_cmblk_t_ mpif_cmblk_t;
Packit 0848f5
Packit 0848f5
/* NOT initialize these structure so it appears in BSS or as COMMON symbols */
Packit 0848f5
mpif_cmblk_t mpifcmb;
Packit 0848f5
mpif_cmblk_t MPIFCMB;
Packit 0848f5
Packit 0848f5
/*
Packit 0848f5
   Do the test in this file instead in the file
Packit 0848f5
   where __attribute__((alias)) is used. 
Packit 0848f5
   This is needed for pgcc since pgcc seems to
Packit 0848f5
   define aliased symbols if they are in the same file.
Packit 0848f5
*/
Packit 0848f5
/*
Packit 0848f5
    We can't do the following comparision in one test:
Packit 0848f5
Packit 0848f5
    ilogical = (( &mpifcmb == ptr && &MPIFCMB == ptr ) ? TRUE : FALSE) ;
Packit 0848f5
Packit 0848f5
    because some compiler, like gcc 4.4.2's -O* optimizes the code
Packit 0848f5
    such that the ilogical expression is FALSE. The likely reason is that
Packit 0848f5
    mpifcmb and MPIFCMB are defined in the same scope in which C optimizer
Packit 0848f5
    may have treated them as different objects (with different addresses),
Packit 0848f5
    &mpifcmb != &MPIFCMB, before actually running the test and hence the
Packit 0848f5
    illogical expression is assumed to be always FALSE.  The solution taken
Packit 0848f5
    here is to prevent the optimizer the opportunity to equate &mpifcmb and
Packit 0848f5
    &MPIFCMB (in same scope), e.g. using 2 separate tests and combine the
Packit 0848f5
    test results in a different scope.
Packit 0848f5
*/
Packit 0848f5
int same_addrs1( void *ptr );
Packit 0848f5
int same_addrs1( void *ptr )
Packit 0848f5
{
Packit 0848f5
#if defined(ATTR_ALIAS_DEBUG)
Packit 0848f5
    printf( "others: addr(mpifcmb)=%p, addr(input ptr)=%p\n", &mpifcmb, ptr );
Packit 0848f5
#endif
Packit 0848f5
    return ( &mpifcmb == ptr ? 1 : 0 );
Packit 0848f5
}
Packit 0848f5
Packit 0848f5
int same_addrs2( void *ptr );
Packit 0848f5
int same_addrs2( void *ptr )
Packit 0848f5
{
Packit 0848f5
#if defined(ATTR_ALIAS_DEBUG)
Packit 0848f5
    printf( "others: addr(MPIFCMB)=%p, addr(input ptr)=%p\n", &MPIFCMB, ptr );
Packit 0848f5
#endif
Packit 0848f5
    return ( &MPIFCMB == ptr ? 1 : 0 );
Packit 0848f5
}
Packit 0848f5
Packit 0848f5
    ])
Packit 0848f5
],[
Packit 0848f5
    rm -f pac_conftest_other.$OBJEXT
Packit 0848f5
    PAC_RUNLOG([cp conftest.$OBJEXT pac_conftest_other.$OBJEXT])
Packit 0848f5
    test -s pac_conftest_other.$OBJEXT && pac_c_attr_alias_other=yes
Packit 0848f5
dnl     cp conftest.$ac_ext pac_conftest_other.$ac_ext
Packit 0848f5
dnl     echo
Packit 0848f5
dnl     echo "pac_conftest_other.$OBJEXT"
Packit 0848f5
dnl     nm -P -g pac_conftest_other.$OBJEXT | grep -i "mpifcmb"
Packit 0848f5
],[
Packit 0848f5
    pac_c_attr_alias_other=no
Packit 0848f5
])  dnl Endof AC_COMPILE_IFELSE
Packit 0848f5
Packit 0848f5
pac_c_attr_alias_main=no
Packit 0848f5
if test "$pac_c_attr_alias_other" = "yes" ; then
Packit 0848f5
Packit 0848f5
#   Push LIBS for later restoration.
Packit 0848f5
    PAC_PUSH_FLAG([LIBS])
Packit 0848f5
    LIBS="pac_conftest_other.$OBJEXT $LIBS"
Packit 0848f5
Packit 0848f5
#   Link the "other" __attribute__ object file.
Packit 0848f5
    AC_LINK_IFELSE([
Packit 0848f5
        AC_LANG_PROGRAM([
Packit 0848f5
#if defined(HAVE_STDIO_H) || defined(STDC_HEADERS)
Packit 0848f5
#include <stdio.h>
Packit 0848f5
#endif
Packit 0848f5
 
Packit 0848f5
struct mpif_cmblk_t_ { int imember; };
Packit 0848f5
typedef struct mpif_cmblk_t_ mpif_cmblk_t;
Packit 0848f5
Packit 0848f5
mpif_cmblk_t mpifcmbr = {0};
Packit 0848f5
extern mpif_cmblk_t MPIFCMB __attribute__ ((alias("mpifcmbr")));
Packit 0848f5
extern mpif_cmblk_t mpifcmb __attribute__ ((alias("mpifcmbr")));
Packit 0848f5
Packit 0848f5
extern int same_addrs1( void *ptr );
Packit 0848f5
extern int same_addrs2( void *ptr );
Packit 0848f5
Packit 0848f5
        ],[
Packit 0848f5
    int iaddr = 0;
Packit 0848f5
#if defined(ATTR_ALIAS_DEBUG)
Packit 0848f5
    printf( "main: addr(mpifcmbr) = %p\n", &mpifcmbr );
Packit 0848f5
    printf( "main: addr(mpifcmb) = %p\n", &mpifcmb );
Packit 0848f5
    printf( "main: addr(MPIFCMB) = %p\n", &MPIFCMB );
Packit 0848f5
#endif
Packit 0848f5
    iaddr = same_addrs1( &mpifcmbr ) && same_addrs2( &mpifcmbr );
Packit 0848f5
    FILE *file = fopen( "pac_conftestval", "w" );
Packit 0848f5
    if (!file) return 1;
Packit 0848f5
    fprintf( file, "%d\n", iaddr );
Packit 0848f5
        ])
Packit 0848f5
    ],[
Packit 0848f5
        rm -f pac_conftest_main$EXEEXT
Packit 0848f5
        PAC_RUNLOG([cp conftest$EXEEXT pac_conftest_main$EXEEXT])
Packit 0848f5
        test -x pac_conftest_main$EXEEXT && pac_c_attr_alias_main=yes
Packit 0848f5
dnl         cp conftest.$ac_ext pac_conftest_main.$ac_ext
Packit 0848f5
dnl         echo
Packit 0848f5
dnl         echo "pac_conftest_main$EXEEXT"
Packit 0848f5
dnl         nm -P -g pac_conftest_main$EXEEXT | grep -i "mpifcmb"
Packit 0848f5
    ],[
Packit 0848f5
        pac_c_attr_alias_main=no
Packit 0848f5
dnl         cp conftest.$ac_ext pac_conftest_main.$ac_ext
Packit 0848f5
    ])  dnl Endof AC_LINK_IFELSE
Packit 0848f5
Packit 0848f5
# Restore the previously pushed LIBS
Packit 0848f5
    PAC_POP_FLAG([LIBS])
Packit 0848f5
    rm -f pac_conftest_other.$OBJEXT
Packit 0848f5
fi dnl Endof if test "$pac_c_attr_alias_other" = "yes"
Packit 0848f5
Packit 0848f5
if test "$pac_c_attr_alias_main" = "yes" ; then
Packit 0848f5
    if test "$cross_compiling" = "yes" ; then
Packit 0848f5
        changequote(,)
Packit 0848f5
        # echo "PAC CROSS-COMPILING" dnl
Packit 0848f5
        # POSIX NM = nm -P format dnl
Packit 0848f5
        if test "$pac_path_NM_G_type" = "POSIX" ; then
Packit 0848f5
            addrs=`${pac_path_NM_G} ./pac_conftest_main$EXEEXT | grep -i mpifcmb | sed -e 's% *[a-zA-Z][a-zA-Z]*  *[a-zA-Z]  *\([0-9abcdef][0-9abcdef]*\).*%\1%g'`
Packit 0848f5
        fi
Packit 0848f5
Packit 0848f5
        # BSD NM = nm -B format dnl
Packit 0848f5
        if test "$pac_path_NM_G_type" = "BSD" ; then
Packit 0848f5
            addrs=`${pac_path_NM_G} -g ./pac_conftest_main$EXEEXT | grep -i mpifcmb | sed -e "s% *\([0-9abcdef][0-9abcdef]*\)  *[a-zA-Z]  *[a-zA-Z][a-zA-A]*.*%\1%g"`
Packit 0848f5
        fi
Packit 0848f5
        changequote([,])
Packit 0848f5
Packit 0848f5
        cmp_addr=""
Packit 0848f5
        diff_addrs=no
Packit 0848f5
        for addr in ${addrs} ; do
Packit 0848f5
            if test "X${cmp_addr}" != "X" ; then
Packit 0848f5
                if test "${cmp_addr}" != "${addr}" ; then
Packit 0848f5
                    diff_addrs=yes
Packit 0848f5
                    break
Packit 0848f5
                fi
Packit 0848f5
            else
Packit 0848f5
                cmp_addr=${addr}
Packit 0848f5
            fi
Packit 0848f5
        done
Packit 0848f5
        
Packit 0848f5
        if test "$diff_addrs" != "yes" ; then
Packit 0848f5
            dnl echo "Same addresses. Multiple aliases support"
Packit 0848f5
            AC_MSG_RESULT([${NM_G} says yes])
Packit 0848f5
            pac_c_multi_attr_alias=yes
Packit 0848f5
        else
Packit 0848f5
            dnl echo "Different addresses. No multiple aliases support."
Packit 0848f5
            AC_MSG_RESULT([${NM_G} says no])
Packit 0848f5
            pac_c_multi_attr_alias=no
Packit 0848f5
        fi
Packit 0848f5
Packit 0848f5
    else # if test "$cross_compiling" != "yes"
Packit 0848f5
        rm -f pac_conftestval
Packit 0848f5
        ac_try="./pac_conftest_main$EXEEXT"
Packit 0848f5
        if AC_TRY_EVAL(ac_try) ; then
Packit 0848f5
            pac_c_attr_alias_val=0
Packit 0848f5
            if test -s pac_conftestval ; then
Packit 0848f5
                eval pac_c_attr_alias_val=`cat pac_conftestval`
Packit 0848f5
            fi
Packit 0848f5
            if test "$pac_c_attr_alias_val" -eq 1 ; then
Packit 0848f5
                AC_MSG_RESULT(yes)
Packit 0848f5
                pac_c_multi_attr_alias=yes
Packit 0848f5
            else
Packit 0848f5
                AC_MSG_RESULT(no)
Packit 0848f5
                pac_c_multi_attr_alias=no
Packit 0848f5
            fi
Packit 0848f5
            rm -f pac_conftestval
Packit 0848f5
        fi
Packit 0848f5
    fi
Packit 0848f5
    dnl Endof if test "$cross_compiling" = "yes"
Packit 0848f5
    rm -f pac_conftest_main$EXEEXT
Packit 0848f5
else
Packit 0848f5
    AC_MSG_RESULT(no! link failure)
Packit 0848f5
    pac_c_multi_attr_alias=no
Packit 0848f5
fi dnl Endof if test "$pac_c_attr_alias_main" = "yes"
Packit 0848f5
Packit 0848f5
AC_LANG_POP(C)
Packit 0848f5
Packit 0848f5
]) dnl  Endof AC_DEFUN([PAC_C_MULTI_ATTR_ALIAS]
Packit 0848f5
dnl
Packit 0848f5
dnl PAC_C_ATTR_ALIGNED()
Packit 0848f5
dnl
Packit 0848f5
dnl Check if __attribute__((aligned)) support is there.
Packit 0848f5
dnl If so, set pac_c_attr_aligned=yes.
Packit 0848f5
dnl
Packit 0848f5
dnl Do a link test instead of compile test to check if the linker
Packit 0848f5
dnl would emit an error.
Packit 0848f5
dnl
Packit 0848f5
AC_DEFUN([PAC_C_ATTR_ALIGNED],[
Packit 0848f5
AC_LANG_PUSH(C)
Packit 0848f5
AC_MSG_CHECKING([for __attribute__((aligned)) support])
Packit 0848f5
#Link the __attribute__ object file.
Packit 0848f5
AC_LINK_IFELSE([
Packit 0848f5
    AC_LANG_PROGRAM([
Packit 0848f5
struct mpif_cmblk_t_ { int imembers[5]; };
Packit 0848f5
typedef struct mpif_cmblk_t_ mpif_cmblk_t;
Packit 0848f5
mpif_cmblk_t mpifcmbr __attribute__((aligned)) = {0};
Packit 0848f5
    ],[])
Packit 0848f5
],[pac_c_attr_aligned=yes], [pac_c_attr_aligned=no])
Packit 0848f5
AC_MSG_RESULT([$pac_c_attr_aligned])
Packit 0848f5
AC_LANG_POP(C)
Packit 0848f5
])
Packit 0848f5
dnl
Packit 0848f5
dnl PAC_F2C_ATTR_ALIGNED_SIZE(ARRAY_SIZE, [OUTPUT_VAR], [MIN_ALIGNMENT])
Packit 0848f5
dnl
Packit 0848f5
dnl ARRAY_SIZE    : Size of the integer array within the fortran commmon block.
Packit 0848f5
dnl OUTPUT_VAR    : Optional variable to be set.
Packit 0848f5
dnl                 if test succeeds, set OUTPUT_VAR=$pac_f2c_attr_aligned_str.
Packit 0848f5
dnl                 if test fails, set OUTPUT_VAR="unknown".
Packit 0848f5
dnl MIN_ALIGNMENT : Optional value.
Packit 0848f5
dnl                 Minimum alignment size to be used in OUTPUT_VAR.
Packit 0848f5
dnl                 pac_f2c_attr_aligned_str won't be modified.
Packit 0848f5
dnl
Packit 0848f5
dnl "pac_f2c_attr_aligned_str" will be set with
Packit 0848f5
dnl 1) __attribute__((aligned(ALIGNMENT_SIZE))),
Packit 0848f5
dnl 2) __attribute__((aligned)).
Packit 0848f5
dnl 3) "", i.e. empty string.
Packit 0848f5
dnl
Packit 0848f5
dnl 2) means the test can't find a good alignment value, but both the Fortran
Packit 0848f5
dnl    and C compilers are OK with "aligned" which in principle means the C
Packit 0848f5
dnl    compiler will pick the maximum useful alignment supported by the
Packit 0848f5
dnl    architecture.
Packit 0848f5
dnl 3) means that the test has failed to find the alignment.
Packit 0848f5
dnl
Packit 0848f5
AC_DEFUN([PAC_F2C_ATTR_ALIGNED_SIZE],[
Packit 0848f5
cmblksize=$1
Packit 0848f5
AC_MSG_CHECKING([the minimum alignment of Fortran common block of $cmblksize integers])
Packit 0848f5
dnl To find the minmium alignment of Fortran common block (of integer array)
Packit 0848f5
dnl as seen by C object file, C object files of various (typical) alignments
Packit 0848f5
dnl are linked to the Fortran code using the common block of integer array.
Packit 0848f5
#
Packit 0848f5
dnl Since the incorrect alignment results only a warning messages from the
Packit 0848f5
dnl fortran compiler(or linker), so we use "diff" to compare the fortran
Packit 0848f5
dnl compiler/linker output.  We cannot use AC_LANG_WERROR,
Packit 0848f5
dnl i.e. ac_fc_werror_flag=yes, because compiler like pgf77 at version 10.x)
Packit 0848f5
dnl has non-zero stderr output if a fortran program is used in the linking.
Packit 0848f5
dnl The stderr contains the name of fortran program even if the linking is
Packit 0848f5
dnl successful.  We could avoid the non-zero stderr output in pgf77 by
Packit 0848f5
dnl compiling everthing into object files and linking all the object files
Packit 0848f5
dnl with pgf77.  Doing that would need us to use AC_TRY_EVAL instead of
Packit 0848f5
dnl AC_LINK_IFELSE, so "diff" approach is used instead.
Packit 0848f5
#
Packit 0848f5
dnl Using diff of compiler(linker) output requires a reference output file
Packit 0848f5
dnl as the base of diff.  The process of creating this reference output file
Packit 0848f5
dnl has to be exactly the same as the testing process, because pgf77 has
Packit 0848f5
dnl the following weird behavour
Packit 0848f5
dnl pgf77 -o ftest ftest.f         => when $?=0 with zero stderr output
Packit 0848f5
dnl pgf77 -o ftest ftest.f dummy.o => when $?=0 with non-zero stderr output.
Packit 0848f5
dnl                                   stderr has "ftest.f:".
Packit 0848f5
dnl 
Packit 0848f5
# First create a fortran CONFTEST which will be used repeatedly.
Packit 0848f5
AC_LANG_PUSH([Fortran]) dnl AC_LANG_PUSH([Fortran 77])
Packit 0848f5
AC_LANG_CONFTEST([
Packit 0848f5
    AC_LANG_SOURCE([
Packit 0848f5
        program fconftest
Packit 0848f5
        integer isize
Packit 0848f5
        parameter (isize=$cmblksize)
Packit 0848f5
        integer status_array(isize)
Packit 0848f5
        common /mpifcmb/ status_array
Packit 0848f5
        save /mpifcmb/
Packit 0848f5
        end
Packit 0848f5
    ])
Packit 0848f5
])
Packit 0848f5
AC_LANG_POP([Fortran]) dnl AC_LANG_POP([Fortran 77])
Packit 0848f5
dnl
Packit 0848f5
dnl
Packit 0848f5
dnl
Packit 0848f5
# Compile a C dummy.$OBJEXT and link with Fortran test program to create
Packit 0848f5
# a reference linker output file, pac_align0.log, as the base of "diff".
Packit 0848f5
AC_LANG_PUSH([C])
Packit 0848f5
AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[
Packit 0848f5
    cp conftest.$ac_ext pac_conftest.c
Packit 0848f5
    PAC_RUNLOG([mv conftest.$OBJEXT pac_conftest.$OBJEXT])
Packit 0848f5
    PAC_PUSH_FLAG([LIBS])
Packit 0848f5
    LIBS="pac_conftest.$OBJEXT $LIBS"
Packit 0848f5
    AC_LANG_PUSH([Fortran]) dnl AC_LANG_PUSH([Fortran 77])
Packit 0848f5
    PAC_PUSH_FLAG([ac_link])
Packit 0848f5
    ac_link="`echo $ac_link | sed -e 's|>.*$|> $pac_logfile 2>\&1|g'`"
Packit 0848f5
    pac_logfile="pac_align0.log"
Packit 0848f5
    rm -f $pac_logfile
Packit 0848f5
    AC_LINK_IFELSE([],[
Packit 0848f5
        pac_f2c_alignedn_diffbase=yes
Packit 0848f5
    ],[
Packit 0848f5
        pac_f2c_alignedn_diffbase=no
Packit 0848f5
    ])
Packit 0848f5
    # Be sure NOT to remove the conftest.f which is still needed for later use.
Packit 0848f5
    # rm -f conftest.$ac_ext 
Packit 0848f5
    # Restore everything in autoconf that has been overwritten
Packit 0848f5
    PAC_POP_FLAG([ac_link])
Packit 0848f5
    # restore previously pushed LIBS
Packit 0848f5
    PAC_POP_FLAG([LIBS])
Packit 0848f5
    AC_LANG_POP([Fortran]) dnl AC_LANG_POP([Fortran 77])
Packit 0848f5
],[
Packit 0848f5
    pac_f2c_alignedn_diffbase=no
Packit 0848f5
])
Packit 0848f5
AC_LANG_POP([C])
Packit 0848f5
dnl
Packit 0848f5
dnl
Packit 0848f5
if test "$pac_f2c_alignedn_diffbase" = "yes" ; then
Packit 0848f5
    # Initialize pac_result_str to empty string since part of the test
Packit 0848f5
    # depends on pac_result_str is empty or non-empty string.
Packit 0848f5
    pac_result_str=""
Packit 0848f5
    # Initialize pac_f2c_attr_aligned_str to empty string and
Packit 0848f5
    # it will remain as empty string if the following test fails.
Packit 0848f5
    pac_f2c_attr_aligned_str=""
Packit 0848f5
    for asize in 4 8 16 32 64 128 max ; do
Packit 0848f5
        if test "$asize" != "max" ; then
Packit 0848f5
            pac_attr_aligned_str="__attribute__((aligned($asize)))"
Packit 0848f5
        else
Packit 0848f5
            pac_attr_aligned_str="__attribute__((aligned))"
Packit 0848f5
        fi
Packit 0848f5
        AC_LANG_PUSH([C])
Packit 0848f5
        #Compile the __attribute__ object file.
Packit 0848f5
        AC_COMPILE_IFELSE([
Packit 0848f5
            AC_LANG_SOURCE([
Packit 0848f5
changequote(,)
Packit 0848f5
struct mpif_cmblk_t_ { $MPI_FINT imembers[$cmblksize]; };
Packit 0848f5
changequote([,])
Packit 0848f5
typedef struct mpif_cmblk_t_ mpif_cmblk_t;
Packit 0848f5
mpif_cmblk_t mpifcmbr $pac_attr_aligned_str = {0};
Packit 0848f5
Packit 0848f5
extern mpif_cmblk_t _CMPIFCMB  __attribute__ ((alias("mpifcmbr")));
Packit 0848f5
extern mpif_cmblk_t   MPIFCMB  __attribute__ ((alias("mpifcmbr")));
Packit 0848f5
extern mpif_cmblk_t   MPIFCMB_ __attribute__ ((alias("mpifcmbr")));
Packit 0848f5
extern mpif_cmblk_t _Cmpifcmb  __attribute__ ((alias("mpifcmbr")));
Packit 0848f5
extern mpif_cmblk_t   mpifcmb  __attribute__ ((alias("mpifcmbr")));
Packit 0848f5
extern mpif_cmblk_t   mpifcmb_ __attribute__ ((alias("mpifcmbr")));
Packit 0848f5
            ])
Packit 0848f5
        ],[
Packit 0848f5
            cp conftest.$ac_ext pac_conftest.c
Packit 0848f5
            PAC_RUNLOG([mv conftest.$OBJEXT pac_conftest.$OBJEXT])
Packit 0848f5
	    PAC_PUSH_FLAG([LIBS])
Packit 0848f5
            LIBS="pac_conftest.$OBJEXT $LIBS"
Packit 0848f5
            AC_LANG_PUSH([Fortran]) dnl AC_LANG_PUSH([Fortran 77])
Packit 0848f5
	    PAC_PUSH_FLAG([ac_link])
Packit 0848f5
            ac_link="`echo $ac_link | sed -e 's|>.*$|> $pac_logfile 2>\&1|g'`"
Packit 0848f5
            pac_logfile="pac_align1.log"
Packit 0848f5
            rm -f $pac_logfile
Packit 0848f5
            # Use conftest.f created in CONFTEST.
Packit 0848f5
            AC_LINK_IFELSE([],[
Packit 0848f5
                PAC_RUNLOG_IFELSE([diff -b pac_align0.log pac_align1.log],[
Packit 0848f5
                    pac_attr_alignedn=yes
Packit 0848f5
                ],[
Packit 0848f5
                    pac_attr_alignedn=no
Packit 0848f5
                    cat $pac_logfile >&AS_MESSAGE_LOG_FD
Packit 0848f5
                    echo "failed C program was:" >&AS_MESSAGE_LOG_FD
Packit 0848f5
                    cat pac_conftest.c >&AS_MESSAGE_LOG_FD
Packit 0848f5
                    echo "failed Fortran program was:" >&AS_MESSAGE_LOG_FD
Packit 0848f5
                    cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD
Packit 0848f5
                ])
Packit 0848f5
            ],[
Packit 0848f5
                pac_attr_alignedn=no
Packit 0848f5
            ])
Packit 0848f5
            # Restore everything in autoconf that has been overwritten
Packit 0848f5
	    PAC_POP_FLAG([ac_link])
Packit 0848f5
            # restore previously pushed LIBS
Packit 0848f5
	    PAC_POP_FLAG([LIBS])
Packit 0848f5
            AC_LANG_POP([Fortran]) dnl AC_LANG_POP([Fortran 77])
Packit 0848f5
            # remove previously generated object file and C file.
Packit 0848f5
            rm -f pac_conftest.$OBJEXT pac_conftest.c
Packit 0848f5
            rm -f $pac_logfile
Packit 0848f5
            if test "$pac_attr_alignedn" = yes ; then
Packit 0848f5
                ifelse([$3],[],[
Packit 0848f5
                    pac_result_str="$asize"
Packit 0848f5
                    pac_f2c_attr_aligned_str="$pac_attr_aligned_str"
Packit 0848f5
                    break
Packit 0848f5
                ],[
Packit 0848f5
                    if test "$asize" != "max" -a "$asize" -lt "$3" ; then
Packit 0848f5
                        if test "X$pac_result_str" = "X" ; then
Packit 0848f5
                            pac_result_str="$asize"
Packit 0848f5
                            pac_f2c_attr_aligned_str="$pac_attr_aligned_str"
Packit 0848f5
                        fi
Packit 0848f5
                        continue
Packit 0848f5
                    else
Packit 0848f5
                        pac_f2c_attr_aligned_str="$pac_attr_aligned_str"
Packit 0848f5
                        if test "X$pac_result_str" != "X" ; then
Packit 0848f5
                            pac_result_str="$pac_result_str, too small! reset to $asize"
Packit 0848f5
                        else
Packit 0848f5
                            pac_result_str="$asize"
Packit 0848f5
                        fi
Packit 0848f5
                        break
Packit 0848f5
                    fi
Packit 0848f5
                ])
Packit 0848f5
            fi
Packit 0848f5
        ], [
Packit 0848f5
            pac_attr_alignedn=no
Packit 0848f5
        ])
Packit 0848f5
        AC_LANG_POP([C])
Packit 0848f5
    done
Packit 0848f5
    ifelse([$2],[],[],[$2="$pac_f2c_attr_aligned_str"])
Packit 0848f5
else
Packit 0848f5
    pac_result_str=""
Packit 0848f5
    # Since the test fails, set pac_f2c_attr_aligned_str to empty string.
Packit 0848f5
    pac_f2c_attr_aligned_str=""
Packit 0848f5
fi
Packit 0848f5
if test "X$pac_result_str" != "X" ; then
Packit 0848f5
    AC_MSG_RESULT([$pac_result_str])
Packit 0848f5
else
Packit 0848f5
    AC_MSG_RESULT([unknown])
Packit 0848f5
fi
Packit 0848f5
rm -f pac_align0.log
Packit 0848f5
])
Packit 0848f5
dnl