Blame src/openpa/configure.ac

Packit Service c5cf8c
# -*- Mode: c-basic-offset:4 ; indent-tabs-mode:nil ; -*-
Packit Service c5cf8c
#  
Packit Service c5cf8c
#  (C) 2008 by Argonne National Laboratory.
Packit Service c5cf8c
#      See COPYRIGHT in top-level directory.
Packit Service c5cf8c
# 
Packit Service c5cf8c
Packit Service c5cf8c
AC_PREREQ(2.62)
Packit Service c5cf8c
Packit Service c5cf8c
AC_INIT([OpenPA], [1.0.3], [https://trac.mcs.anl.gov/projects/openpa/newticket])
Packit Service c5cf8c
dnl Set the directory that contains support scripts such as install-sh and
Packit Service c5cf8c
dnl config.guess.  It also contains autoconf macro files.
Packit Service c5cf8c
AC_CONFIG_AUX_DIR(confdb)
Packit Service c5cf8c
AC_CONFIG_MACRO_DIR([confdb])
Packit Service c5cf8c
Packit Service c5cf8c
AM_INIT_AUTOMAKE([-Wall -Werror foreign color-tests 1.12.3 subdir-objects])
Packit Service c5cf8c
Packit Service c5cf8c
# automake 1.12 seems to require this, but automake 1.11 doesn't recognize it
Packit Service c5cf8c
# must come before LT_INIT
Packit Service c5cf8c
m4_ifdef([AM_PROG_AR],[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
save_cflags=$CFLAGS
Packit Service c5cf8c
LT_INIT()
Packit Service c5cf8c
CFLAGS=$save_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([OPALIBNAME],[can be used to override the name of the OpenPA library (default: "opa")])
Packit Service c5cf8c
OPALIBNAME=${OPALIBNAME:-"opa"}
Packit Service c5cf8c
AC_SUBST(OPALIBNAME)
Packit Service c5cf8c
export OPALIBNAME
Packit Service c5cf8c
Packit Service c5cf8c
if test -s "$srcdir/VERSION" ; then
Packit Service c5cf8c
   . $srcdir/VERSION
Packit Service c5cf8c
   AC_SUBST([libopa_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
dnl force configure to be re-run if $top_srcdir/VERSION changes
Packit Service c5cf8c
AC_SUBST([CONFIG_STATUS_DEPENDENCIES],['$(top_srcdir)/VERSION'])
Packit Service c5cf8c
Packit Service c5cf8c
# FIXME this header needs to end up in the installation include directory in some form,
Packit Service c5cf8c
# so we probably need to change its name to something that won't collide in the
Packit Service c5cf8c
# global namespace. [goodell@ 2009-02-19]
Packit Service c5cf8c
AC_CONFIG_HEADER([src/config.h])
Packit Service c5cf8c
AH_TOP([/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
Packit Service c5cf8c
/*
Packit Service c5cf8c
 *  (C) 2008 by Argonne National Laboratory.
Packit Service c5cf8c
 *      See COPYRIGHT in top-level directory.
Packit Service c5cf8c
 */
Packit Service c5cf8c
])
Packit Service c5cf8c
AH_BOTTOM([])
Packit Service c5cf8c
Packit Service c5cf8c
dnl Preps an opa_config.h with prefixed macros from config.h for output at
Packit Service c5cf8c
dnl AC_OUTPUT time.  This way we can safely include opa_config.h in the
Packit Service c5cf8c
dnl installation and include it in installed headers.
Packit Service c5cf8c
AC_CONFIG_COMMANDS([prefix-config],[perl $srcdir/confdb/cmd_prefix_config_h.pl OPA src/config.h src/opa_config.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
########################################################################
Packit Service c5cf8c
Packit Service c5cf8c
# check if we're cross compiling
Packit Service c5cf8c
if test "$build_alias" = "$host_alias" ; then
Packit Service c5cf8c
  CROSS_COMPILING="no"
Packit Service c5cf8c
else
Packit Service c5cf8c
  CROSS_COMPILING="yes"
Packit Service c5cf8c
fi
Packit Service c5cf8c
Packit Service c5cf8c
AC_PROG_CC
Packit Service c5cf8c
AM_PROG_CC_C_O
Packit Service c5cf8c
Packit Service c5cf8c
AC_HEADER_ASSERT
Packit Service c5cf8c
# do we need intrin.h in here since it's a windows file?
Packit Service c5cf8c
AC_CHECK_HEADERS([pthread.h atomic.h intrin.h inttypes.h stdint.h stddef.h])
Packit Service c5cf8c
Packit Service c5cf8c
AC_C_RESTRICT
Packit Service c5cf8c
AC_C_INLINE
Packit Service c5cf8c
Packit Service c5cf8c
# Not strictly needed (autoconf docs: This macro is obsolescent, as current C
Packit Service c5cf8c
# compilers support const. New programs need not use this macro. )
Packit Service c5cf8c
AC_C_CONST
Packit Service c5cf8c
Packit Service c5cf8c
dnl Check for presence of the pthreads library.  This is needed by the test
Packit Service c5cf8c
dnl suite.
Packit Service c5cf8c
AC_CHECK_LIB(pthread, pthread_create)
Packit Service c5cf8c
Packit Service c5cf8c
dnl Check for presence of pthread_yield.  If not present, check for sched_yield.
Packit Service c5cf8c
dnl These are used by the test suite.
Packit Service c5cf8c
AC_CHECK_FUNCS(pthread_yield,
Packit Service c5cf8c
    ,
Packit Service c5cf8c
    [AC_CHECK_HEADER(sched.h,
Packit Service c5cf8c
        [AC_CHECK_FUNCS(sched_yield)]
Packit Service c5cf8c
    )]
Packit Service c5cf8c
)
Packit Service c5cf8c
Packit Service c5cf8c
if test "$ac_cv_lib_pthread_pthread_create" = yes; then
Packit Service c5cf8c
AC_MSG_CHECKING([if 100 threads can be run at once])
Packit Service c5cf8c
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
Packit Service c5cf8c
    #include <stddef.h>
Packit Service c5cf8c
    #include <pthread.h>
Packit Service c5cf8c
    pthread_mutex_t mutexus_maximus;
Packit Service c5cf8c
    void *thread_func(void *udata) {
Packit Service c5cf8c
        pthread_mutex_lock(&mutexus_maximus);
Packit Service c5cf8c
        pthread_mutex_unlock(&mutexus_maximus);
Packit Service c5cf8c
        return NULL;
Packit Service c5cf8c
    }
Packit Service c5cf8c
]], [[
Packit Service c5cf8c
    int i;
Packit Service c5cf8c
    pthread_t threads[99];
Packit Service c5cf8c
    pthread_mutex_init(&mutexus_maximus, NULL);
Packit Service c5cf8c
    pthread_mutex_lock(&mutexus_maximus);
Packit Service c5cf8c
    for(i=0; i<99; i++)
Packit Service c5cf8c
        if(pthread_create(&threads[i], NULL, thread_func, NULL)) {
Packit Service c5cf8c
            pthread_mutex_unlock(&mutexus_maximus);
Packit Service c5cf8c
            return 1;
Packit Service c5cf8c
        }
Packit Service c5cf8c
    pthread_mutex_unlock(&mutexus_maximus);
Packit Service c5cf8c
    return 0;
Packit Service c5cf8c
]])],
Packit Service c5cf8c
AC_MSG_RESULT([yes])
Packit Service c5cf8c
AC_DEFINE(MAX_NTHREADS, 100, [define to the maximum number of simultaneous threads]),
Packit Service c5cf8c
AC_MSG_RESULT([no])
Packit Service c5cf8c
dnl We cannot run 100 threads, check if we can run 10
Packit Service c5cf8c
    AC_MSG_CHECKING([if 10 threads can be run at once])
Packit Service c5cf8c
    AC_RUN_IFELSE([AC_LANG_PROGRAM([[
Packit Service c5cf8c
        #include <stddef.h>
Packit Service c5cf8c
        #include <pthread.h>
Packit Service c5cf8c
        pthread_mutex_t mutexus_maximus;
Packit Service c5cf8c
        void *thread_func(void *udata) {
Packit Service c5cf8c
            pthread_mutex_lock(&mutexus_maximus);
Packit Service c5cf8c
            pthread_mutex_unlock(&mutexus_maximus);
Packit Service c5cf8c
            return NULL;
Packit Service c5cf8c
        }
Packit Service c5cf8c
    ]], [[[
Packit Service c5cf8c
        int i;
Packit Service c5cf8c
        pthread_t threads[9];
Packit Service c5cf8c
        pthread_mutex_init(&mutexus_maximus, NULL);
Packit Service c5cf8c
        pthread_mutex_lock(&mutexus_maximus);
Packit Service c5cf8c
        for(i=0; i<9; i++)
Packit Service c5cf8c
            if(pthread_create(&threads[i], NULL, thread_func, NULL)) {
Packit Service c5cf8c
                pthread_mutex_unlock(&mutexus_maximus);
Packit Service c5cf8c
                return 1;
Packit Service c5cf8c
            }
Packit Service c5cf8c
        pthread_mutex_unlock(&mutexus_maximus);
Packit Service c5cf8c
        return 0;
Packit Service c5cf8c
    ]]])],
Packit Service c5cf8c
    AC_MSG_RESULT([yes])
Packit Service c5cf8c
    AC_DEFINE(MAX_NTHREADS, 10, [define to the maximum number of simultaneous threads]),
Packit Service c5cf8c
    AC_MSG_RESULT([no])
Packit Service c5cf8c
    AC_DEFINE(MAX_NTHREADS, 4, [define to the maximum number of simultaneous threads]),
Packit Service c5cf8c
    AC_MSG_RESULT([N/A])),
Packit Service c5cf8c
AC_MSG_RESULT([N/A]))
Packit Service c5cf8c
fi
Packit Service c5cf8c
Packit Service c5cf8c
AC_CHECK_SIZEOF([void *])
Packit Service c5cf8c
AC_CHECK_SIZEOF([int])
Packit Service c5cf8c
Packit Service c5cf8c
dnl Check for __attribute__ support.  This was originally taken from
Packit Service c5cf8c
dnl the PAC_C_GNU_ATTRIBUTE macro in mpich.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl We start by requiring Gcc.  Some other compilers accept __attribute__
Packit Service c5cf8c
dnl but generate warning messages, or have different interpretations 
Packit Service c5cf8c
dnl (which seems to make __attribute__ just as bad as #pragma) 
Packit Service c5cf8c
dnl For example, the Intel icc compiler accepts __attribute__ and
Packit Service c5cf8c
dnl __attribute__((pure)) but generates warnings for __attribute__((format...))
Packit Service c5cf8c
if test "$GCC" = "yes" ; then
Packit Service c5cf8c
    AC_CACHE_CHECK([whether __attribute__ allowed],
Packit Service c5cf8c
pac_cv_gnu_attr_pure,[
Packit Service c5cf8c
AC_TRY_COMPILE([int foo(int) __attribute__ ((pure));],[int a;],
Packit Service c5cf8c
pac_cv_gnu_attr_pure=yes,pac_cv_gnu_attr_pure=no)])
Packit Service c5cf8c
AC_CACHE_CHECK([whether __attribute__((format)) allowed],
Packit Service c5cf8c
pac_cv_gnu_attr_format,[
Packit Service c5cf8c
AC_TRY_COMPILE([int foo(char *,...) __attribute__ ((format(printf,1,2)));],[int a;],
Packit Service c5cf8c
pac_cv_gnu_attr_format=yes,pac_cv_gnu_attr_format=no)])
Packit Service c5cf8c
    if test "$pac_cv_gnu_attr_pure" = "yes" -a "$pac_cv_gnu_attr_format" = "yes" ; then
Packit Service c5cf8c
        AC_DEFINE(HAVE_GCC_ATTRIBUTE,1,[Define if GNU __attribute__ is supported])
Packit Service c5cf8c
    fi
Packit Service c5cf8c
fi
Packit Service c5cf8c
Packit Service c5cf8c
dnl Check to make sure that the compiler rejects bogus inline assembly
Packit Service c5cf8c
dnl statements.  If it does not, then we need to be careful below when
Packit Service c5cf8c
dnl we're checking which primitives header file to use.
Packit Service c5cf8c
AC_MSG_CHECKING([if compiler rejects bogus asm statements])
Packit Service c5cf8c
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
Packit Service c5cf8c
    __asm__ __volatile__ ("ILLEGAL_ASM_STMT");
Packit Service c5cf8c
  ]])],
Packit Service c5cf8c
  compiler_rejects_bogus_asm=no
Packit Service c5cf8c
  AC_MSG_RESULT([no])
Packit Service c5cf8c
  ,
Packit Service c5cf8c
  compiler_rejects_bogus_asm=yes
Packit Service c5cf8c
  AC_MSG_RESULT([yes])
Packit Service c5cf8c
)
Packit Service c5cf8c
Packit Service c5cf8c
AC_ARG_WITH([atomic-primitives], [AC_HELP_STRING([--with-atomic-primitives],
Packit Service c5cf8c
    [Force OPA to use a specific atomic primitives implementation file (default
Packit Service c5cf8c
     is auto).  A value of 'no' forces the use of locks to implement atomic
Packit Service c5cf8c
     primitives.  A value of 'auto_allow_emulation' will attempt to detect
Packit Service c5cf8c
     native primitives and will fall back to lock-based emulation if none are
Packit Service c5cf8c
     available.  Note that using locks to implement atomic primitives will have
Packit Service c5cf8c
     a substantial impact on performance and is intended for testing only.  A
Packit Service c5cf8c
     value of 'unsafe' will use a non-atomic version of the primitives for performance
Packit Service c5cf8c
     in single-threaded code and meta-testing.])],
Packit Service c5cf8c
    [AS_IF([test "$with_atomic_primitives" = "yes"], [with_atomic_primitives=auto])],
Packit Service c5cf8c
    [with_atomic_primitives=auto]
Packit Service c5cf8c
)
Packit Service c5cf8c
Packit Service c5cf8c
AC_ARG_ENABLE(embedded,
Packit Service c5cf8c
        [AC_HELP_STRING([--enable-embedded],[Enable embedded mode])])
Packit Service c5cf8c
AM_CONDITIONAL([EMBEDDED], [test "x${enable_embedded}" = "xyes"])
Packit Service c5cf8c
Packit Service c5cf8c
# is set to yes by the macro below if any test ever succeeds
Packit Service c5cf8c
non_emulated_primitives_available=no
Packit Service c5cf8c
# is set to yes in OPA_TRY_PRIMITIVE_HEADER when a primitive
Packit Service c5cf8c
# matching $with_atomic_primitives is checked
Packit Service c5cf8c
checked_specified_primitive=no
Packit Service c5cf8c
Packit Service c5cf8c
AC_DEFUN([OPA_PRIMITIVE_TEST_PGM], [AC_LANG_PROGRAM([[
Packit Service c5cf8c
#define OPA_SIZEOF_INT SIZEOF_INT
Packit Service c5cf8c
#define OPA_SIZEOF_VOID_P SIZEOF_VOID_P
Packit Service c5cf8c
#ifndef _opa_inline
Packit Service c5cf8c
#define _opa_inline inline
Packit Service c5cf8c
#endif
Packit Service c5cf8c
#ifndef _opa_restrict
Packit Service c5cf8c
#define _opa_restrict restrict
Packit Service c5cf8c
#endif
Packit Service c5cf8c
#ifndef _opa_const
Packit Service c5cf8c
#define _opa_const const
Packit Service c5cf8c
#endif
Packit Service c5cf8c
#ifdef HAVE_GCC_ATTRIBUTE
Packit Service c5cf8c
#define OPA_HAVE_GCC_ATTRIBUTE 1
Packit Service c5cf8c
#endif
Packit Service c5cf8c
#include "opa_util.h" /* for OPA_ATTRIBUTE and friends */
Packit Service c5cf8c
#include "primitives/$1"
Packit Service c5cf8c
    ]],[[
Packit Service c5cf8c
    OPA_int_t a, b;
Packit Service c5cf8c
    int c;
Packit Service c5cf8c
Packit Service c5cf8c
    OPA_store_int(&a, 0);
Packit Service c5cf8c
    OPA_store_int(&b, 1);
Packit Service c5cf8c
    c = OPA_load_int(&a);
Packit Service c5cf8c
Packit Service c5cf8c
    OPA_add_int(&a, 10);
Packit Service c5cf8c
    OPA_incr_int(&a);
Packit Service c5cf8c
    OPA_decr_int(&a);
Packit Service c5cf8c
Packit Service c5cf8c
    c = OPA_decr_and_test_int(&a);
Packit Service c5cf8c
    c = OPA_fetch_and_add_int(&a, 10);
Packit Service c5cf8c
    c = OPA_fetch_and_incr_int(&a);
Packit Service c5cf8c
    c = OPA_fetch_and_decr_int(&a);
Packit Service c5cf8c
Packit Service c5cf8c
    c = OPA_cas_int(&a, 10, 11);
Packit Service c5cf8c
    c = OPA_swap_int(&a, OPA_load_int(&b);;
Packit Service c5cf8c
Packit Service c5cf8c
    OPA_write_barrier();
Packit Service c5cf8c
    OPA_read_barrier();
Packit Service c5cf8c
    OPA_read_write_barrier();
Packit Service c5cf8c
     ]])]
Packit Service c5cf8c
)
Packit Service c5cf8c
Packit Service c5cf8c
dnl OPA_TRY_PRIMITIVE_HEADER([header file from src/ dir], [HAVE_ macro suffix], [feature description])
Packit Service c5cf8c
dnl Does an AC_LINK_IFELSE() to see if the header file works
Packit Service c5cf8c
AC_DEFUN([OPA_TRY_PRIMITIVE_HEADER],[
Packit Service c5cf8c
if test "$with_atomic_primitives" = "auto"                 || \
Packit Service c5cf8c
   test "$with_atomic_primitives" = "auto_allow_emulation" || \
Packit Service c5cf8c
   test "$with_atomic_primitives" = "$1"
Packit Service c5cf8c
then
Packit Service c5cf8c
    checked_specified_primitive=yes
Packit Service c5cf8c
    AC_MSG_CHECKING([for support for $3])
Packit Service c5cf8c
    SAVE_CFLAGS="$CFLAGS"
Packit Service c5cf8c
    CFLAGS="$CFLAGS -I${srcdir}/src"
Packit Service c5cf8c
    AC_LINK_IFELSE([OPA_PRIMITIVE_TEST_PGM([$1])],
Packit Service c5cf8c
        [AC_DEFINE([HAVE_$2], [1], [define to 1 if we have support for $3])
Packit Service c5cf8c
        non_emulated_primitives_available=yes]
Packit Service c5cf8c
        [AC_MSG_RESULT([yes])]
Packit Service c5cf8c
    ,
Packit Service c5cf8c
        [AC_MSG_RESULT([no])]
Packit Service c5cf8c
    )
Packit Service c5cf8c
    CFLAGS="$SAVE_CFLAGS"
Packit Service c5cf8c
fi
Packit Service c5cf8c
])
Packit Service c5cf8c
Packit Service c5cf8c
dnl OPA_TRY_RUN_PRIMITIVE_HEADER([header file from src/ dir], [HAVE_ macro suffix], [feature description])
Packit Service c5cf8c
dnl Does an AC_RUN_IFELSE() to see if the header file works, but falls back to AC_LINK_IFELSE() 
Packit Service c5cf8c
dnl if we're cross-compiling
Packit Service c5cf8c
AC_DEFUN([OPA_TRY_RUN_PRIMITIVE_HEADER],[
Packit Service c5cf8c
if test "$with_atomic_primitives" = "auto"                 || \
Packit Service c5cf8c
   test "$with_atomic_primitives" = "auto_allow_emulation" || \
Packit Service c5cf8c
   test "$with_atomic_primitives" = "$1"
Packit Service c5cf8c
then
Packit Service c5cf8c
    checked_specified_primitive=yes
Packit Service c5cf8c
    AC_MSG_CHECKING([for support for $3])
Packit Service c5cf8c
    SAVE_CFLAGS="$CFLAGS"
Packit Service c5cf8c
    CFLAGS="$CFLAGS -I${srcdir}/src"
Packit Service c5cf8c
    AC_RUN_IFELSE([OPA_PRIMITIVE_TEST_PGM([$1])],[
Packit Service c5cf8c
        AC_DEFINE([HAVE_$2], [1], [define to 1 if we have support for $3])
Packit Service c5cf8c
        non_emulated_primitives_available=yes
Packit Service c5cf8c
        AC_MSG_RESULT([yes])]
Packit Service c5cf8c
    ,
Packit Service c5cf8c
        [AC_MSG_RESULT([no])]
Packit Service c5cf8c
    ,
Packit Service c5cf8c
        [AC_LINK_IFELSE([OPA_PRIMITIVE_TEST_PGM([$1])],[
Packit Service c5cf8c
            AC_DEFINE([HAVE_$2], [1], [define to 1 if we have support for $3])
Packit Service c5cf8c
            non_emulated_primitives_available=yes
Packit Service c5cf8c
            AC_MSG_RESULT([yes])]
Packit Service c5cf8c
        ,
Packit Service c5cf8c
            [AC_MSG_RESULT([no])]
Packit Service c5cf8c
        )]
Packit Service c5cf8c
    )
Packit Service c5cf8c
    CFLAGS="$SAVE_CFLAGS"
Packit Service c5cf8c
fi
Packit Service c5cf8c
])
Packit Service c5cf8c
Packit Service c5cf8c
using_emulated_primitives=no
Packit Service c5cf8c
using_unsafe_primitives=no
Packit Service c5cf8c
Packit Service c5cf8c
if test "$with_atomic_primitives" = "no" ; then
Packit Service c5cf8c
    using_emulated_primitives=yes
Packit Service c5cf8c
    # EXPLICIT_EMULATION becomes OPA_EXPLICIT_EMULATION in the installed opa_config.h
Packit Service c5cf8c
    AC_DEFINE([EXPLICIT_EMULATION],[1],
Packit Service c5cf8c
              [define if lock-based emulation was explicitly requested at
Packit Service c5cf8c
               configure time via --with-atomic-primitives=no])
Packit Service c5cf8c
elif test "$with_atomic_primitives" = "unsafe" ; then
Packit Service c5cf8c
    using_unsafe_primitives=yes
Packit Service c5cf8c
else
Packit Service c5cf8c
dnl We currently test for support of each platform or implementation by
Packit Service c5cf8c
dnl attempting to compile the associated primitives header file.  This doesn't
Packit Service c5cf8c
dnl feel right, but it's actually pretty effective while being fairly easy to
Packit Service c5cf8c
dnl implement as well.  The biggest problem with this strategy is that if we are
Packit Service c5cf8c
dnl missing some little bit of compatibility code (a missing type or header for
Packit Service c5cf8c
dnl which we have a workaround) we could end up selecting the wrong
Packit Service c5cf8c
dnl implementation.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl If the compiler can't tell that it's getting bad assembly, we have
Packit Service c5cf8c
dnl no hope of being able to check what asm statements are supported
Packit Service c5cf8c
dnl without AC_TRY_RUN().
Packit Service c5cf8c
    if test "$compiler_rejects_bogus_asm" = "yes"  ; then 
Packit Service c5cf8c
        # if we're cross compiling, don't try the gcc_intel_32_64
Packit Service c5cf8c
        # test, since it uses fence operations which are not supported
Packit Service c5cf8c
        # on pre Pentium 4 machines, but it may still compile and link
Packit Service c5cf8c
        if test "$CROSS_COMPILING" = "no" ; then
Packit Service c5cf8c
            OPA_TRY_RUN_PRIMITIVE_HEADER([opa_gcc_intel_32_64.h], [GCC_X86_32_64], [gcc x86/x86_64 primitives])
Packit Service c5cf8c
        fi
Packit Service c5cf8c
        OPA_TRY_RUN_PRIMITIVE_HEADER([opa_gcc_intel_32_64_p3.h], [GCC_X86_32_64_P3], [gcc x86 primitives for pre-Pentium 4])
Packit Service c5cf8c
        OPA_TRY_PRIMITIVE_HEADER([opa_gcc_ia64.h], [GCC_AND_IA64_ASM], [gcc ia64 primitives])
Packit Service c5cf8c
        OPA_TRY_PRIMITIVE_HEADER([opa_gcc_ppc.h], [GCC_AND_POWERPC_ASM], [gcc PowerPC atomics])
Packit Service c5cf8c
        OPA_TRY_PRIMITIVE_HEADER([opa_gcc_arm.h], [GCC_AND_ARM_ASM], [gcc ARM atomics])
Packit Service c5cf8c
        OPA_TRY_PRIMITIVE_HEADER([opa_gcc_sicortex.h], [GCC_AND_SICORTEX_ASM], [gcc SiCortex atomics])
Packit Service c5cf8c
    fi
Packit Service c5cf8c
Packit Service c5cf8c
    OPA_TRY_PRIMITIVE_HEADER([opa_gcc_intrinsics.h], [GCC_INTRINSIC_ATOMICS], [gcc atomic intrinsics])
Packit Service c5cf8c
    OPA_TRY_PRIMITIVE_HEADER([opa_nt_intrinsics.h], [NT_INTRINSICS], [Windows NT atomic intrinsics])
Packit Service c5cf8c
    OPA_TRY_PRIMITIVE_HEADER([opa_sun_atomic_ops.h], [SUN_ATOMIC_OPS], [Sun atomic operations library])
Packit Service c5cf8c
Packit Service c5cf8c
    if test "$checked_specified_primitive" = "no" ; then
Packit Service c5cf8c
        AC_MSG_ERROR([did not find specified atomic primitives file "$with_atomic_primitives"], 1)
Packit Service c5cf8c
    fi
Packit Service c5cf8c
Packit Service c5cf8c
    if test "$non_emulated_primitives_available" = "no" ; then
Packit Service c5cf8c
        if test "$with_atomic_primitives" = "auto_allow_emulation" ; then
Packit Service c5cf8c
            using_emulated_primitives=yes
Packit Service c5cf8c
        else
Packit Service c5cf8c
            AC_MSG_ERROR([
Packit Service c5cf8c
=======================================================
Packit Service c5cf8c
No native supported atomic primitives were detected.
Packit Service c5cf8c
You can use "--with-atomic-primitives=no" to emulate
Packit Service c5cf8c
the atomic primitives using locks, but note that doing
Packit Service c5cf8c
this will result in a substantial performance
Packit Service c5cf8c
penalty.
Packit Service c5cf8c
=======================================================], 1)
Packit Service c5cf8c
        fi
Packit Service c5cf8c
    fi
Packit Service c5cf8c
fi
Packit Service c5cf8c
Packit Service c5cf8c
internal_pkg_config_libs=
Packit Service c5cf8c
external_pkg_config_libs=
Packit Service c5cf8c
if test "$using_emulated_primitives" = "yes" ; then
Packit Service c5cf8c
    AC_MSG_WARN([
Packit Service c5cf8c
===================================================
Packit Service c5cf8c
Using locks to implement atomic primitives.  This
Packit Service c5cf8c
will result in a substantial impact on performance.
Packit Service c5cf8c
Use this only for testing.
Packit Service c5cf8c
===================================================])
Packit Service c5cf8c
    AC_DEFINE(USE_LOCK_BASED_PRIMITIVES, 1, [define to 1 to force using lock-based atomic primitives])
Packit Service c5cf8c
    internal_pkg_config_libs="-lpthread $internal_pkg_config_libs"
Packit Service c5cf8c
    external_pkg_config_libs="-lopa     $external_pkg_config_libs"
Packit Service c5cf8c
fi
Packit Service c5cf8c
Packit Service c5cf8c
AC_SUBST(internal_pkg_config_libs)
Packit Service c5cf8c
AC_SUBST(external_pkg_config_libs)
Packit Service c5cf8c
Packit Service c5cf8c
if test "$using_unsafe_primitives" = "yes" ; then
Packit Service c5cf8c
    AC_MSG_WARN([
Packit Service c5cf8c
===================================================
Packit Service c5cf8c
Using *UNSAFE*, *NON-ATOMIC* primitive operations.
Packit Service c5cf8c
Use this for only for testing or for performance
Packit Service c5cf8c
reasons in non-concurrent code.
Packit Service c5cf8c
Packit Service c5cf8c
Consider yourself warned!
Packit Service c5cf8c
===================================================])
Packit Service c5cf8c
    AC_DEFINE([USE_UNSAFE_PRIMITIVES],[1],[define to 1 if unsafe (non-atomic) primitives should be used])
Packit Service c5cf8c
fi
Packit Service c5cf8c
Packit Service c5cf8c
dnl Check to see if we should enable strict fairness checks
Packit Service c5cf8c
AC_MSG_CHECKING([whether to enable strict fairness checks])
Packit Service c5cf8c
AC_ARG_ENABLE(strict-fairness-checks,
Packit Service c5cf8c
    [AC_HELP_STRING([--enable-strict-fairness-checks],
Packit Service c5cf8c
        [Enable stricter checks of the "fairness" of atomic operations in the
Packit Service c5cf8c
         test suite (default is no).  A value of 'yes' will remove the calls to
Packit Service c5cf8c
         pthread_yield() from these test routines.])],
Packit Service c5cf8c
    [strict_fairness_checks=$enableval],
Packit Service c5cf8c
    [strict_fairness_checks=no])
Packit Service c5cf8c
if test "${strict_fairness_checks}" = "yes"; then
Packit Service c5cf8c
    AC_MSG_RESULT([yes])
Packit Service c5cf8c
    AC_DEFINE([HAVE_STRICT_FAIRNESS_CHECKS], [1],
Packit Service c5cf8c
        [Define if strict checking of atomic operation fairness is desired])
Packit Service c5cf8c
else
Packit Service c5cf8c
    AC_MSG_RESULT([no])
Packit Service c5cf8c
fi
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
   libopa_so_versionflags="-version-info \$(libopa_so_version)"
Packit Service c5cf8c
else
Packit Service c5cf8c
   libopa_so_versionflags="-avoid-version"
Packit Service c5cf8c
fi
Packit Service c5cf8c
export libopa_so_versionflags
Packit Service c5cf8c
AC_SUBST(libopa_so_versionflags)
Packit Service c5cf8c
Packit Service c5cf8c
if test -z "$pkgconfigdir" ; then
Packit Service c5cf8c
  # The default pkgconfig dir is under the lib dir
Packit Service c5cf8c
  pkgconfigdir=$libdir/pkgconfig
Packit Service c5cf8c
fi
Packit Service c5cf8c
AC_SUBST(pkgconfigdir)
Packit Service c5cf8c
export pkgconfigdir
Packit Service c5cf8c
Packit Service c5cf8c
AC_CONFIG_FILES([Makefile src/Makefile test/Makefile openpa.pc])
Packit Service c5cf8c
AC_OUTPUT
Packit Service c5cf8c