2004-02-13 21:05:49 +03:00
|
|
|
dnl -*- shell-script -*-
|
|
|
|
dnl
|
2005-11-05 22:57:48 +03:00
|
|
|
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
dnl University Research and Technology
|
|
|
|
dnl Corporation. All rights reserved.
|
|
|
|
dnl Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
dnl of Tennessee Research Foundation. All rights
|
|
|
|
dnl reserved.
|
2004-11-28 23:09:25 +03:00
|
|
|
dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
dnl University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
dnl Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
dnl All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
dnl $COPYRIGHT$
|
|
|
|
dnl
|
|
|
|
dnl Additional copyrights may follow
|
|
|
|
dnl
|
2004-02-13 21:05:49 +03:00
|
|
|
dnl $HEADER$
|
|
|
|
dnl
|
|
|
|
|
2005-07-09 22:52:53 +04:00
|
|
|
# OMPI_C_GET_ALIGN(type, config_var)
|
|
|
|
# ----------------------------------
|
2004-02-13 21:05:49 +03:00
|
|
|
# Determine datatype alignment.
|
|
|
|
# First arg is type, 2nd arg is config var to define.
|
2005-07-09 22:52:53 +04:00
|
|
|
AC_DEFUN([OMPI_C_GET_ALIGNMENT],[
|
|
|
|
AC_CACHE_CHECK([alignment of $1],
|
|
|
|
[AS_TR_SH([ompi_cv_c_align_$1])],
|
|
|
|
[AC_TRY_RUN([
|
2004-02-13 21:05:49 +03:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
struct foo { char c; $1 x; };
|
2006-09-23 03:58:23 +04:00
|
|
|
int main()
|
2004-02-13 21:05:49 +03:00
|
|
|
{
|
|
|
|
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;
|
2005-07-09 22:52:53 +04:00
|
|
|
}], [AS_TR_SH([ompi_cv_c_align_$1])=`cat conftestval`],
|
|
|
|
[AC_MSG_WARN([*** Problem running configure test!])
|
|
|
|
AC_MSG_WARN([*** See config.log for details.])
|
|
|
|
AC_MSG_ERROR([*** Cannot continue.])],
|
|
|
|
[ # cross compile - do a non-executable test. Trick
|
2006-04-14 19:33:51 +04:00
|
|
|
# taken from the Autoconf 2.59c. Switch to using
|
|
|
|
# AC_CHECK_ALIGNOF when we can require Autoconf 2.60.
|
|
|
|
_AC_COMPUTE_INT([(long int) offsetof (ompi__type_alignof_, y)],
|
2005-07-09 22:52:53 +04:00
|
|
|
[AS_TR_SH([ompi_cv_c_align_$1])],
|
2006-04-14 19:33:51 +04:00
|
|
|
[AC_INCLUDES_DEFAULT
|
2005-07-04 21:34:24 +04:00
|
|
|
#ifndef offsetof
|
|
|
|
# define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0)
|
2005-07-09 22:52:53 +04:00
|
|
|
#endif
|
2006-04-14 19:33:51 +04:00
|
|
|
typedef struct { char x; $1 y; } ompi__type_alignof_;
|
2005-07-09 22:52:53 +04:00
|
|
|
],
|
|
|
|
[AC_MSG_WARN([*** Problem running configure test!])
|
|
|
|
AC_MSG_WARN([*** See config.log for details.])
|
|
|
|
AC_MSG_ERROR([*** Cannot continue.])])])])
|
2004-02-13 21:05:49 +03:00
|
|
|
|
2005-07-09 22:52:53 +04:00
|
|
|
AC_DEFINE_UNQUOTED([$2], [$AS_TR_SH([ompi_cv_c_align_$1])], [Alignment of type $1])
|
|
|
|
eval "$2=$AS_TR_SH([ompi_cv_c_align_$1])"
|
2004-02-13 21:05:49 +03:00
|
|
|
|
2007-11-06 15:20:58 +03:00
|
|
|
rm -rf conftest* ]) dnl
|