|
Packit Service |
c5cf8c |
AC_PREREQ(2.63)
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
# (C) 2006 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
# See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AC_INIT([MPL], [0.1])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# sanity check that --srcdir was specified correctly
|
|
Packit Service |
c5cf8c |
AC_CONFIG_SRCDIR([src/str/mpl_str.c])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AC_CONFIG_AUX_DIR(confdb)
|
|
Packit Service |
c5cf8c |
AC_CONFIG_MACRO_DIR(confdb)
|
|
Packit Service |
c5cf8c |
AM_INIT_AUTOMAKE([subdir-objects] [-Wall -Werror foreign 1.12.3])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
dnl must come before LT_INIT, which AC_REQUIREs AC_PROG_CC
|
|
Packit Service |
c5cf8c |
PAC_PROG_CC
|
|
Packit Service |
c5cf8c |
AM_PROG_CC_C_O
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AC_USE_SYSTEM_EXTENSIONS
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AM_PROG_AR
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
LT_PREREQ([2.2.6])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Bug in libtool adds -O2 and -g by default
|
|
Packit Service |
c5cf8c |
PAC_PUSH_FLAG([CFLAGS])
|
|
Packit Service |
c5cf8c |
LT_INIT()
|
|
Packit Service |
c5cf8c |
PAC_POP_FLAG([CFLAGS])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# ----------------------------------------------------------------------------
|
|
Packit Service |
c5cf8c |
# Set default library names if names haven't already been provided
|
|
Packit Service |
c5cf8c |
AC_ARG_VAR([MPLLIBNAME],[can be used to override the name of the MPL library (default: "mpl")])
|
|
Packit Service |
c5cf8c |
MPLLIBNAME=${MPLLIBNAME:-"mpl"}
|
|
Packit Service |
c5cf8c |
AC_SUBST(MPLLIBNAME)
|
|
Packit Service |
c5cf8c |
export MPLLIBNAME
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if test -s "$srcdir/VERSION" ; then
|
|
Packit Service |
c5cf8c |
. $srcdir/VERSION
|
|
Packit Service |
c5cf8c |
AC_SUBST(libmpl_so_version)
|
|
Packit Service |
c5cf8c |
else
|
|
Packit Service |
c5cf8c |
AC_MSG_ERROR([Version information not found. Configuration aborted.])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AC_CONFIG_HEADER([include/config.h])
|
|
Packit Service |
c5cf8c |
AC_CONFIG_COMMANDS([prefix-config],[perl $srcdir/confdb/cmd_prefix_config_h.pl MPL include/config.h include/mplconfig.h])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Non-verbose make
|
|
Packit Service |
c5cf8c |
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AC_C_CONST
|
|
Packit Service |
c5cf8c |
AC_C_RESTRICT
|
|
Packit Service |
c5cf8c |
AC_C_INLINE
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
PAC_C_MACRO_VA_ARGS
|
|
Packit Service |
c5cf8c |
PAC_C_BUILTIN_EXPECT
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AC_ARG_ENABLE(embedded,
|
|
Packit Service |
c5cf8c |
AC_HELP_STRING([--enable-embedded], [Build MPL in embedded mode (default is no)]),
|
|
Packit Service |
c5cf8c |
[embedded=yes],
|
|
Packit Service |
c5cf8c |
[embedded=no])
|
|
Packit Service |
c5cf8c |
AM_CONDITIONAL([MPL_EMBEDDED_MODE],[test "x${embedded}" = "xyes"])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AC_ARG_ENABLE(g,
|
|
Packit Service |
c5cf8c |
AC_HELP_STRING([--enable-g=option],
|
|
Packit Service |
c5cf8c |
[
|
|
Packit Service |
c5cf8c |
Control the level of debugging support in MPL.
|
|
Packit Service |
c5cf8c |
"option" is a list of comma separated names. Default
|
|
Packit Service |
c5cf8c |
is "all".
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
none|no - No debugging
|
|
Packit Service |
c5cf8c |
log - Enable debug event logging
|
|
Packit Service |
c5cf8c |
mem - Enable memory tracing
|
|
Packit Service |
c5cf8c |
yes|all - All of the above choices (except "none", obviously)
|
|
Packit Service |
c5cf8c |
]),,[enable_g=none])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# enable-g
|
|
Packit Service |
c5cf8c |
# strip off multiple options, separated by commas
|
|
Packit Service |
c5cf8c |
PAC_PUSH_FLAG(IFS)
|
|
Packit Service |
c5cf8c |
IFS=","
|
|
Packit Service |
c5cf8c |
for option in $enable_g ; do
|
|
Packit Service |
c5cf8c |
case "$option" in
|
|
Packit Service |
c5cf8c |
log)
|
|
Packit Service |
c5cf8c |
enable_g_log=yes
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
mem)
|
|
Packit Service |
c5cf8c |
enable_g_mem=yes
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
all|yes)
|
|
Packit Service |
c5cf8c |
enable_g_log=yes
|
|
Packit Service |
c5cf8c |
enable_g_mem=yes
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
no|none)
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
*)
|
|
Packit Service |
c5cf8c |
AC_MSG_WARN([Unknown value $option for enable-g])
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
esac
|
|
Packit Service |
c5cf8c |
done
|
|
Packit Service |
c5cf8c |
PAC_POP_FLAG(IFS)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if test "$enable_g_log" = "yes" ; then
|
|
Packit Service |
c5cf8c |
AC_DEFINE([USE_DBG_LOGGING],[1],[Define to enable logging macros])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if test "$enable_g_mem" = "yes" ; then
|
|
Packit Service |
c5cf8c |
AC_DEFINE([USE_MEMORY_TRACING],[1],[Define to enable memory tracing])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# support gcov test coverage information
|
|
Packit Service |
c5cf8c |
PAC_ENABLE_COVERAGE
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# check for compiler support for the __typeof() extension
|
|
Packit Service |
c5cf8c |
AC_CACHE_CHECK([whether the compiler supports __typeof(variable)],
|
|
Packit Service |
c5cf8c |
[pac_cv_have___typeof],
|
|
Packit Service |
c5cf8c |
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[double foo = 0.0; __typeof(foo) bar = 1.0;]])],
|
|
Packit Service |
c5cf8c |
[pac_cv_have___typeof=yes],
|
|
Packit Service |
c5cf8c |
[pac_cv_have___typeof=no])]
|
|
Packit Service |
c5cf8c |
)
|
|
Packit Service |
c5cf8c |
if test "$pac_cv_have___typeof" = "yes" ; then
|
|
Packit Service |
c5cf8c |
AC_DEFINE([HAVE___TYPEOF],[1],[defined if the C compiler supports __typeof(variable)])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
dnl Check if the necessary headers are available
|
|
Packit Service |
c5cf8c |
AC_CHECK_HEADERS(stdio.h stdlib.h string.h stdarg.h ctype.h sys/types.h sys/uio.h execinfo.h unistd.h errno.h windows.h sys/mman.h)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# A C99 compliant compiler should have inttypes.h for fixed-size int types
|
|
Packit Service |
c5cf8c |
AC_CHECK_HEADERS(inttypes.h stdint.h)
|
|
Packit Service |
c5cf8c |
AC_HEADER_STDBOOL
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
# valgrind support
|
|
Packit Service |
c5cf8c |
AC_ARG_WITH([valgrind],
|
|
Packit Service |
c5cf8c |
[AS_HELP_STRING([--without-valgrind],[to disable valgrind support (such as because of version issues)])]
|
|
Packit Service |
c5cf8c |
[AS_HELP_STRING([--with-valgrind=PATH],[use valgrind headers installed in PATH (default is "yes", use no special path)])],
|
|
Packit Service |
c5cf8c |
[],[with_valgrind=yes])
|
|
Packit Service |
c5cf8c |
if test "$with_valgrind" != "no" ; then
|
|
Packit Service |
c5cf8c |
savedCPPFLAGS="$CPPFLAGS"
|
|
Packit Service |
c5cf8c |
if test "$with_valgrind" != "yes" ; then
|
|
Packit Service |
c5cf8c |
# Clients of MPL will either need to respect the localdefs file (as in
|
|
Packit Service |
c5cf8c |
# MPICH) or add this entry to their own CPPFLAGS-equivalent.
|
|
Packit Service |
c5cf8c |
# (TODO: a pkg-config file would help with this)
|
|
Packit Service |
c5cf8c |
PAC_APPEND_FLAG([-I${with_valgrind}], [CPPFLAGS])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
# headers for valgrind client requests
|
|
Packit Service |
c5cf8c |
AC_CHECK_HEADERS([valgrind.h memcheck.h valgrind/valgrind.h valgrind/memcheck.h])
|
|
Packit Service |
c5cf8c |
# headers for valgrind-based thread checking tools
|
|
Packit Service |
c5cf8c |
# TODO: incorporate ThreadSanitizer as well (include dynamic_annotations.h,
|
|
Packit Service |
c5cf8c |
# link with dynamic_annotations.c)
|
|
Packit Service |
c5cf8c |
AC_CHECK_HEADERS([helgrind.h valgrind/helgrind.h])
|
|
Packit Service |
c5cf8c |
AC_CHECK_HEADERS([drd.h valgrind/drd.h])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# ensure that we have a new enough valgrind with all the client macros
|
|
Packit Service |
c5cf8c |
# a preproc test would probably be sufficient, but the LINK_IFELSE helps us
|
|
Packit Service |
c5cf8c |
# double-check that we aren't accidentally grabbing the headers for some
|
|
Packit Service |
c5cf8c |
# other platform
|
|
Packit Service |
c5cf8c |
AC_CACHE_CHECK([whether the valgrind headers are broken or too old],
|
|
Packit Service |
c5cf8c |
[pac_cv_have_broken_valgrind],
|
|
Packit Service |
c5cf8c |
[AC_LINK_IFELSE(
|
|
Packit Service |
c5cf8c |
[AC_LANG_PROGRAM([
|
|
Packit Service |
c5cf8c |
#if defined(HAVE_VALGRIND_H) && defined(HAVE_MEMCHECK_H)
|
|
Packit Service |
c5cf8c |
# include <valgrind.h>
|
|
Packit Service |
c5cf8c |
# include <memcheck.h>
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_VALGRIND_VALGRIND_H) && defined(HAVE_VALGRIND_MEMCHECK_H)
|
|
Packit Service |
c5cf8c |
# include <valgrind/valgrind.h>
|
|
Packit Service |
c5cf8c |
# include <valgrind/memcheck.h>
|
|
Packit Service |
c5cf8c |
#else
|
|
Packit Service |
c5cf8c |
# error unexpected valgrind header error
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
int foo = 10;
|
|
Packit Service |
c5cf8c |
char mempool_obj;
|
|
Packit Service |
c5cf8c |
],[
|
|
Packit Service |
c5cf8c |
#if defined(VALGRIND_MAKE_MEM_DEFINED)
|
|
Packit Service |
c5cf8c |
VALGRIND_MAKE_MEM_NOACCESS(&foo,sizeof(foo));
|
|
Packit Service |
c5cf8c |
VALGRIND_MAKE_MEM_UNDEFINED(&foo,sizeof(foo));
|
|
Packit Service |
c5cf8c |
VALGRIND_MAKE_MEM_DEFINED(&foo,sizeof(foo));
|
|
Packit Service |
c5cf8c |
VALGRIND_CHECK_MEM_IS_DEFINED(&foo,sizeof(foo));
|
|
Packit Service |
c5cf8c |
VALGRIND_CHECK_MEM_IS_ADDRESSABLE(&foo,sizeof(foo));
|
|
Packit Service |
c5cf8c |
#elif defined(VALGRIND_MAKE_READABLE)
|
|
Packit Service |
c5cf8c |
/* older (pre-3.2.0), but still supported style */
|
|
Packit Service |
c5cf8c |
VALGRIND_MAKE_READABLE(&foo,sizeof(foo));
|
|
Packit Service |
c5cf8c |
VALGRIND_MAKE_NOACCESS(&foo,sizeof(foo));
|
|
Packit Service |
c5cf8c |
VALGRIND_MAKE_UNDEFINED(&foo,sizeof(foo));
|
|
Packit Service |
c5cf8c |
VALGRIND_CHECK_READABLE(&foo,sizeof(foo));
|
|
Packit Service |
c5cf8c |
VALGRIND_CHECK_WRITEABLE(&foo,sizeof(foo));
|
|
Packit Service |
c5cf8c |
#else
|
|
Packit Service |
c5cf8c |
#error missing essential valgrind client macros
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
VALGRIND_CREATE_BLOCK(&foo,sizeof(foo),"description");
|
|
Packit Service |
c5cf8c |
if (RUNNING_ON_VALGRIND) ++foo;
|
|
Packit Service |
c5cf8c |
VALGRIND_PRINTF_BACKTRACE("testing: %s","valgrind support");
|
|
Packit Service |
c5cf8c |
VALGRIND_CREATE_MEMPOOL(&mempool_obj,0,0);
|
|
Packit Service |
c5cf8c |
VALGRIND_MEMPOOL_ALLOC(&mempool_obj,&foo,sizeof(foo));
|
|
Packit Service |
c5cf8c |
VALGRIND_MEMPOOL_FREE(&mempool_obj,&foo;;
|
|
Packit Service |
c5cf8c |
VALGRIND_DESTROY_MEMPOOL(&mempool_obj);
|
|
Packit Service |
c5cf8c |
]) dnl end PROGRAM
|
|
Packit Service |
c5cf8c |
],
|
|
Packit Service |
c5cf8c |
[pac_cv_have_broken_valgrind=no], dnl end if-true
|
|
Packit Service |
c5cf8c |
[pac_cv_have_broken_valgrind=yes] dnl end if-false
|
|
Packit Service |
c5cf8c |
)] dnl end IFELSE
|
|
Packit Service |
c5cf8c |
) dnl end CACHE_CHECK
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if test "$pac_cv_have_broken_valgrind" = "yes" ; then
|
|
Packit Service |
c5cf8c |
AC_DEFINE([HAVE_BROKEN_VALGRIND],[1],[define if valgrind is old and/or broken compared to what we are expecting])
|
|
Packit Service |
c5cf8c |
CPPFLAGS="$savedCPPFLAGS"
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
## TIMER CODE
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# ----------------------------------------------------------------------------
|
|
Packit Service |
c5cf8c |
# Support for timers. The following code processes the
|
|
Packit Service |
c5cf8c |
# --enable-timer-type=name argument and selects the timer based on
|
|
Packit Service |
c5cf8c |
# both that field and what configure is able to determine is available.
|
|
Packit Service |
c5cf8c |
# The file src/include/mpl_timer.h is also created.
|
|
Packit Service |
c5cf8c |
# ----------------------------------------------------------------------------
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# clock_gettime is the POSIX gettimeofday
|
|
Packit Service |
c5cf8c |
# gethrtime is the Solaris high-resolution timer
|
|
Packit Service |
c5cf8c |
dnl
|
|
Packit Service |
c5cf8c |
dnl Specific checks that a function works correctly
|
|
Packit Service |
c5cf8c |
dnl
|
|
Packit Service |
c5cf8c |
dnl Now that we know what the options are, choose the timer to use
|
|
Packit Service |
c5cf8c |
dnl
|
|
Packit Service |
c5cf8c |
dnl The default preference is
|
|
Packit Service |
c5cf8c |
dnl Solaris gethrtime
|
|
Packit Service |
c5cf8c |
dnl Posix clock_gettime
|
|
Packit Service |
c5cf8c |
dnl Unix gettimeofday (one of two versions)
|
|
Packit Service |
c5cf8c |
dnl
|
|
Packit Service |
c5cf8c |
dnl Also available are various hardware time stamps
|
|
Packit Service |
c5cf8c |
dnl Linux-x86 cycle counter
|
|
Packit Service |
c5cf8c |
dnl Powerpc-64bit timebase cycle counter
|
|
Packit Service |
c5cf8c |
dnl
|
|
Packit Service |
c5cf8c |
dnl We also allow --enable-timer-type=name to select a timer type
|
|
Packit Service |
c5cf8c |
AC_ARG_ENABLE(timer-type,
|
|
Packit Service |
c5cf8c |
[ --enable-timer-type=name - Select the timer to use for MPI_Wtime and
|
|
Packit Service |
c5cf8c |
internal timestamps.
|
|
Packit Service |
c5cf8c |
ppc64_cycle - Powerpc-64bit; returns cycle counts using timebase register
|
|
Packit Service |
c5cf8c |
gethrtime - Solaris timer (Solaris systems only)
|
|
Packit Service |
c5cf8c |
clock_gettime - Posix timer (where available)
|
|
Packit Service |
c5cf8c |
gettimeofday - Most Unix systems
|
|
Packit Service |
c5cf8c |
linux86_cycle - Linux x86; returns cycle counts, not time in seconds*
|
|
Packit Service |
c5cf8c |
gcc_ia64_cycle - IPF ar.itc timer*
|
|
Packit Service |
c5cf8c |
mach_absolute_time - Mach absolute time (alternative to clock_gettime
|
|
Packit Service |
c5cf8c |
for OSX)
|
|
Packit Service |
c5cf8c |
device - The timer is provided by the device
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
*Note that the cycle timers are intended to be used by
|
|
Packit Service |
c5cf8c |
developers for internal low-level timing. Normal users should
|
|
Packit Service |
c5cf8c |
not use these as they are not guaranteed to be accurate in
|
|
Packit Service |
c5cf8c |
certain situations.
|
|
Packit Service |
c5cf8c |
],timer_type=$enable_timer_type)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
## The user did not specify a timer type. Try to find a sane option
|
|
Packit Service |
c5cf8c |
## that is supported by the platform.
|
|
Packit Service |
c5cf8c |
if test -z "$timer_type" ; then
|
|
Packit Service |
c5cf8c |
# Try to pick a timer based on what is available
|
|
Packit Service |
c5cf8c |
AC_CHECK_FUNCS(clock_gettime clock_getres gethrtime mach_absolute_time gettimeofday)
|
|
Packit Service |
c5cf8c |
if test "$ac_cv_func_gethrtime" = "yes" ; then
|
|
Packit Service |
c5cf8c |
# Sigh. The Solaris include files do not define hrtime_t
|
|
Packit Service |
c5cf8c |
# Before we accept this choice, make sure that we can
|
|
Packit Service |
c5cf8c |
# do arithmetic with hrtime_t .
|
|
Packit Service |
c5cf8c |
AC_CACHE_CHECK([that hrtime_t is properly defined for gethrtime],
|
|
Packit Service |
c5cf8c |
pac_cv_hrtime_works,[
|
|
Packit Service |
c5cf8c |
AC_TRY_COMPILE([
|
|
Packit Service |
c5cf8c |
#include <sys/time.h>
|
|
Packit Service |
c5cf8c |
],[hrtime_t t1, t2; t1 = 1; t2 = 2; t1 = t1 + t2;],
|
|
Packit Service |
c5cf8c |
pac_cv_hrtime_works=yes,pac_cv_hrtime_works=no)])
|
|
Packit Service |
c5cf8c |
# A more ambitious test would look to see if casting an
|
|
Packit Service |
c5cf8c |
# hrtime_t to int64_t works, and even more ambitious
|
|
Packit Service |
c5cf8c |
# would check whether long or long long was 64 bits (or even
|
|
Packit Service |
c5cf8c |
# better, the sizeof hrtime_t).
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# AC_CHECK_FUNCS has false positive when checking whether gethrtime is
|
|
Packit Service |
c5cf8c |
# available on Solaris with strict configuration. We must use
|
|
Packit Service |
c5cf8c |
# AC_CHECK_DECL to confirm it.
|
|
Packit Service |
c5cf8c |
AC_CHECK_DECL(gethrtime)
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
if test "$ac_cv_func_gethrtime" = "yes" -a \
|
|
Packit Service |
c5cf8c |
"$ac_cv_has_decl_gethrtime" = "yes" -a \
|
|
Packit Service |
c5cf8c |
"$pac_cv_hrtime_works" = "yes" ; then
|
|
Packit Service |
c5cf8c |
timer_type=gethrtime
|
|
Packit Service |
c5cf8c |
elif test "$ac_cv_func_clock_gettime" = "yes" -a \
|
|
Packit Service |
c5cf8c |
"$ac_cv_func_clock_getres" = "yes" ; then
|
|
Packit Service |
c5cf8c |
# Test on both because some systems (e.g., cygwin) provide
|
|
Packit Service |
c5cf8c |
# clock_gettime but not clock_getres
|
|
Packit Service |
c5cf8c |
timer_type=clock_gettime
|
|
Packit Service |
c5cf8c |
elif test "$ac_cv_func_mach_absolute_time" = "yes" ; then
|
|
Packit Service |
c5cf8c |
timer_type=mach_absolute_time
|
|
Packit Service |
c5cf8c |
elif test "$ac_cv_func_gettimeofday" = "yes" ; then
|
|
Packit Service |
c5cf8c |
timer_type=gettimeofday
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
if test -z "$timer_type" ; then
|
|
Packit Service |
c5cf8c |
AC_MSG_ERROR([No timer found])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Check for valid timer and select datatypes for the time stamp
|
|
Packit Service |
c5cf8c |
case "$timer_type" in
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
gethrtime)
|
|
Packit Service |
c5cf8c |
MPL_TIMER_TYPE=hrtime_t
|
|
Packit Service |
c5cf8c |
AC_CHECK_FUNC(gethrtime,,[
|
|
Packit Service |
c5cf8c |
AC_MSG_ERROR([Requested timer gethrtime is not available])
|
|
Packit Service |
c5cf8c |
])
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
clock_gettime)
|
|
Packit Service |
c5cf8c |
missing_function=no
|
|
Packit Service |
c5cf8c |
AC_SEARCH_LIBS([clock_gettime],[rt],,AC_MSG_ERROR([clock_gettime is not available]))
|
|
Packit Service |
c5cf8c |
AC_SEARCH_LIBS([clock_getres],[rt],,AC_MSG_ERROR([clock_getres is not available]))
|
|
Packit Service |
c5cf8c |
MPL_TIMER_TYPE="struct timespec"
|
|
Packit Service |
c5cf8c |
# AIX does not always define struct timespec (!)
|
|
Packit Service |
c5cf8c |
# Make sure that we can use struct timespec
|
|
Packit Service |
c5cf8c |
AC_CACHE_CHECK([whether struct timespec is defined in time.h],
|
|
Packit Service |
c5cf8c |
pac_cv_struct_timespec_defined,[
|
|
Packit Service |
c5cf8c |
AC_TRY_COMPILE([
|
|
Packit Service |
c5cf8c |
#include <time.h>],[
|
|
Packit Service |
c5cf8c |
struct timespec t;],pac_cv_struct_timespec_defined=yes,
|
|
Packit Service |
c5cf8c |
pac_cv_struct_timespec_defined=no)
|
|
Packit Service |
c5cf8c |
])
|
|
Packit Service |
c5cf8c |
if test "$pac_cv_struct_timespec_defined" != "yes" ; then
|
|
Packit Service |
c5cf8c |
# Try again, but with -D_XOPEN_SOURCE=500 (works for AIX)
|
|
Packit Service |
c5cf8c |
AC_CACHE_CHECK([whether struct timespec is defined in time.h with _XOPEN_SOURCE=500],
|
|
Packit Service |
c5cf8c |
pac_cv_struct_timespec_defined_with_xopen500,[
|
|
Packit Service |
c5cf8c |
AC_TRY_COMPILE([
|
|
Packit Service |
c5cf8c |
#define _XOPEN_SOURCE 500
|
|
Packit Service |
c5cf8c |
#include <time.h>],[
|
|
Packit Service |
c5cf8c |
struct timespec t;],pac_cv_struct_timespec_defined_with_xopen500=yes,
|
|
Packit Service |
c5cf8c |
pac_cv_struct_timespec_defined_with_xopen500=no)
|
|
Packit Service |
c5cf8c |
])
|
|
Packit Service |
c5cf8c |
if test "$pac_cv_struct_timespec_defined_with_xopen500" = "yes" ; then
|
|
Packit Service |
c5cf8c |
# We need to define _XOPEN_SOURCE=500, but we need to ensure that
|
|
Packit Service |
c5cf8c |
# this is done before any include files are loaded. At
|
|
Packit Service |
c5cf8c |
# this point it is really too late to add this definition,
|
|
Packit Service |
c5cf8c |
# since it may make other tests incompatible.
|
|
Packit Service |
c5cf8c |
AC_MSG_ERROR([The available timer requires _XOPEN_SOURCE=500. Add -D_XOPEN_SOURCE=500 to CFLAGS and rerun configure])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
# FreeBSD 4.3 incorrectly puts the header into sys/time.h;
|
|
Packit Service |
c5cf8c |
# time.h is required (see pages 45 and 46 in the POSIX standard).
|
|
Packit Service |
c5cf8c |
# See if we can compile
|
|
Packit Service |
c5cf8c |
AC_CACHE_CHECK([for CLOCK_REALTIME defined in time.h],pac_cv_posix_clock_realtime,[
|
|
Packit Service |
c5cf8c |
AC_TRY_COMPILE([
|
|
Packit Service |
c5cf8c |
#include <time.h>],[
|
|
Packit Service |
c5cf8c |
clockid_t cid = CLOCK_REALTIME;],pac_cv_posix_clock_realtime=yes,
|
|
Packit Service |
c5cf8c |
pac_cv_posix_clock_realtime=no)])
|
|
Packit Service |
c5cf8c |
if test "$pac_cv_posix_clock_realtime" = "no" ; then
|
|
Packit Service |
c5cf8c |
AC_MSG_WARN([POSIX timer requires definitions in time.h])
|
|
Packit Service |
c5cf8c |
# Check for the definition in sys/time.h, which is where
|
|
Packit Service |
c5cf8c |
# OpenBSD and FreeBSD have put it by mistake
|
|
Packit Service |
c5cf8c |
AC_TRY_COMPILE([
|
|
Packit Service |
c5cf8c |
#include <time.h>
|
|
Packit Service |
c5cf8c |
#include <sys/time.h>],[
|
|
Packit Service |
c5cf8c |
clockid_t cid = CLOCK_REALTIME;],pac_cv_posix_clock_realtime=yes,
|
|
Packit Service |
c5cf8c |
pac_cv_posix_clock_realtime=no)
|
|
Packit Service |
c5cf8c |
if test "$pac_cv_posix_clock_realtime" = yes ; then
|
|
Packit Service |
c5cf8c |
AC_MSG_WARN([sys/time.h required for POSIX timer])
|
|
Packit Service |
c5cf8c |
AC_DEFINE(NEEDS_SYS_TIME_H,1,[Define if sys/time.h is required to get timer definitions])
|
|
Packit Service |
c5cf8c |
else
|
|
Packit Service |
c5cf8c |
AC_MSG_ERROR([Cannot find the definition of CLOCK_REALTIME for the POSIX timer])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
gettimeofday)
|
|
Packit Service |
c5cf8c |
MPL_TIMER_TYPE="struct timeval"
|
|
Packit Service |
c5cf8c |
# We may have already tested for gettimeofday. If we got a "yes",
|
|
Packit Service |
c5cf8c |
# we're good to go
|
|
Packit Service |
c5cf8c |
if test "$ac_cv_func_gettimeofday" != "yes" ; then
|
|
Packit Service |
c5cf8c |
AC_CHECK_FUNC(gettimeofday,,[
|
|
Packit Service |
c5cf8c |
AC_MSG_ERROR([Requested timer gettimeofday is not available])
|
|
Packit Service |
c5cf8c |
])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
linux86_cycle|linux86_cycle_2)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# The following AC_TRY_RUN statements are needed because x86_64 compilers
|
|
Packit Service |
c5cf8c |
# usually know about rdtscp but the cpu may or may not actually implement the
|
|
Packit Service |
c5cf8c |
# feature. This is not cross-compile safe, unfortunately. In the long run we
|
|
Packit Service |
c5cf8c |
# should allow the user to override this with a configure flag.
|
|
Packit Service |
c5cf8c |
AC_CACHE_CHECK([that linux86 cycle counter is available],
|
|
Packit Service |
c5cf8c |
pac_cv_linux86_cycle,
|
|
Packit Service |
c5cf8c |
AC_TRY_RUN([
|
|
Packit Service |
c5cf8c |
int main()
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
/* rdtscp */
|
|
Packit Service |
c5cf8c |
long long var, *var_ptr=&var;
|
|
Packit Service |
c5cf8c |
__asm__ __volatile__("rdtscp; shl \$32, %%rdx; or %%rdx, %%rax" : "=a" (*var_ptr) : : "ecx", "rdx");
|
|
Packit Service |
c5cf8c |
return 0;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
],pac_cv_linux86_cycle=rdtscp,
|
|
Packit Service |
c5cf8c |
AC_TRY_RUN([[
|
|
Packit Service |
c5cf8c |
int main()
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
/* cpuid 64 */
|
|
Packit Service |
c5cf8c |
long long var, *var_ptr=&var;
|
|
Packit Service |
c5cf8c |
__asm__ __volatile__("push %%rbx ; cpuid ; rdtsc ; pop %%rbx ; shl $32, %%rdx; or %%rdx, %%rax" : "=a" (*var_ptr) : : "ecx", "rdx");
|
|
Packit Service |
c5cf8c |
return 0;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
]],pac_cv_linux86_cycle=cpuid_rdtsc64,
|
|
Packit Service |
c5cf8c |
AC_TRY_RUN([[[
|
|
Packit Service |
c5cf8c |
int main()
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
/* cpuid 32 */
|
|
Packit Service |
c5cf8c |
long long var, *var_ptr=&var;
|
|
Packit Service |
c5cf8c |
__asm__ __volatile__("push %%ebx ; cpuid ; rdtsc ; pop %%ebx" : "=A" (*var_ptr) : : "ecx");
|
|
Packit Service |
c5cf8c |
return 0;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
]]],pac_cv_linux86_cycle=cpuid_rdtsc32,
|
|
Packit Service |
c5cf8c |
AC_TRY_RUN([[[[
|
|
Packit Service |
c5cf8c |
int main()
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
/* simple */
|
|
Packit Service |
c5cf8c |
long long var, *var_ptr=&var;
|
|
Packit Service |
c5cf8c |
__asm__ __volatile__("rdtsc" : "=A" (*var_ptr));
|
|
Packit Service |
c5cf8c |
return 0;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
]]]],pac_cv_linux86_cycle=rdtsc,
|
|
Packit Service |
c5cf8c |
pac_cv_linux86_cycle=no)
|
|
Packit Service |
c5cf8c |
)
|
|
Packit Service |
c5cf8c |
),
|
|
Packit Service |
c5cf8c |
dnl The if-cross-compiling clause from the first AC_TRY_RUN. Hope that if the
|
|
Packit Service |
c5cf8c |
dnl compiler knows about the instruction then it's supported by the target
|
|
Packit Service |
c5cf8c |
dnl platform.
|
|
Packit Service |
c5cf8c |
AC_TRY_COMPILE(,[[
|
|
Packit Service |
c5cf8c |
long long var, *var_ptr=&var;
|
|
Packit Service |
c5cf8c |
__asm__ __volatile__("rdtscp; shl \$32, %%rdx; or %%rdx, %%rax" : "=a" (*var_ptr) : : "ecx", "rdx");
|
|
Packit Service |
c5cf8c |
]],pac_cv_linux86_cycle=rdtscp,
|
|
Packit Service |
c5cf8c |
AC_TRY_COMPILE(,[[[
|
|
Packit Service |
c5cf8c |
long long var, *var_ptr=&var;
|
|
Packit Service |
c5cf8c |
__asm__ __volatile__("push %%rbx ; cpuid ; rdtsc ; pop %%rbx ; shl $32, %%rdx; or %%rdx, %%rax" : "=a" (*var_ptr) : : "ecx", "rdx");
|
|
Packit Service |
c5cf8c |
]]],pac_cv_linux86_cycle=cpuid_rdtsc64,
|
|
Packit Service |
c5cf8c |
AC_TRY_COMPILE(,[[[[
|
|
Packit Service |
c5cf8c |
long long var, *var_ptr=&var;
|
|
Packit Service |
c5cf8c |
__asm__ __volatile__("push %%ebx ; cpuid ; rdtsc ; pop %%ebx" : "=A" (*var_ptr) : : "ecx");
|
|
Packit Service |
c5cf8c |
]]]],pac_cv_linux86_cycle=cpuid_rdtsc32,
|
|
Packit Service |
c5cf8c |
AC_TRY_COMPILE(,[[[[[
|
|
Packit Service |
c5cf8c |
long long var, *var_ptr=&var;
|
|
Packit Service |
c5cf8c |
__asm__ __volatile__("rdtsc" : "=A" (*var_ptr));
|
|
Packit Service |
c5cf8c |
]]]]],pac_cv_linux86_cycle=rdtsc,
|
|
Packit Service |
c5cf8c |
pac_cv_linux86_cycle=no)
|
|
Packit Service |
c5cf8c |
)
|
|
Packit Service |
c5cf8c |
)
|
|
Packit Service |
c5cf8c |
)
|
|
Packit Service |
c5cf8c |
)
|
|
Packit Service |
c5cf8c |
)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
case "$pac_cv_linux86_cycle" in
|
|
Packit Service |
c5cf8c |
"rdtscp")
|
|
Packit Service |
c5cf8c |
AC_DEFINE(LINUX86_CYCLE_RDTSCP,1,[Define which x86 cycle counter to use])
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
"cpuid_rdtsc64")
|
|
Packit Service |
c5cf8c |
AC_DEFINE(LINUX86_CYCLE_CPUID_RDTSC64,1,[Define which x86 cycle counter to use])
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
"cpuid_rdtsc32")
|
|
Packit Service |
c5cf8c |
AC_DEFINE(LINUX86_CYCLE_CPUID_RDTSC32,1,[Define which x86 cycle counter to use])
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
"rdtsc")
|
|
Packit Service |
c5cf8c |
AC_DEFINE(LINUX86_CYCLE_RDTSC,1,[Define which x86 cycle counter to use])
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
*)
|
|
Packit Service |
c5cf8c |
cpu_gcc_x86_cycle=no
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
esac
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if test "$cpu_gcc_x86_cycle" = "no" ; then
|
|
Packit Service |
c5cf8c |
AC_MSG_ERROR([Linux86 cycle counter is not available on this system and or with the $CC compiler])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
MPL_TIMER_TYPE="long long"
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
gcc_ia64_cycle)
|
|
Packit Service |
c5cf8c |
AC_CACHE_CHECK([that IPF timer is available],
|
|
Packit Service |
c5cf8c |
pac_cv_ia64_cycle,[
|
|
Packit Service |
c5cf8c |
AC_TRY_COMPILE(,[
|
|
Packit Service |
c5cf8c |
long var, *var_ptr=&var;
|
|
Packit Service |
c5cf8c |
#ifdef __INTEL_COMPILER
|
|
Packit Service |
c5cf8c |
#include "ia64regs.h"
|
|
Packit Service |
c5cf8c |
var=__getReg(_IA64_REG_AR_ITC);
|
|
Packit Service |
c5cf8c |
#else
|
|
Packit Service |
c5cf8c |
__asm__ __volatile__("mov %0=ar.itc" : "=r" (var_ptr));
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
],pac_cv_gcc_ia64_cycle=yes,pac_cv_gcc_ia64_cycle=no)])
|
|
Packit Service |
c5cf8c |
if test "$pac_cv_gcc_ia64_cycle" != "yes" ; then
|
|
Packit Service |
c5cf8c |
AC_MSG_ERROR([IPF cycle counter is not available on this system and or with the $CC compiler])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
MPL_TIMER_TYPE="long"
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
mach_absolute_time)
|
|
Packit Service |
c5cf8c |
AC_CHECK_FUNC(mach_absolute_time,,[AC_MSG_ERROR([mach_absolute_time is not available])])
|
|
Packit Service |
c5cf8c |
AC_CHECK_FUNC(mach_timebase_info,,[AC_MSG_ERROR([mach_timebase_info is not available])])
|
|
Packit Service |
c5cf8c |
MPL_TIMER_TYPE="uint64_t"
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
device)
|
|
Packit Service |
c5cf8c |
# The device selected should export the datatype for the timer
|
|
Packit Service |
c5cf8c |
MPL_TIMER_TYPE="void *"
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
ppc64_cycle)
|
|
Packit Service |
c5cf8c |
AC_CACHE_CHECK([that ppc64 timebase cycle counter is available],
|
|
Packit Service |
c5cf8c |
pac_cv_ppc64_cycle,[
|
|
Packit Service |
c5cf8c |
AC_TRY_COMPILE([
|
|
Packit Service |
c5cf8c |
],[
|
|
Packit Service |
c5cf8c |
unsigned temp;
|
|
Packit Service |
c5cf8c |
asm volatile ("mfspr %0,%1" : "=r" (temp) : "i" (0x10D));
|
|
Packit Service |
c5cf8c |
],pac_cv_ppc64_cycle=yes,
|
|
Packit Service |
c5cf8c |
pac_cv_ppc64_cycle=no)
|
|
Packit Service |
c5cf8c |
])
|
|
Packit Service |
c5cf8c |
if test "$pac_cv_ppc64_cycle" != "yes" ; then
|
|
Packit Service |
c5cf8c |
AC_MSG_ERROR([The PPC64 cycle counter is not available on this system and or with the $CC compiler])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
MPL_TIMER_TYPE="uint64_t"
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
*)
|
|
Packit Service |
c5cf8c |
AC_MSG_ERROR([Invalid timer type $timer_type])
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
esac
|
|
Packit Service |
c5cf8c |
# Convert timer type to upper case
|
|
Packit Service |
c5cf8c |
timer_type=`echo $timer_type | \
|
|
Packit Service |
c5cf8c |
tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
|
|
Packit Service |
c5cf8c |
MPL_TIMER_KIND=MPL_TIMER_KIND__$timer_type
|
|
Packit Service |
c5cf8c |
AC_SUBST(MPL_TIMER_KIND)
|
|
Packit Service |
c5cf8c |
AC_SUBST(MPL_TIMER_TYPE)
|
|
Packit Service |
c5cf8c |
AC_MSG_NOTICE([Timer type selected is $timer_type])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
## END OF TIMER CODE
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
## START OF PROCESSOR YIELD CODE
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
# If the user specified a method to use, we check if it's available.
|
|
Packit Service |
c5cf8c |
# If a method was not specified, we make a guess based on the OS. The
|
|
Packit Service |
c5cf8c |
# default is to use sched_yield() or yield() if one is available,
|
|
Packit Service |
c5cf8c |
# otherwise, default to nothing. After that we define the appropriate
|
|
Packit Service |
c5cf8c |
# macro.
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AC_CHECK_HEADERS(sched.h)
|
|
Packit Service |
c5cf8c |
AC_CHECK_HEADERS(unistd.h)
|
|
Packit Service |
c5cf8c |
AC_CHECK_HEADERS(sys/select.h)
|
|
Packit Service |
c5cf8c |
AC_CHECK_FUNCS(sched_yield yield usleep sleep select)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if test "$ac_cv_func_usleep" = "yes" ; then
|
|
Packit Service |
c5cf8c |
PAC_FUNC_NEEDS_DECL([#include <unistd.h>],usleep)
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AC_ARG_ENABLE([yield],
|
|
Packit Service |
c5cf8c |
[AS_HELP_STRING([--enable-yield], [choose a method to yield the processor in busy loops. Available methods are: sched_yield, yield, select, usleep, sleep, nothing])],
|
|
Packit Service |
c5cf8c |
[AS_CASE([$enableval],
|
|
Packit Service |
c5cf8c |
[sched_yield], [AS_IF([test "x$ac_cv_func_sched_yield" != "xyes"], [enable_yield=unavail])],
|
|
Packit Service |
c5cf8c |
[yield], [AS_IF([test "x$ac_cv_func_yield" != "xyes"], [enable_yield=unavail])],
|
|
Packit Service |
c5cf8c |
[select], [AS_IF([test "x$ac_cv_func_select" != "xyes"], [enable_yield=unavail])],
|
|
Packit Service |
c5cf8c |
[usleep], [AS_IF([test "x$ac_cv_func_usleep" != "xyes"], [enable_yield=unavail])],
|
|
Packit Service |
c5cf8c |
[sleep], [AS_IF([test "x$ac_cv_func_sleep" != "xyes"], [enable_yield=unavail])],
|
|
Packit Service |
c5cf8c |
[nothing|no|none], [],
|
|
Packit Service |
c5cf8c |
[AC_MSG_ERROR([Invalid option $enableval for --enable-yield])])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AS_IF([test "x$enable_yield" = "xunavail"],
|
|
Packit Service |
c5cf8c |
[AC_MSG_ERROR([Yield method $enableval is not available on this platform.])])
|
|
Packit Service |
c5cf8c |
],
|
|
Packit Service |
c5cf8c |
[# none specified by user; make a guess based on os
|
|
Packit Service |
c5cf8c |
AS_CASE([$host],
|
|
Packit Service |
c5cf8c |
[*-*-darwin*],
|
|
Packit Service |
c5cf8c |
[# In Lion, sched_yield worked but none of the other options had any effect
|
|
Packit Service |
c5cf8c |
AS_IF([test "x$ac_cv_func_sched_yield" = "xyes"], [enable_yield=sched_yield],
|
|
Packit Service |
c5cf8c |
[enable_yield=nothing])],
|
|
Packit Service |
c5cf8c |
[*-*-linux*],
|
|
Packit Service |
c5cf8c |
[# sched_yield() has been broken in linux since 2.6.23, and no good alternative exists.
|
|
Packit Service |
c5cf8c |
enable_yield=nothing],
|
|
Packit Service |
c5cf8c |
[# default: just use sched_yield() or yield()
|
|
Packit Service |
c5cf8c |
AS_IF([test "x$ac_cv_func_sched_yield" = "xyes"], [enable_yield=sched_yield],
|
|
Packit Service |
c5cf8c |
[test "x$ac_cv_func_yield" = "xyes"], [enable_yield=yield],
|
|
Packit Service |
c5cf8c |
[enable_yield=nothing])])
|
|
Packit Service |
c5cf8c |
]
|
|
Packit Service |
c5cf8c |
)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# set the appropriate macro
|
|
Packit Service |
c5cf8c |
AS_CASE([$enable_yield],
|
|
Packit Service |
c5cf8c |
[sched_yield],
|
|
Packit Service |
c5cf8c |
[AC_DEFINE(USE_SCHED_YIELD_FOR_YIELD,1,[Define to use sched_yield to yield processor])],
|
|
Packit Service |
c5cf8c |
[yield],
|
|
Packit Service |
c5cf8c |
[AC_DEFINE(USE_YIELD_FOR_YIELD,1,[Define to use yield to yield processor])],
|
|
Packit Service |
c5cf8c |
[select],
|
|
Packit Service |
c5cf8c |
[AC_DEFINE(USE_SELECT_FOR_YIELD,1,[Define to use select to yield processor])],
|
|
Packit Service |
c5cf8c |
[usleep],
|
|
Packit Service |
c5cf8c |
[AC_DEFINE(USE_USLEEP_FOR_YIELD,1,[Define to use usleep to yield processor])],
|
|
Packit Service |
c5cf8c |
[sleep],
|
|
Packit Service |
c5cf8c |
[AC_DEFINE(USE_SLEEP_FOR_YIELD,1,[Define to use sleep to yield processor])],
|
|
Packit Service |
c5cf8c |
[nothing|no|none],
|
|
Packit Service |
c5cf8c |
[AC_DEFINE(USE_NOTHING_FOR_YIELD,1,[Define to use nothing to yield processor])],
|
|
Packit Service |
c5cf8c |
[AC_MSG_ERROR([Invalid value $enable_yield for enable_yield.])]
|
|
Packit Service |
c5cf8c |
)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
## END OF PROCESSOR YIELD CODE
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
## START OF THREADS CODE
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
PAC_SET_HEADER_LIB_PATH(uti)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AC_ARG_WITH([thread-package],
|
|
Packit Service |
c5cf8c |
[ --with-thread-package=package Thread package to use. Supported thread packages include:
|
|
Packit Service |
c5cf8c |
posix or pthreads - POSIX threads (default, if required)
|
|
Packit Service |
c5cf8c |
solaris - Solaris threads (Solaris OS only)
|
|
Packit Service |
c5cf8c |
abt or argobots - Argobots threads
|
|
Packit Service |
c5cf8c |
win - windows threads
|
|
Packit Service |
c5cf8c |
uti - POSIX threads plus Utility Thread Offloading library
|
|
Packit Service |
c5cf8c |
none - no threads
|
|
Packit Service |
c5cf8c |
],,with_thread_package=posix)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if test "${thread_pkg_required}" = "no" -o "${with_thread_package}" = "no" ; then
|
|
Packit Service |
c5cf8c |
with_thread_package=none
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if test "${with_thread_package}" = "yes" ; then
|
|
Packit Service |
c5cf8c |
with_thread_package=posix
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if test "${thread_pkg_required}" = "yes" -a "${with_thread_package}" = "none" ; then
|
|
Packit Service |
c5cf8c |
AC_ERROR([if no thread package is available, use --enable-threads=single or funneled])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
THREAD_PACKAGE_NAME=MPL_THREAD_PACKAGE_INVALID
|
|
Packit Service |
c5cf8c |
case $with_thread_package in
|
|
Packit Service |
c5cf8c |
posix|pthreads|uti)
|
|
Packit Service |
c5cf8c |
if test "${with_thread_package}" = "pthreads" ; then
|
|
Packit Service |
c5cf8c |
with_thread_package=posix
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
AC_CHECK_HEADERS(pthread.h)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# If pthreads library is found, just include it on the link line. We don't try
|
|
Packit Service |
c5cf8c |
# to test if the C compiler needs it or not, since the C++ or Fortran
|
|
Packit Service |
c5cf8c |
# compilers might need it even if the C compiler doesn't
|
|
Packit Service |
c5cf8c |
# (nvcc with gfortran, for example).
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
# OSF1 has __pthread_create but not pthread_create (because of
|
|
Packit Service |
c5cf8c |
# inconsistencies in the pthread spec). Thus, we look for pthread_key_create
|
|
Packit Service |
c5cf8c |
AC_CHECK_LIB([pthread],[pthread_key_create],have_pthreads=yes)
|
|
Packit Service |
c5cf8c |
if test "$have_pthreads" = "yes" ; then
|
|
Packit Service |
c5cf8c |
PAC_PREPEND_FLAG([-lpthread],[LIBS])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AC_CHECK_FUNCS(pthread_yield)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# this check should come after the AC_CHECK_LIB for -lpthread
|
|
Packit Service |
c5cf8c |
AC_CHECK_FUNC([pthread_key_create],[],[AC_MSG_ERROR([unable to find pthreads library])])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Check for a routine that specify a routine to call on
|
|
Packit Service |
c5cf8c |
# thread exit. We can use this to release memory that may
|
|
Packit Service |
c5cf8c |
# be allocated by the MPL library in the thread.
|
|
Packit Service |
c5cf8c |
# A complication: pthread_cleanup_push may be a macro; in that
|
|
Packit Service |
c5cf8c |
# case, check_funcs will fail to find it.
|
|
Packit Service |
c5cf8c |
# Under OSX, pthread_cleanup_push and pop are macros that must
|
|
Packit Service |
c5cf8c |
# appear together in the same lexical scope, and hence are
|
|
Packit Service |
c5cf8c |
# really useless in libraries that may allocate data within
|
|
Packit Service |
c5cf8c |
# a user-managed thread.
|
|
Packit Service |
c5cf8c |
AC_CHECK_FUNCS(pthread_cleanup_push)
|
|
Packit Service |
c5cf8c |
if test "$ac_cv_func_pthread_cleanup_push" = "no" ; then
|
|
Packit Service |
c5cf8c |
AC_CACHE_CHECK([whether pthread_cleanup_push is available (may be a macro in pthread.h)],pac_cv_func_pthread_cleanup_push,[
|
|
Packit Service |
c5cf8c |
AC_TRY_LINK([
|
|
Packit Service |
c5cf8c |
#include <pthread.h>
|
|
Packit Service |
c5cf8c |
void f1(void *a) { return; }],
|
|
Packit Service |
c5cf8c |
[pthread_cleanup_push( f1, (void *)0 );],
|
|
Packit Service |
c5cf8c |
pac_cv_func_pthread_cleanup_push=yes,
|
|
Packit Service |
c5cf8c |
pac_cv_func_pthread_cleanup_push=no)])
|
|
Packit Service |
c5cf8c |
if test "$pac_cv_func_pthread_cleanup_push" = yes ; then
|
|
Packit Service |
c5cf8c |
AC_DEFINE(HAVE_PTHREAD_CLEANUP_PUSH_MACRO,1,[Define if pthread_cleanup_push is available, even as a macro])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if test "${with_thread_package}" = "uti" ; then
|
|
Packit Service |
c5cf8c |
PAC_CHECK_HEADER_LIB(uti.h,uti,uti_attr_init,have_uti=yes,have_uti=no)
|
|
Packit Service |
c5cf8c |
if test "${have_uti}" = "yes" ; then
|
|
Packit Service |
c5cf8c |
AC_MSG_NOTICE([Using POSIX and Utility Thread Offloading library for thread package])
|
|
Packit Service |
c5cf8c |
else
|
|
Packit Service |
c5cf8c |
AC_MSG_ERROR([Unable to find Utility Thread Offloading library])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
THREAD_PACKAGE_NAME=MPL_THREAD_PACKAGE_UTI
|
|
Packit Service |
c5cf8c |
else
|
|
Packit Service |
c5cf8c |
AC_MSG_NOTICE([POSIX will be used for thread package.])
|
|
Packit Service |
c5cf8c |
THREAD_PACKAGE_NAME=MPL_THREAD_PACKAGE_POSIX
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
solaris)
|
|
Packit Service |
c5cf8c |
AC_CHECK_HEADERS(thread.h)
|
|
Packit Service |
c5cf8c |
AC_CHECK_FUNCS(thr_yield)
|
|
Packit Service |
c5cf8c |
AC_SEARCH_LIBS(thr_create,thread,found=yes,found=no)
|
|
Packit Service |
c5cf8c |
if test "$found" != "yes" ; then
|
|
Packit Service |
c5cf8c |
AC_MSG_ERROR([unable to find Solaris threads library])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
# FIXME: need to add -mt if using solaris compilers
|
|
Packit Service |
c5cf8c |
THREAD_PACKAGE_NAME=MPL_THREAD_PACKAGE_SOLARIS
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
win|windows)
|
|
Packit Service |
c5cf8c |
with_thread_package=win
|
|
Packit Service |
c5cf8c |
THREAD_PACKAGE_NAME=MPL_THREAD_PACKAGE_WIN
|
|
Packit Service |
c5cf8c |
AC_MSG_ERROR([The 'win' thread package is not supported via autoconf builds at this time.])
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
abt|argobots)
|
|
Packit Service |
c5cf8c |
with_thread_package=argobots
|
|
Packit Service |
c5cf8c |
AC_CHECK_HEADER([abt.h],[],AC_MSG_ERROR([unable to find Argobots header file]))
|
|
Packit Service |
c5cf8c |
AC_CHECK_LIB([abt],[ABT_key_create],[],AC_MSG_ERROR([unable to find Argobots library]))
|
|
Packit Service |
c5cf8c |
PAC_PREPEND_FLAG([-labt],[LIBS])
|
|
Packit Service |
c5cf8c |
THREAD_PACKAGE_NAME=MPL_THREAD_PACKAGE_ARGOBOTS
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
no|none)
|
|
Packit Service |
c5cf8c |
with_thread_package=none
|
|
Packit Service |
c5cf8c |
THREAD_PACKAGE_NAME=MPL_THREAD_PACKAGE_NONE
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
*)
|
|
Packit Service |
c5cf8c |
AC_MSG_ERROR([The specified thread package, $with_thread_package, is not supported.])
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
esac
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Define and export the selected thread library so that other packages
|
|
Packit Service |
c5cf8c |
# know what's used in MPL
|
|
Packit Service |
c5cf8c |
AC_DEFINE_UNQUOTED([THREAD_PACKAGE_NAME],[$THREAD_PACKAGE_NAME],[set to the name of the thread package])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# check for compiler-support for thread-local storage (MPL_TLS)
|
|
Packit Service |
c5cf8c |
if test "${with_thread_package}" != "argobots" ; then
|
|
Packit Service |
c5cf8c |
PAC_CC_CHECK_TLS
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
## END OF THREADS CODE
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
## START OF PROCESS MUTEX CODE
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AC_ARG_WITH([proc-mutex-package],
|
|
Packit Service |
c5cf8c |
[ --with-proc-mutex-package=package Interprocess mutex package to use. Supported packages include:
|
|
Packit Service |
c5cf8c |
posix or pthreads - POSIX threads (default, if required)
|
|
Packit Service |
c5cf8c |
none - no interprocess mutex support
|
|
Packit Service |
c5cf8c |
],,with_proc_mutex_package=posix)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if test "${with_proc_mutex_package}" = "no" ; then
|
|
Packit Service |
c5cf8c |
with_proc_mutex_package=none
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
if test "${with_proc_mutex_package}" = "yes" ; then
|
|
Packit Service |
c5cf8c |
with_proc_mutex_package=posix
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
PROC_MUTEX_PACKAGE_NAME=MPL_PROC_MUTEX_PACKAGE_INVALID
|
|
Packit Service |
c5cf8c |
case $with_proc_mutex_package in
|
|
Packit Service |
c5cf8c |
posix|pthreads)
|
|
Packit Service |
c5cf8c |
if test "${with_proc_mutex_package}" = "pthreads" ; then
|
|
Packit Service |
c5cf8c |
with_proc_mutex_package=posix
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Do not prepend -lpthread again if already checked by thread package
|
|
Packit Service |
c5cf8c |
if test "${with_thread_package}" != "posix" ; then
|
|
Packit Service |
c5cf8c |
AC_CHECK_HEADERS(pthread.h)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# If pthreads library is found, just include it on the link line. We don't try
|
|
Packit Service |
c5cf8c |
# to test if the C compiler needs it or not, since the C++ or Fortran
|
|
Packit Service |
c5cf8c |
# compilers might need it even if the C compiler doesn't
|
|
Packit Service |
c5cf8c |
# (nvcc with gfortran, for example).
|
|
Packit Service |
c5cf8c |
AC_CHECK_LIB([pthread],[pthread_mutex_init],have_pthreads=yes)
|
|
Packit Service |
c5cf8c |
if test "$have_pthreads" = "yes" ; then
|
|
Packit Service |
c5cf8c |
PAC_PREPEND_FLAG([-lpthread],[LIBS])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# this check should come after the AC_CHECK_LIB for -lpthread
|
|
Packit Service |
c5cf8c |
AC_CHECK_FUNC([pthread_mutex_init],[],[AC_MSG_ERROR([unable to find pthreads library])])
|
|
Packit Service |
c5cf8c |
# pthread_mutexattr_setpshared is first released in Issue 5
|
|
Packit Service |
c5cf8c |
AC_CHECK_FUNCS(pthread_mutexattr_setpshared)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AC_MSG_NOTICE([POSIX will be used for interprocess mutex package.])
|
|
Packit Service |
c5cf8c |
PROC_MUTEX_PACKAGE_NAME=MPL_PROC_MUTEX_PACKAGE_POSIX
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
no|none)
|
|
Packit Service |
c5cf8c |
with_proc_mutex_package=none
|
|
Packit Service |
c5cf8c |
PROC_MUTEX_PACKAGE_NAME=MPL_PROC_MUTEX_PACKAGE_NONE
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
*)
|
|
Packit Service |
c5cf8c |
AC_MSG_ERROR([The specified interprocess mutex package, $with_proc_mutex_package, is not supported.])
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
esac
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Define and export the selected interprocess mutex package so that other packages
|
|
Packit Service |
c5cf8c |
# know what's used in MPL
|
|
Packit Service |
c5cf8c |
AC_DEFINE_UNQUOTED([PROC_MUTEX_PACKAGE_NAME],[$PROC_MUTEX_PACKAGE_NAME],[set to the name of the interprocess mutex package])
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
## END OF PROCESS MUTEX CODE
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
## START OF PTHREAD MUTEX COMMON CHECK
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
if test "${with_thread_package}" = "pthreads" -o "${with_proc_mutex_package}" = "pthreads"; then
|
|
Packit Service |
c5cf8c |
# Check for PTHREAD_MUTEX_ERRORCHECK_NP and PTHREAD_MUTEX_ERRORCHECK
|
|
Packit Service |
c5cf8c |
AC_CACHE_CHECK([whether pthread.h defines PTHREAD_MUTEX_ERRORCHECK_NP],
|
|
Packit Service |
c5cf8c |
pac_cv_has_pthread_mutex_errorcheck_np,[
|
|
Packit Service |
c5cf8c |
AC_TRY_COMPILE([#include <pthread.h>],
|
|
Packit Service |
c5cf8c |
[int a=PTHREAD_MUTEX_ERRORCHECK_NP;],
|
|
Packit Service |
c5cf8c |
pac_cv_has_pthread_mutex_errorcheck_np=yes,
|
|
Packit Service |
c5cf8c |
pac_cv_has_pthread_mutex_errorcheck_np=no)])
|
|
Packit Service |
c5cf8c |
AC_CACHE_CHECK([whether pthread.h defines PTHREAD_MUTEX_ERRORCHECK],
|
|
Packit Service |
c5cf8c |
pac_cv_has_pthread_mutex_errorcheck,[
|
|
Packit Service |
c5cf8c |
AC_TRY_COMPILE([#include <pthread.h>],
|
|
Packit Service |
c5cf8c |
[int a=PTHREAD_MUTEX_ERRORCHECK;],
|
|
Packit Service |
c5cf8c |
pac_cv_has_pthread_mutex_errorcheck=yes,
|
|
Packit Service |
c5cf8c |
pac_cv_has_pthread_mutex_errorcheck=no)])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if test "$pac_cv_has_pthread_mutex_errorcheck" = yes ; then
|
|
Packit Service |
c5cf8c |
AC_DEFINE(PTHREAD_MUTEX_ERRORCHECK_VALUE,PTHREAD_MUTEX_ERRORCHECK,
|
|
Packit Service |
c5cf8c |
[Define to an expression that will result in an error checking mutex type.])
|
|
Packit Service |
c5cf8c |
elif test "$pac_cv_has_pthread_mutex_errorcheck_np" = yes ; then
|
|
Packit Service |
c5cf8c |
AC_DEFINE(PTHREAD_MUTEX_ERRORCHECK_VALUE,PTHREAD_MUTEX_ERRORCHECK_NP,
|
|
Packit Service |
c5cf8c |
[Define to an expression that will result in an error checking mutex type.])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
PAC_FUNC_NEEDS_DECL([#include <pthread.h>],pthread_mutexattr_settype)
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
## END OF PTHREAD MUTEX COMMON CHECK
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
## START OF DBG CODE
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# mkstemp() is a better replacement for mktemp()
|
|
Packit Service |
c5cf8c |
AC_HAVE_FUNCS(mkstemp)
|
|
Packit Service |
c5cf8c |
if test "$ac_cv_func_mkstemp" = "yes" ; then
|
|
Packit Service |
c5cf8c |
PAC_FUNC_NEEDS_DECL([#include <stdlib.h>],mkstemp)
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
# fdopen() converts from an fd to a FILE*
|
|
Packit Service |
c5cf8c |
AC_HAVE_FUNCS(fdopen)
|
|
Packit Service |
c5cf8c |
if test "$ac_cv_func_fdopen" = "yes" ; then
|
|
Packit Service |
c5cf8c |
PAC_FUNC_NEEDS_DECL([#include <stdio.h>],fdopen)
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AC_CHECK_FUNCS(getpid)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
## END OF DBG CODE
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
## START OF SHM CODE
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
dnl Check for shm
|
|
Packit Service |
c5cf8c |
PAC_ARG_SHARED_MEMORY
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
case $with_shared_memory in
|
|
Packit Service |
c5cf8c |
sysv)
|
|
Packit Service |
c5cf8c |
AC_DEFINE(MPL_USE_SYSV_SHM,1,[Define if use SYSV shared memory])
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
mmap)
|
|
Packit Service |
c5cf8c |
AC_DEFINE(MPL_USE_MMAP_SHM,1,[Define if use MMAP shared memory])
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
nt)
|
|
Packit Service |
c5cf8c |
AC_DEFINE(MPL_USE_NT_SHM,1,[Define if use Windows shared memory])
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
*)
|
|
Packit Service |
c5cf8c |
AC_MSG_ERROR([cannot support shared memory: need either sysv shared memory functions or mmap in order to support shared memory])
|
|
Packit Service |
c5cf8c |
esac
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
## END OF SHM CODE
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
## Enable creation of libtool-style versioning or no versioning
|
|
Packit Service |
c5cf8c |
AC_ARG_ENABLE(versioning,
|
|
Packit Service |
c5cf8c |
[AC_HELP_STRING([--enable-versioning],[Enable library versioning])],,
|
|
Packit Service |
c5cf8c |
[enable_versioning=yes])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if test "$enable_versioning" = "yes" ; then
|
|
Packit Service |
c5cf8c |
libmpl_so_versionflags="-version-info \$(libmpl_so_version)"
|
|
Packit Service |
c5cf8c |
else
|
|
Packit Service |
c5cf8c |
libmpl_so_versionflags="-avoid-version"
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
export libmpl_so_versionflags
|
|
Packit Service |
c5cf8c |
AC_SUBST(libmpl_so_versionflags)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#######################################################################
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Check for strdup
|
|
Packit Service |
c5cf8c |
AC_CHECK_FUNCS(strdup)
|
|
Packit Service |
c5cf8c |
if test "$ac_cv_func_strdup" = "yes" ; then
|
|
Packit Service |
c5cf8c |
PAC_FUNC_NEEDS_DECL([#include <string.h>],strdup)
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Check for snprintf
|
|
Packit Service |
c5cf8c |
AC_CHECK_FUNCS(snprintf)
|
|
Packit Service |
c5cf8c |
if test "$ac_cv_func_snprintf" = "yes" ; then
|
|
Packit Service |
c5cf8c |
PAC_FUNC_NEEDS_DECL([#include <stdio.h>],snprintf)
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Check for strncmp
|
|
Packit Service |
c5cf8c |
AC_CHECK_FUNCS(strncmp)
|
|
Packit Service |
c5cf8c |
if test "$ac_cv_func_strncmp" = "yes" ; then
|
|
Packit Service |
c5cf8c |
PAC_FUNC_NEEDS_DECL([#include <string.h>],strncmp)
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Check for putenv
|
|
Packit Service |
c5cf8c |
AC_CHECK_FUNCS(putenv)
|
|
Packit Service |
c5cf8c |
if test "$ac_cv_func_putenv" = "yes" ; then
|
|
Packit Service |
c5cf8c |
PAC_FUNC_NEEDS_DECL([#include <stdlib.h>],putenv)
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Check for strerror
|
|
Packit Service |
c5cf8c |
AC_CHECK_FUNCS(strerror)
|
|
Packit Service |
c5cf8c |
if test "$ac_cv_func_strerror" = "yes" ; then
|
|
Packit Service |
c5cf8c |
PAC_FUNC_NEEDS_DECL([#include <string.h>],strerror)
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Check for usleep
|
|
Packit Service |
c5cf8c |
AC_CHECK_FUNCS(usleep)
|
|
Packit Service |
c5cf8c |
if test "$ac_cv_func_usleep" = "yes" ; then
|
|
Packit Service |
c5cf8c |
PAC_FUNC_NEEDS_DECL([#include <unistd.h>],usleep)
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Check if we can implement MPL_aligned_alloc
|
|
Packit Service |
c5cf8c |
AC_CHECK_FUNCS(posix_memalign)
|
|
Packit Service |
c5cf8c |
AC_CHECK_FUNCS(aligned_alloc)
|
|
Packit Service |
c5cf8c |
if test "$ac_cv_func_aligned_alloc" = "yes" ; then
|
|
Packit Service |
c5cf8c |
PAC_FUNC_NEEDS_DECL([#include <stdlib.h>],aligned_alloc)
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
if test "$ac_cv_func_posix_memalign" = "yes" -o "$ac_cv_func_aligned_alloc" = "yes"; then
|
|
Packit Service |
c5cf8c |
AC_DEFINE([DEFINE_ALIGNED_ALLOC],[1],[Define to 1 if MPL enables MPL_aligned_alloc.])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AC_CHECK_FUNCS(backtrace_symbols)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Check for libbacktrace support
|
|
Packit Service |
c5cf8c |
PAC_PUSH_FLAG([LIBS])
|
|
Packit Service |
c5cf8c |
PAC_PREPEND_FLAG([-lbacktrace],[LIBS])
|
|
Packit Service |
c5cf8c |
AC_LINK_IFELSE([
|
|
Packit Service |
c5cf8c |
AC_LANG_PROGRAM([
|
|
Packit Service |
c5cf8c |
#include <backtrace.h>
|
|
Packit Service |
c5cf8c |
],[
|
|
Packit Service |
c5cf8c |
backtrace_create_state(0, 0, 0, 0);
|
|
Packit Service |
c5cf8c |
backtrace_print(0, 0, 0);
|
|
Packit Service |
c5cf8c |
])],
|
|
Packit Service |
c5cf8c |
[ac_cv_lib_backtrace=yes],
|
|
Packit Service |
c5cf8c |
[ac_cv_lib_backtrace=no]
|
|
Packit Service |
c5cf8c |
)
|
|
Packit Service |
c5cf8c |
PAC_POP_FLAG([LIBS])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if test "$ac_cv_lib_backtrace" = "yes" ; then
|
|
Packit Service |
c5cf8c |
AC_DEFINE([HAVE_LIBBACKTRACE],[1],[Define to 1 if you have the backtrace header (backtrace.h) and library (-lbacktrace)])
|
|
Packit Service |
c5cf8c |
PAC_PREPEND_FLAG([-lbacktrace],[LIBS])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
AC_CHECK_DECLS([backtrace_create_state, backtrace_print])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Check for libunwind support
|
|
Packit Service |
c5cf8c |
PAC_PUSH_FLAG([LIBS])
|
|
Packit Service |
c5cf8c |
PAC_PREPEND_FLAG([-lunwind],[LIBS])
|
|
Packit Service |
c5cf8c |
AC_LINK_IFELSE([
|
|
Packit Service |
c5cf8c |
AC_LANG_PROGRAM([
|
|
Packit Service |
c5cf8c |
#include<libunwind.h>
|
|
Packit Service |
c5cf8c |
],[
|
|
Packit Service |
c5cf8c |
unw_backtrace(0, 0);
|
|
Packit Service |
c5cf8c |
])],
|
|
Packit Service |
c5cf8c |
[ac_cv_lib_libunwind=yes],
|
|
Packit Service |
c5cf8c |
[ac_cv_lib_libunwind=no]
|
|
Packit Service |
c5cf8c |
)
|
|
Packit Service |
c5cf8c |
PAC_POP_FLAG([LIBS])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if test "$ac_cv_lib_libunwind" = "yes" ; then
|
|
Packit Service |
c5cf8c |
AC_DEFINE([HAVE_LIBUNWIND],[1],[Define to 1 if you have the libunwind header (libunwind.h) and library (-lunwind)])
|
|
Packit Service |
c5cf8c |
PAC_PREPEND_FLAG([-lunwind],[LIBS])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AX_LIB_SOCKET_NSL
|
|
Packit Service |
c5cf8c |
AC_CHECK_HEADERS(ifaddrs.h arpa/inet.h)
|
|
Packit Service |
c5cf8c |
AC_CHECK_FUNCS(inet_ntop getifaddrs)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
dnl Check for ATTRIBUTE
|
|
Packit Service |
c5cf8c |
PAC_C_GNU_ATTRIBUTE
|
|
Packit Service |
c5cf8c |
AX_GCC_VAR_ATTRIBUTE(aligned)
|
|
Packit Service |
c5cf8c |
AX_GCC_VAR_ATTRIBUTE(used)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
dnl Check for fallthrough attribute
|
|
Packit Service |
c5cf8c |
PAC_PUSH_ALL_FLAGS
|
|
Packit Service |
c5cf8c |
dnl This check requires removing -Wall and -Wextra first or it will fail. Just
|
|
Packit Service |
c5cf8c |
dnl clear them all.
|
|
Packit Service |
c5cf8c |
CFLAGS=""
|
|
Packit Service |
c5cf8c |
AX_GCC_FUNC_ATTRIBUTE(fallthrough)
|
|
Packit Service |
c5cf8c |
PAC_POP_ALL_FLAGS
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
dnl Final output
|
|
Packit Service |
c5cf8c |
AC_CONFIG_FILES([Makefile localdefs include/mpl_timer.h])
|
|
Packit Service |
c5cf8c |
AC_OUTPUT
|