2008-10-28 20:22:29 +03:00
|
|
|
dnl
|
|
|
|
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
dnl University Research and Technology
|
|
|
|
dnl Corporation. All rights reserved.
|
2019-10-11 18:12:07 +03:00
|
|
|
dnl Copyright (c) 2004-2020 The University of Tennessee and The University
|
2008-10-28 20:22:29 +03:00
|
|
|
dnl of Tennessee Research Foundation. All rights
|
|
|
|
dnl reserved.
|
2015-06-24 06:59:57 +03:00
|
|
|
dnl Copyright (c) 2004-2006 High Performance Computing Center Stuttgart,
|
2008-10-28 20:22:29 +03:00
|
|
|
dnl University of Stuttgart. All rights reserved.
|
|
|
|
dnl Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
dnl All rights reserved.
|
2018-08-23 18:40:55 +03:00
|
|
|
dnl Copyright (c) 2008-2018 Cisco Systems, Inc. All rights reserved.
|
2010-11-16 00:41:56 +03:00
|
|
|
dnl Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
|
2017-02-27 04:35:49 +03:00
|
|
|
dnl Copyright (c) 2015-2017 Research Organization for Information Science
|
2015-02-03 09:19:22 +03:00
|
|
|
dnl and Technology (RIST). All rights reserved.
|
2017-06-23 17:27:48 +03:00
|
|
|
dnl Copyright (c) 2014-2017 Los Alamos National Security, LLC. All rights
|
2016-03-30 01:57:15 +03:00
|
|
|
dnl reserved.
|
2017-04-07 05:47:34 +03:00
|
|
|
dnl Copyright (c) 2017 Amazon.com, Inc. or its affiliates. All Rights
|
|
|
|
dnl reserved.
|
2008-10-28 20:22:29 +03:00
|
|
|
dnl $COPYRIGHT$
|
2015-06-24 06:59:57 +03:00
|
|
|
dnl
|
2008-10-28 20:22:29 +03:00
|
|
|
dnl Additional copyrights may follow
|
2015-06-24 06:59:57 +03:00
|
|
|
dnl
|
2008-10-28 20:22:29 +03:00
|
|
|
dnl $HEADER$
|
|
|
|
dnl
|
|
|
|
|
2018-08-23 18:40:55 +03:00
|
|
|
dnl This is a C test to see if 128-bit __atomic_compare_exchange_n()
|
|
|
|
dnl actually works (e.g., it compiles and links successfully on
|
|
|
|
dnl ARM64+clang, but returns incorrect answers as of August 2018).
|
|
|
|
AC_DEFUN([OPAL_ATOMIC_COMPARE_EXCHANGE_N_TEST_SOURCE],[[
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdlib.h>
|
2008-10-28 20:22:29 +03:00
|
|
|
|
2018-08-23 18:40:55 +03:00
|
|
|
typedef union {
|
|
|
|
uint64_t fake@<:@2@:>@;
|
|
|
|
__int128 real;
|
|
|
|
} ompi128;
|
|
|
|
|
|
|
|
static void test1(void)
|
|
|
|
{
|
|
|
|
// As of Aug 2018, we could not figure out a way to assign 128-bit
|
|
|
|
// constants -- the compilers would not accept it. So use a fake
|
|
|
|
// union to assign 2 uin64_t's to make a single __int128.
|
|
|
|
ompi128 ptr = { .fake = { 0xFFEEDDCCBBAA0099, 0x8877665544332211 }};
|
|
|
|
ompi128 expected = { .fake = { 0x11EEDDCCBBAA0099, 0x88776655443322FF }};
|
|
|
|
ompi128 desired = { .fake = { 0x1122DDCCBBAA0099, 0x887766554433EEFF }};
|
|
|
|
bool r = __atomic_compare_exchange_n(&ptr.real, &expected.real,
|
|
|
|
desired.real, true,
|
|
|
|
__ATOMIC_RELAXED, __ATOMIC_RELAXED);
|
|
|
|
if ( !(r == false && ptr.real == expected.real)) {
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test2(void)
|
|
|
|
{
|
|
|
|
ompi128 ptr = { .fake = { 0xFFEEDDCCBBAA0099, 0x8877665544332211 }};
|
|
|
|
ompi128 expected = ptr;
|
|
|
|
ompi128 desired = { .fake = { 0x1122DDCCBBAA0099, 0x887766554433EEFF }};
|
|
|
|
bool r = __atomic_compare_exchange_n(&ptr.real, &expected.real,
|
|
|
|
desired.real, true,
|
|
|
|
__ATOMIC_RELAXED, __ATOMIC_RELAXED);
|
|
|
|
if (!(r == true && ptr.real == desired.real)) {
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
test1();
|
|
|
|
test2();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
]])
|
2014-12-04 04:40:34 +03:00
|
|
|
|
2018-08-23 18:40:55 +03:00
|
|
|
dnl ------------------------------------------------------------------
|
2014-12-04 04:40:34 +03:00
|
|
|
|
2018-08-23 18:40:55 +03:00
|
|
|
dnl This is a C test to see if 128-bit __sync_bool_compare_and_swap()
|
|
|
|
dnl actually works (e.g., it compiles and links successfully on
|
|
|
|
dnl ARM64+clang, but returns incorrect answers as of August 2018).
|
|
|
|
AC_DEFUN([OPAL_SYNC_BOOL_COMPARE_AND_SWAP_TEST_SOURCE],[[
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdlib.h>
|
2014-12-18 09:34:12 +03:00
|
|
|
|
2018-08-23 18:40:55 +03:00
|
|
|
typedef union {
|
|
|
|
uint64_t fake@<:@2@:>@;
|
|
|
|
__int128 real;
|
|
|
|
} ompi128;
|
2014-12-18 09:34:12 +03:00
|
|
|
|
2018-08-23 18:40:55 +03:00
|
|
|
static void test1(void)
|
|
|
|
{
|
|
|
|
// As of Aug 2018, we could not figure out a way to assign 128-bit
|
|
|
|
// constants -- the compilers would not accept it. So use a fake
|
|
|
|
// union to assign 2 uin64_t's to make a single __int128.
|
|
|
|
ompi128 ptr = { .fake = { 0xFFEEDDCCBBAA0099, 0x8877665544332211 }};
|
|
|
|
ompi128 oldval = { .fake = { 0x11EEDDCCBBAA0099, 0x88776655443322FF }};
|
|
|
|
ompi128 newval = { .fake = { 0x1122DDCCBBAA0099, 0x887766554433EEFF }};
|
|
|
|
bool r = __sync_bool_compare_and_swap(&ptr.real, oldval.real, newval.real);
|
|
|
|
if (!(r == false && ptr.real != newval.real)) {
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
2014-12-18 09:34:12 +03:00
|
|
|
|
2018-08-23 18:40:55 +03:00
|
|
|
static void test2(void)
|
|
|
|
{
|
|
|
|
ompi128 ptr = { .fake = { 0xFFEEDDCCBBAA0099, 0x8877665544332211 }};
|
|
|
|
ompi128 oldval = ptr;
|
|
|
|
ompi128 newval = { .fake = { 0x1122DDCCBBAA0099, 0x887766554433EEFF }};
|
|
|
|
bool r = __sync_bool_compare_and_swap(&ptr.real, oldval.real, newval.real);
|
|
|
|
if (!(r == true && ptr.real == newval.real)) {
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
}
|
2014-12-18 09:34:12 +03:00
|
|
|
|
2018-08-23 18:40:55 +03:00
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
test1();
|
|
|
|
test2();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
]])
|
|
|
|
|
|
|
|
dnl ------------------------------------------------------------------
|
|
|
|
|
|
|
|
dnl
|
|
|
|
dnl Check to see if a specific function is linkable.
|
|
|
|
dnl
|
|
|
|
dnl Check with:
|
|
|
|
dnl 1. No compiler/linker flags.
|
|
|
|
dnl 2. CFLAGS += -mcx16
|
|
|
|
dnl 3. LIBS += -latomic
|
|
|
|
dnl 4. Finally, if it links ok with any of #1, #2, or #3, actually try
|
|
|
|
dnl to run the test code (if we're not cross-compiling) and verify
|
|
|
|
dnl that it actually gives us the correct result.
|
|
|
|
dnl
|
|
|
|
dnl Note that we unfortunately can't use AC SEARCH_LIBS because its
|
|
|
|
dnl check incorrectly fails (because these functions are special compiler
|
|
|
|
dnl intrinsics -- SEARCH_LIBS tries with "check FUNC()", which the
|
|
|
|
dnl compiler complains doesn't match the internal prototype). So we have
|
|
|
|
dnl to use our own LINK_IFELSE tests. Indeed, since these functions are
|
|
|
|
dnl so special, we actually need a valid source code that calls the
|
|
|
|
dnl functions with correct arguments, etc. It's not enough, for example,
|
|
|
|
dnl to do the usual "try to set a function pointer to the symbol" trick to
|
|
|
|
dnl determine if these functions are available, because the compiler may
|
|
|
|
dnl not implement these as actual symbols. So just try to link a real
|
|
|
|
dnl test code.
|
|
|
|
dnl
|
|
|
|
dnl $1: function name to print
|
|
|
|
dnl $2: program to test
|
|
|
|
dnl $3: action if any of 1, 2, or 3 succeeds
|
|
|
|
dnl #4: action if all of 1, 2, and 3 fail
|
|
|
|
dnl
|
|
|
|
AC_DEFUN([OPAL_ASM_CHECK_ATOMIC_FUNC],[
|
|
|
|
OPAL_VAR_SCOPE_PUSH([opal_asm_check_func_happy opal_asm_check_func_CFLAGS_save opal_asm_check_func_LIBS_save])
|
|
|
|
|
|
|
|
opal_asm_check_func_CFLAGS_save=$CFLAGS
|
|
|
|
opal_asm_check_func_LIBS_save=$LIBS
|
|
|
|
|
|
|
|
dnl Check with no compiler/linker flags
|
|
|
|
AC_MSG_CHECKING([for $1])
|
|
|
|
AC_LINK_IFELSE([$2],
|
|
|
|
[opal_asm_check_func_happy=1
|
|
|
|
AC_MSG_RESULT([yes])],
|
|
|
|
[opal_asm_check_func_happy=0
|
|
|
|
AC_MSG_RESULT([no])])
|
|
|
|
|
|
|
|
dnl If that didn't work, try again with CFLAGS+=mcx16
|
|
|
|
AS_IF([test $opal_asm_check_func_happy -eq 0],
|
|
|
|
[AC_MSG_CHECKING([for $1 with -mcx16])
|
|
|
|
CFLAGS="$CFLAGS -mcx16"
|
|
|
|
AC_LINK_IFELSE([$2],
|
|
|
|
[opal_asm_check_func_happy=1
|
|
|
|
AC_MSG_RESULT([yes])],
|
|
|
|
[opal_asm_check_func_happy=0
|
|
|
|
CFLAGS=$opal_asm_check_func_CFLAGS_save
|
|
|
|
AC_MSG_RESULT([no])])
|
|
|
|
])
|
|
|
|
|
|
|
|
dnl If that didn't work, try again with LIBS+=-latomic
|
|
|
|
AS_IF([test $opal_asm_check_func_happy -eq 0],
|
|
|
|
[AC_MSG_CHECKING([for $1 with -latomic])
|
|
|
|
LIBS="$LIBS -latomic"
|
|
|
|
AC_LINK_IFELSE([$2],
|
|
|
|
[opal_asm_check_func_happy=1
|
|
|
|
AC_MSG_RESULT([yes])],
|
|
|
|
[opal_asm_check_func_happy=0
|
|
|
|
LIBS=$opal_asm_check_func_LIBS_save
|
|
|
|
AC_MSG_RESULT([no])])
|
|
|
|
])
|
|
|
|
|
|
|
|
dnl If we have it, try it and make sure it gives a correct result.
|
|
|
|
dnl As of Aug 2018, we know that it links but does *not* work on clang
|
|
|
|
dnl 6 on ARM64.
|
|
|
|
AS_IF([test $opal_asm_check_func_happy -eq 1],
|
|
|
|
[AC_MSG_CHECKING([if $1() gives correct results])
|
|
|
|
AC_RUN_IFELSE([$2],
|
|
|
|
[AC_MSG_RESULT([yes])],
|
|
|
|
[opal_asm_check_func_happy=0
|
|
|
|
AC_MSG_RESULT([no])],
|
|
|
|
[AC_MSG_RESULT([cannot test -- assume yes (cross compiling)])])
|
|
|
|
])
|
2014-12-18 09:34:12 +03:00
|
|
|
|
2018-08-23 18:40:55 +03:00
|
|
|
dnl If we were unsuccessful, restore CFLAGS/LIBS
|
|
|
|
AS_IF([test $opal_asm_check_func_happy -eq 0],
|
|
|
|
[CFLAGS=$opal_asm_check_func_CFLAGS_save
|
|
|
|
LIBS=$opal_asm_check_func_LIBS_save])
|
2014-12-18 09:34:12 +03:00
|
|
|
|
2018-08-23 18:40:55 +03:00
|
|
|
dnl Run the user actions
|
|
|
|
AS_IF([test $opal_asm_check_func_happy -eq 1], [$3], [$4])
|
2014-12-18 09:34:12 +03:00
|
|
|
|
2018-08-23 18:40:55 +03:00
|
|
|
OPAL_VAR_SCOPE_POP
|
|
|
|
])
|
2014-12-18 09:34:12 +03:00
|
|
|
|
2018-08-23 18:40:55 +03:00
|
|
|
dnl ------------------------------------------------------------------
|
2014-12-18 09:34:12 +03:00
|
|
|
|
2018-08-23 18:40:55 +03:00
|
|
|
AC_DEFUN([OPAL_CHECK_SYNC_BUILTIN_CSWAP_INT128], [
|
|
|
|
OPAL_VAR_SCOPE_PUSH([sync_bool_compare_and_swap_128_result])
|
2014-12-18 09:34:12 +03:00
|
|
|
|
2018-08-23 18:40:55 +03:00
|
|
|
# Do we have __sync_bool_compare_and_swap?
|
|
|
|
# Use a special macro because we need to check with a few different
|
|
|
|
# CFLAGS/LIBS.
|
|
|
|
OPAL_ASM_CHECK_ATOMIC_FUNC([__sync_bool_compare_and_swap],
|
|
|
|
[AC_LANG_SOURCE(OPAL_SYNC_BOOL_COMPARE_AND_SWAP_TEST_SOURCE)],
|
|
|
|
[sync_bool_compare_and_swap_128_result=1],
|
|
|
|
[sync_bool_compare_and_swap_128_result=0])
|
2014-12-05 00:25:53 +03:00
|
|
|
|
2018-08-23 18:40:55 +03:00
|
|
|
AC_DEFINE_UNQUOTED([OPAL_HAVE_SYNC_BUILTIN_CSWAP_INT128],
|
|
|
|
[$sync_bool_compare_and_swap_128_result],
|
|
|
|
[Whether the __sync builtin atomic compare and swap supports 128-bit values])
|
2014-12-04 04:40:34 +03:00
|
|
|
|
|
|
|
OPAL_VAR_SCOPE_POP
|
|
|
|
])
|
|
|
|
|
2011-11-23 08:25:41 +04:00
|
|
|
AC_DEFUN([OPAL_CHECK_SYNC_BUILTINS], [
|
|
|
|
AC_MSG_CHECKING([for __sync builtin atomics])
|
|
|
|
|
2016-04-12 19:00:22 +03:00
|
|
|
AC_TRY_LINK([long tmp;], [__sync_synchronize();
|
|
|
|
__sync_bool_compare_and_swap(&tmp, 0, 1);
|
|
|
|
__sync_add_and_fetch(&tmp, 1);],
|
2011-11-23 08:25:41 +04:00
|
|
|
[AC_MSG_RESULT([yes])
|
|
|
|
$1],
|
|
|
|
[AC_MSG_RESULT([no])
|
|
|
|
$2])
|
2016-05-09 12:12:12 +03:00
|
|
|
|
|
|
|
AC_MSG_CHECKING([for 64-bit __sync builtin atomics])
|
|
|
|
|
|
|
|
AC_TRY_LINK([
|
|
|
|
#include <stdint.h>
|
|
|
|
uint64_t tmp;], [
|
|
|
|
__sync_bool_compare_and_swap(&tmp, 0, 1);
|
|
|
|
__sync_add_and_fetch(&tmp, 1);],
|
|
|
|
[AC_MSG_RESULT([yes])
|
|
|
|
opal_asm_sync_have_64bit=1],
|
|
|
|
[AC_MSG_RESULT([no])
|
|
|
|
opal_asm_sync_have_64bit=0])
|
|
|
|
|
|
|
|
AC_DEFINE_UNQUOTED([OPAL_ASM_SYNC_HAVE_64BIT],[$opal_asm_sync_have_64bit],
|
2018-08-18 03:41:13 +03:00
|
|
|
[Whether 64-bit is supported by the __sync builtin atomics])
|
2016-05-10 13:15:26 +03:00
|
|
|
|
|
|
|
# Check for 128-bit support
|
|
|
|
OPAL_CHECK_SYNC_BUILTIN_CSWAP_INT128
|
2011-11-23 08:25:41 +04:00
|
|
|
])
|
|
|
|
|
|
|
|
|
2016-06-02 04:23:47 +03:00
|
|
|
AC_DEFUN([OPAL_CHECK_GCC_BUILTIN_CSWAP_INT128], [
|
2018-08-23 18:40:55 +03:00
|
|
|
OPAL_VAR_SCOPE_PUSH([atomic_compare_exchange_n_128_result atomic_compare_exchange_n_128_CFLAGS_save atomic_compare_exchange_n_128_LIBS_save])
|
|
|
|
|
|
|
|
atomic_compare_exchange_n_128_CFLAGS_save=$CFLAGS
|
|
|
|
atomic_compare_exchange_n_128_LIBS_save=$LIBS
|
|
|
|
|
|
|
|
# Do we have __sync_bool_compare_and_swap?
|
|
|
|
# Use a special macro because we need to check with a few different
|
|
|
|
# CFLAGS/LIBS.
|
|
|
|
OPAL_ASM_CHECK_ATOMIC_FUNC([__atomic_compare_exchange_n],
|
|
|
|
[AC_LANG_SOURCE(OPAL_ATOMIC_COMPARE_EXCHANGE_N_TEST_SOURCE)],
|
|
|
|
[atomic_compare_exchange_n_128_result=1],
|
|
|
|
[atomic_compare_exchange_n_128_result=0])
|
|
|
|
|
|
|
|
# If we have it and it works, check to make sure it is always lock
|
|
|
|
# free.
|
|
|
|
AS_IF([test $atomic_compare_exchange_n_128_result -eq 1],
|
|
|
|
[AC_MSG_CHECKING([if __int128 atomic compare-and-swap is always lock-free])
|
|
|
|
AC_RUN_IFELSE([AC_LANG_PROGRAM([], [if (!__atomic_always_lock_free(16, 0)) { return 1; }])],
|
2016-06-03 00:29:19 +03:00
|
|
|
[AC_MSG_RESULT([yes])],
|
2018-08-23 18:40:55 +03:00
|
|
|
[atomic_compare_exchange_n_128_result=0
|
|
|
|
# If this test fails, need to reset CFLAGS/LIBS (the
|
|
|
|
# above tests atomically set CFLAGS/LIBS or not; this
|
|
|
|
# test is running after the fact, so we have to undo
|
|
|
|
# the side-effects of setting CFLAGS/LIBS if the above
|
|
|
|
# tests passed).
|
|
|
|
CFLAGS=$atomic_compare_exchange_n_128_CFLAGS_save
|
|
|
|
LIBS=$atomic_compare_exchange_n_128_LIBS_save
|
|
|
|
AC_MSG_RESULT([no])],
|
|
|
|
[AC_MSG_RESULT([cannot test -- assume yes (cross compiling)])])
|
|
|
|
])
|
|
|
|
|
|
|
|
AC_DEFINE_UNQUOTED([OPAL_HAVE_GCC_BUILTIN_CSWAP_INT128],
|
|
|
|
[$atomic_compare_exchange_n_128_result],
|
|
|
|
[Whether the __atomic builtin atomic compare swap is both supported and lock-free on 128-bit values])
|
|
|
|
|
|
|
|
dnl If we could not find decent support for 128-bits __atomic let's
|
|
|
|
dnl try the GCC _sync
|
|
|
|
AS_IF([test $atomic_compare_exchange_n_128_result -eq 0],
|
|
|
|
[OPAL_CHECK_SYNC_BUILTIN_CSWAP_INT128])
|
2016-06-02 04:23:47 +03:00
|
|
|
|
|
|
|
OPAL_VAR_SCOPE_POP
|
|
|
|
])
|
|
|
|
|
|
|
|
AC_DEFUN([OPAL_CHECK_GCC_ATOMIC_BUILTINS], [
|
|
|
|
AC_MSG_CHECKING([for __atomic builtin atomics])
|
|
|
|
|
2017-07-04 03:47:45 +03:00
|
|
|
AC_TRY_LINK([
|
|
|
|
#include <stdint.h>
|
|
|
|
uint32_t tmp, old = 0;
|
|
|
|
uint64_t tmp64, old64 = 0;], [
|
|
|
|
__atomic_thread_fence(__ATOMIC_SEQ_CST);
|
2016-06-02 04:23:47 +03:00
|
|
|
__atomic_compare_exchange_n(&tmp, &old, 1, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
|
2017-07-04 03:47:45 +03:00
|
|
|
__atomic_add_fetch(&tmp, 1, __ATOMIC_RELAXED);
|
|
|
|
__atomic_compare_exchange_n(&tmp64, &old64, 1, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
|
|
|
|
__atomic_add_fetch(&tmp64, 1, __ATOMIC_RELAXED);],
|
2016-06-02 04:23:47 +03:00
|
|
|
[AC_MSG_RESULT([yes])
|
|
|
|
$1],
|
|
|
|
[AC_MSG_RESULT([no])
|
|
|
|
$2])
|
|
|
|
|
|
|
|
# Check for 128-bit support
|
|
|
|
OPAL_CHECK_GCC_BUILTIN_CSWAP_INT128
|
|
|
|
])
|
|
|
|
|
|
|
|
|
2008-10-28 20:22:29 +03:00
|
|
|
dnl #################################################################
|
|
|
|
dnl
|
2014-05-07 05:00:06 +04:00
|
|
|
dnl OPAL_CHECK_ASM_TEXT
|
2008-10-28 20:22:29 +03:00
|
|
|
dnl
|
|
|
|
dnl Determine how to set current mode as text.
|
|
|
|
dnl
|
|
|
|
dnl #################################################################
|
2014-05-07 05:00:06 +04:00
|
|
|
AC_DEFUN([OPAL_CHECK_ASM_TEXT],[
|
2008-10-28 20:22:29 +03:00
|
|
|
AC_MSG_CHECKING([directive for setting text section])
|
2009-05-07 00:11:28 +04:00
|
|
|
opal_cv_asm_text=""
|
2014-05-06 19:01:34 +04:00
|
|
|
if test "$opal_cv_c_compiler_vendor" = "microsoft" ; then
|
2008-10-28 20:22:29 +03:00
|
|
|
# text section will be brought in with the rest of
|
|
|
|
# header for MS - leave blank for now
|
2009-05-07 00:11:28 +04:00
|
|
|
opal_cv_asm_text=""
|
2008-10-28 20:22:29 +03:00
|
|
|
else
|
|
|
|
case $host in
|
|
|
|
*-aix*)
|
2009-05-07 00:11:28 +04:00
|
|
|
opal_cv_asm_text=[".csect .text[PR]"]
|
2008-10-28 20:22:29 +03:00
|
|
|
;;
|
|
|
|
*)
|
2009-05-07 00:11:28 +04:00
|
|
|
opal_cv_asm_text=".text"
|
2008-10-28 20:22:29 +03:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
2009-05-07 00:11:28 +04:00
|
|
|
AC_MSG_RESULT([$opal_cv_asm_text])
|
|
|
|
AC_DEFINE_UNQUOTED([OPAL_ASM_TEXT], ["$opal_cv_asm_text"],
|
2008-10-28 20:22:29 +03:00
|
|
|
[Assembly directive for setting text section])
|
2009-05-07 00:11:28 +04:00
|
|
|
OPAL_ASM_TEXT="$opal_cv_asm_text"
|
|
|
|
AC_SUBST(OPAL_ASM_TEXT)
|
2008-10-28 20:22:29 +03:00
|
|
|
])dnl
|
|
|
|
|
|
|
|
|
|
|
|
dnl #################################################################
|
|
|
|
dnl
|
2014-05-07 05:00:06 +04:00
|
|
|
dnl OPAL_CHECK_ASM_GLOBAL
|
2008-10-28 20:22:29 +03:00
|
|
|
dnl
|
2009-05-07 00:11:28 +04:00
|
|
|
dnl Sets OPAL_ASM_GLOBAL to the value to prefix global values
|
2008-10-28 20:22:29 +03:00
|
|
|
dnl
|
|
|
|
dnl I'm sure if I don't have a test for this, there will be some
|
|
|
|
dnl dumb platform that uses something else
|
|
|
|
dnl
|
|
|
|
dnl #################################################################
|
2014-05-07 05:00:06 +04:00
|
|
|
AC_DEFUN([OPAL_CHECK_ASM_GLOBAL],[
|
2008-10-28 20:22:29 +03:00
|
|
|
AC_MSG_CHECKING([directive for exporting symbols])
|
2009-05-07 00:11:28 +04:00
|
|
|
opal_cv_asm_global=""
|
2014-05-06 19:01:34 +04:00
|
|
|
if test "$opal_cv_c_compiler_vendor" = "microsoft" ; then
|
2009-05-07 00:11:28 +04:00
|
|
|
opal_cv_asm_global="PUBLIC"
|
2008-10-28 20:22:29 +03:00
|
|
|
else
|
|
|
|
case $host in
|
|
|
|
*)
|
2009-05-07 00:11:28 +04:00
|
|
|
opal_cv_asm_global=".globl"
|
2008-10-28 20:22:29 +03:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
2009-05-07 00:11:28 +04:00
|
|
|
AC_MSG_RESULT([$opal_cv_asm_global])
|
|
|
|
AC_DEFINE_UNQUOTED([OPAL_ASM_GLOBAL], ["$opal_cv_asm_global"],
|
2008-10-28 20:22:29 +03:00
|
|
|
[Assembly directive for exporting symbols])
|
2009-05-07 00:11:28 +04:00
|
|
|
OPAL_ASM_GLOBAL="$opal_cv_asm_global"
|
2014-05-07 07:01:47 +04:00
|
|
|
AC_SUBST(OPAL_AS_GLOBAL)
|
2008-10-28 20:22:29 +03:00
|
|
|
])dnl
|
|
|
|
|
|
|
|
|
|
|
|
dnl #################################################################
|
|
|
|
dnl
|
2014-05-07 05:00:06 +04:00
|
|
|
dnl OPAL_CHECK_ASM_LSYM
|
2008-10-28 20:22:29 +03:00
|
|
|
dnl
|
2009-05-07 00:11:28 +04:00
|
|
|
dnl Sets OPAL_ASM_LSYM to the prefix value on a symbol to make it
|
2008-10-28 20:22:29 +03:00
|
|
|
dnl an internal label (jump target and whatnot)
|
|
|
|
dnl
|
|
|
|
dnl We look for L .L $ L$ (in that order) for something that both
|
|
|
|
dnl assembles and does not leave a label in the output of nm. Fall
|
|
|
|
dnl back to L if nothing else seems to work :/
|
|
|
|
dnl
|
|
|
|
dnl #################################################################
|
|
|
|
|
2014-05-07 05:00:06 +04:00
|
|
|
# _OPAL_CHECK_ASM_LSYM([variable-to-set])
|
2008-10-28 20:22:29 +03:00
|
|
|
# ---------------------------------------
|
2014-05-07 05:00:06 +04:00
|
|
|
AC_DEFUN([_OPAL_CHECK_ASM_LSYM],[
|
2008-10-28 20:22:29 +03:00
|
|
|
AC_REQUIRE([AC_PROG_GREP])
|
|
|
|
|
|
|
|
$1="L"
|
|
|
|
|
|
|
|
for sym in L .L $ L$ ; do
|
|
|
|
asm_result=0
|
|
|
|
echo "configure: trying $sym" >&AC_FD_CC
|
2014-05-07 00:30:37 +04:00
|
|
|
OPAL_TRY_ASSEMBLE([foobar$opal_cv_asm_label_suffix
|
2009-05-07 00:11:28 +04:00
|
|
|
${sym}mytestlabel$opal_cv_asm_label_suffix],
|
2015-06-24 06:59:57 +03:00
|
|
|
[# ok, we succeeded at assembling. see if we can nm,
|
2008-10-28 20:22:29 +03:00
|
|
|
# throwing the results in a file
|
|
|
|
if $NM conftest.$OBJEXT > conftest.out 2>&AC_FD_CC ; then
|
|
|
|
if test "`$GREP mytestlabel conftest.out`" = "" ; then
|
|
|
|
# there was no symbol... looks promising to me
|
|
|
|
$1="$sym"
|
|
|
|
asm_result=1
|
|
|
|
elif test ["`$GREP ' [Nt] .*mytestlabel' conftest.out`"] = "" ; then
|
|
|
|
# see if we have a non-global-ish symbol
|
|
|
|
# but we should see if we can do better.
|
|
|
|
$1="$sym"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
# not so much on the NM goodness :/
|
|
|
|
echo "$NM failed. Output from NM was:" >&AC_FD_CC
|
|
|
|
cat conftest.out >&AC_FD_CC
|
|
|
|
AC_MSG_WARN([$NM could not read object file])
|
|
|
|
fi
|
|
|
|
])
|
|
|
|
if test "$asm_result" = "1" ; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
rm -f conftest.out
|
|
|
|
unset asm_result sym
|
|
|
|
])
|
|
|
|
|
2014-05-07 05:00:06 +04:00
|
|
|
# OPAL_CHECK_ASM_LSYM()
|
2008-10-28 20:22:29 +03:00
|
|
|
# ---------------------
|
2014-05-07 05:00:06 +04:00
|
|
|
AC_DEFUN([OPAL_CHECK_ASM_LSYM],[
|
2008-10-28 20:22:29 +03:00
|
|
|
AC_REQUIRE([AC_PROG_NM])
|
|
|
|
|
|
|
|
AC_CACHE_CHECK([prefix for lsym labels],
|
2009-05-07 00:11:28 +04:00
|
|
|
[opal_cv_asm_lsym],
|
2014-05-07 05:00:06 +04:00
|
|
|
[_OPAL_CHECK_ASM_LSYM([opal_cv_asm_lsym])])
|
2009-05-07 00:11:28 +04:00
|
|
|
AC_DEFINE_UNQUOTED([OPAL_ASM_LSYM], ["$opal_cv_asm_lsym"],
|
2008-10-28 20:22:29 +03:00
|
|
|
[Assembly prefix for lsym labels])
|
2009-05-07 00:11:28 +04:00
|
|
|
OPAL_ASM_LSYM="$opal_cv_asm_lsym"
|
|
|
|
AC_SUBST(OPAL_ASM_LSYM)
|
2008-10-28 20:22:29 +03:00
|
|
|
])dnl
|
|
|
|
|
|
|
|
dnl #################################################################
|
|
|
|
dnl
|
2014-05-07 05:00:06 +04:00
|
|
|
dnl OPAL_CHECK_ASM_PROC
|
2008-10-28 20:22:29 +03:00
|
|
|
dnl
|
|
|
|
dnl Sets a cv-flag, if the compiler needs a proc/endp-definition to
|
|
|
|
dnl link with C.
|
|
|
|
dnl
|
|
|
|
dnl #################################################################
|
2014-05-07 05:00:06 +04:00
|
|
|
AC_DEFUN([OPAL_CHECK_ASM_PROC],[
|
2008-10-28 20:22:29 +03:00
|
|
|
AC_CACHE_CHECK([if .proc/endp is needed],
|
2014-05-07 05:00:06 +04:00
|
|
|
[opal_cv_asm_need_proc],
|
|
|
|
[opal_cv_asm_need_proc="no"
|
2014-05-07 00:30:37 +04:00
|
|
|
OPAL_TRY_ASSEMBLE([
|
2008-10-28 20:22:29 +03:00
|
|
|
.proc mysym
|
|
|
|
mysym:
|
|
|
|
.endp mysym],
|
2014-05-07 05:00:06 +04:00
|
|
|
[opal_cv_asm_need_proc="yes"])
|
2008-10-28 20:22:29 +03:00
|
|
|
rm -f conftest.out])
|
|
|
|
|
2014-05-07 05:00:06 +04:00
|
|
|
if test "$opal_cv_asm_need_proc" = "yes" ; then
|
|
|
|
opal_cv_asm_proc=".proc"
|
|
|
|
opal_cv_asm_endproc=".endp"
|
2008-10-28 20:22:29 +03:00
|
|
|
else
|
2014-05-07 05:00:06 +04:00
|
|
|
opal_cv_asm_proc="#"
|
|
|
|
opal_cv_asm_endproc="#"
|
2008-10-28 20:22:29 +03:00
|
|
|
fi
|
|
|
|
])dnl
|
|
|
|
|
|
|
|
|
|
|
|
dnl #################################################################
|
|
|
|
dnl
|
2014-05-07 05:00:06 +04:00
|
|
|
dnl OPAL_CHECK_ASM_GSYM
|
2008-10-28 20:22:29 +03:00
|
|
|
dnl
|
2009-05-07 00:11:28 +04:00
|
|
|
dnl Sets OPAL_ASM_GSYM to the prefix value on a symbol to make it
|
2008-10-28 20:22:29 +03:00
|
|
|
dnl a global linkable from C. Basically, an _ or not.
|
|
|
|
dnl
|
|
|
|
dnl #################################################################
|
2014-05-07 05:00:06 +04:00
|
|
|
AC_DEFUN([OPAL_CHECK_ASM_GSYM],[
|
2008-10-28 20:22:29 +03:00
|
|
|
AC_CACHE_CHECK([prefix for global symbol labels],
|
2009-05-07 00:11:28 +04:00
|
|
|
[opal_cv_asm_gsym],
|
2014-05-07 05:00:06 +04:00
|
|
|
[_OPAL_CHECK_ASM_GSYM])
|
2008-10-28 20:22:29 +03:00
|
|
|
|
2009-05-07 00:11:28 +04:00
|
|
|
if test "$opal_cv_asm_gsym" = "none" ; then
|
2008-10-28 20:22:29 +03:00
|
|
|
AC_MSG_ERROR([Could not determine global symbol label prefix])
|
|
|
|
fi
|
|
|
|
|
2009-05-07 00:11:28 +04:00
|
|
|
AC_DEFINE_UNQUOTED([OPAL_ASM_GSYM], ["$opal_cv_asm_gsym"],
|
2008-10-28 20:22:29 +03:00
|
|
|
[Assembly prefix for gsym labels])
|
2009-05-07 00:11:28 +04:00
|
|
|
OPAL_ASM_GSYM="$opal_cv_asm_gsym"
|
|
|
|
AC_SUBST(OPAL_ASM_GSYM)
|
2008-10-28 20:22:29 +03:00
|
|
|
|
|
|
|
])
|
|
|
|
|
2014-05-07 05:00:06 +04:00
|
|
|
AC_DEFUN([_OPAL_CHECK_ASM_GSYM],[
|
2009-05-07 00:11:28 +04:00
|
|
|
opal_cv_asm_gsym="none"
|
2008-10-28 20:22:29 +03:00
|
|
|
|
|
|
|
for sym in "_" "" "." ; do
|
|
|
|
asm_result=0
|
|
|
|
echo "configure: trying $sym" >&AC_FD_CC
|
|
|
|
cat > conftest_c.c <<EOF
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
void gsym_test_func(void);
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
int
|
|
|
|
main()
|
|
|
|
{
|
|
|
|
gsym_test_func();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
2014-05-07 00:30:37 +04:00
|
|
|
OPAL_TRY_ASSEMBLE([
|
2009-05-07 00:11:28 +04:00
|
|
|
$opal_cv_asm_text
|
2014-05-07 05:00:06 +04:00
|
|
|
$opal_cv_asm_proc ${sym}gsym_test_func
|
2009-05-07 00:11:28 +04:00
|
|
|
$opal_cv_asm_global ${sym}gsym_test_func
|
|
|
|
${sym}gsym_test_func${opal_cv_asm_label_suffix}
|
2014-05-07 05:00:06 +04:00
|
|
|
$opal_cv_asm_endproc ${sym}gsym_test_func
|
2008-10-28 20:22:29 +03:00
|
|
|
],
|
2014-05-07 07:01:47 +04:00
|
|
|
[opal_compile="$CC $CFLAGS -I. conftest_c.c -c > conftest.cmpl 2>&1"
|
|
|
|
if AC_TRY_EVAL(opal_compile) ; then
|
2008-10-28 20:22:29 +03:00
|
|
|
# save the warnings
|
|
|
|
cat conftest.cmpl >&AC_FD_CC
|
2014-05-07 07:01:47 +04:00
|
|
|
opal_link="$CC $CFLAGS conftest_c.$OBJEXT conftest.$OBJEXT -o conftest $LDFLAGS $LIBS > conftest.link 2>&1"
|
|
|
|
if AC_TRY_EVAL(opal_link) ; then
|
2008-10-28 20:22:29 +03:00
|
|
|
# save the warnings
|
|
|
|
cat conftest.link >&AC_FD_CC
|
|
|
|
asm_result=1
|
|
|
|
else
|
|
|
|
cat conftest.link >&AC_FD_CC
|
|
|
|
echo "configure: failed C program was: " >&AC_FD_CC
|
|
|
|
cat conftest_c.c >&AC_FD_CC
|
|
|
|
echo "configure: failed ASM program was: " >&AC_FD_CC
|
|
|
|
cat conftest.s >&AC_FD_CC
|
|
|
|
asm_result=0
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
# save output and failed program
|
|
|
|
cat conftest.cmpl >&AC_FD_CC
|
|
|
|
echo "configure: failed C program was: " >&AC_FD_CC
|
|
|
|
cat conftest.c >&AC_FD_CC
|
|
|
|
asm_result=0
|
2015-06-24 06:59:57 +03:00
|
|
|
fi],
|
2008-10-28 20:22:29 +03:00
|
|
|
[asm_result=0])
|
|
|
|
if test "$asm_result" = "1" ; then
|
2009-05-07 00:11:28 +04:00
|
|
|
opal_cv_asm_gsym="$sym"
|
2008-10-28 20:22:29 +03:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
rm -rf conftest.*
|
|
|
|
])dnl
|
|
|
|
|
|
|
|
|
|
|
|
dnl #################################################################
|
|
|
|
dnl
|
2014-05-07 05:00:06 +04:00
|
|
|
dnl OPAL_CHECK_ASM_LABEL_SUFFIX
|
2008-10-28 20:22:29 +03:00
|
|
|
dnl
|
2009-05-07 00:11:28 +04:00
|
|
|
dnl Sets OPAL_ASM_LABEL_SUFFIX to the value to suffix for labels
|
2008-10-28 20:22:29 +03:00
|
|
|
dnl
|
|
|
|
dnl I'm sure if I don't have a test for this, there will be some
|
|
|
|
dnl dumb platform that uses something else
|
|
|
|
dnl
|
|
|
|
dnl #################################################################
|
2014-05-07 05:00:06 +04:00
|
|
|
AC_DEFUN([OPAL_CHECK_ASM_LABEL_SUFFIX],[
|
2008-10-28 20:22:29 +03:00
|
|
|
AC_MSG_CHECKING([suffix for labels])
|
2009-05-07 00:11:28 +04:00
|
|
|
opal_cv_asm_label_suffix=""
|
2008-10-28 20:22:29 +03:00
|
|
|
case $host in
|
|
|
|
*)
|
2009-05-07 00:11:28 +04:00
|
|
|
opal_cv_asm_label_suffix=":"
|
2008-10-28 20:22:29 +03:00
|
|
|
;;
|
|
|
|
esac
|
2009-05-07 00:11:28 +04:00
|
|
|
AC_MSG_RESULT([$opal_cv_asm_label_suffix])
|
|
|
|
AC_DEFINE_UNQUOTED([OPAL_ASM_LABEL_SUFFIX], ["$opal_cv_asm_label_suffix"],
|
2008-10-28 20:22:29 +03:00
|
|
|
[Assembly suffix for labels])
|
2009-05-07 00:11:28 +04:00
|
|
|
OPAL_ASM_LABEL_SUFFIX="$opal_cv_asm_label_suffix"
|
2014-05-07 07:01:47 +04:00
|
|
|
AC_SUBST(OPAL_AS_LABEL_SUFFIX)
|
2008-10-28 20:22:29 +03:00
|
|
|
])dnl
|
|
|
|
|
|
|
|
|
|
|
|
dnl #################################################################
|
|
|
|
dnl
|
2014-05-07 05:00:06 +04:00
|
|
|
dnl OPAL_CHECK_ASM_ALIGN_LOG
|
2008-10-28 20:22:29 +03:00
|
|
|
dnl
|
2015-06-24 06:59:57 +03:00
|
|
|
dnl Sets OPAL_ASM_ALIGN_LOG to 1 if align is specified
|
2008-10-28 20:22:29 +03:00
|
|
|
dnl logarithmically, 0 otherwise
|
|
|
|
dnl
|
|
|
|
dnl #################################################################
|
2014-05-07 05:00:06 +04:00
|
|
|
AC_DEFUN([OPAL_CHECK_ASM_ALIGN_LOG],[
|
2008-10-28 20:22:29 +03:00
|
|
|
AC_REQUIRE([AC_PROG_NM])
|
|
|
|
AC_REQUIRE([AC_PROG_GREP])
|
|
|
|
|
|
|
|
AC_CACHE_CHECK([if .align directive takes logarithmic value],
|
2014-05-07 05:00:06 +04:00
|
|
|
[opal_cv_asm_align_log],
|
2014-05-07 00:30:37 +04:00
|
|
|
[ OPAL_TRY_ASSEMBLE([ $opal_cv_asm_text
|
2008-10-28 20:22:29 +03:00
|
|
|
.align 4
|
2009-05-07 00:11:28 +04:00
|
|
|
$opal_cv_asm_global foo
|
2008-10-28 20:22:29 +03:00
|
|
|
.byte 1
|
|
|
|
.align 4
|
2009-05-07 00:11:28 +04:00
|
|
|
foo$opal_cv_asm_label_suffix
|
2015-06-24 06:59:57 +03:00
|
|
|
.byte 2],
|
2014-05-07 07:01:47 +04:00
|
|
|
[opal_asm_addr=[`$NM conftest.$OBJEXT | $GREP foo | sed -e 's/.*\([0-9a-fA-F][0-9a-fA-F]\).*foo.*/\1/'`]],
|
|
|
|
[opal_asm_addr=""])
|
2008-10-28 20:22:29 +03:00
|
|
|
# test for both 16 and 10 (decimal and hex notations)
|
2014-05-07 07:01:47 +04:00
|
|
|
echo "configure: .align test address offset is $opal_asm_addr" >&AC_FD_CC
|
2015-02-03 09:19:22 +03:00
|
|
|
if test "$opal_asm_addr" = "16" || test "$opal_asm_addr" = "10" ; then
|
2014-05-07 05:00:06 +04:00
|
|
|
opal_cv_asm_align_log="yes"
|
2008-10-28 20:22:29 +03:00
|
|
|
else
|
2014-05-07 05:00:06 +04:00
|
|
|
opal_cv_asm_align_log="no"
|
2008-10-28 20:22:29 +03:00
|
|
|
fi])
|
|
|
|
|
2015-02-03 09:19:22 +03:00
|
|
|
if test "$opal_cv_asm_align_log" = "yes" || test "$opal_cv_asm_align_log" = "1" ; then
|
2014-05-07 07:01:47 +04:00
|
|
|
opal_asm_align_log_result=1
|
2008-10-28 20:22:29 +03:00
|
|
|
else
|
2014-05-07 07:01:47 +04:00
|
|
|
opal_asm_align_log_result=0
|
2008-10-28 20:22:29 +03:00
|
|
|
fi
|
|
|
|
|
2009-05-07 00:11:28 +04:00
|
|
|
AC_DEFINE_UNQUOTED([OPAL_ASM_ALIGN_LOG],
|
2008-10-28 20:22:29 +03:00
|
|
|
[$asm_align_log_result],
|
|
|
|
[Assembly align directive expects logarithmic value])
|
|
|
|
|
|
|
|
unset omp_asm_addr asm_result
|
|
|
|
])dnl
|
|
|
|
|
|
|
|
|
|
|
|
dnl #################################################################
|
|
|
|
dnl
|
2014-05-07 05:00:06 +04:00
|
|
|
dnl OPAL_CHECK_ASM_TYPE
|
2008-10-28 20:22:29 +03:00
|
|
|
dnl
|
2015-06-24 06:59:57 +03:00
|
|
|
dnl Sets OPAL_ASM_TYPE to the prefix for the function type to
|
2008-10-28 20:22:29 +03:00
|
|
|
dnl set a symbol's type as function (needed on ELF for shared
|
2018-04-09 18:44:48 +03:00
|
|
|
dnl libraries). If no .type directive is needed, sets OPAL_ASM_TYPE
|
2008-10-28 20:22:29 +03:00
|
|
|
dnl to an empty string
|
|
|
|
dnl
|
|
|
|
dnl We look for @ \# %
|
|
|
|
dnl
|
|
|
|
dnl #################################################################
|
2014-05-07 05:00:06 +04:00
|
|
|
AC_DEFUN([OPAL_CHECK_ASM_TYPE],[
|
2008-10-28 20:22:29 +03:00
|
|
|
AC_CACHE_CHECK([prefix for function in .type],
|
2009-05-07 00:11:28 +04:00
|
|
|
[opal_cv_asm_type],
|
2014-05-07 05:00:06 +04:00
|
|
|
[_OPAL_CHECK_ASM_TYPE])
|
2008-10-28 20:22:29 +03:00
|
|
|
|
2009-05-07 00:11:28 +04:00
|
|
|
AC_DEFINE_UNQUOTED([OPAL_ASM_TYPE], ["$opal_cv_asm_type"],
|
2008-10-28 20:22:29 +03:00
|
|
|
[How to set function type in .type directive])
|
2009-05-07 00:11:28 +04:00
|
|
|
OPAL_ASM_TYPE="$opal_cv_asm_type"
|
|
|
|
AC_SUBST(OPAL_ASM_TYPE)
|
2008-10-28 20:22:29 +03:00
|
|
|
])
|
|
|
|
|
2014-05-07 05:00:06 +04:00
|
|
|
AC_DEFUN([_OPAL_CHECK_ASM_TYPE],[
|
2009-05-07 00:11:28 +04:00
|
|
|
opal_cv_asm_type=""
|
2008-10-28 20:22:29 +03:00
|
|
|
|
|
|
|
case "${host}" in
|
|
|
|
*-sun-solaris*)
|
|
|
|
# GCC on solaris seems to accept just about anything, not
|
|
|
|
# that what it defines actually works... So just hardwire
|
|
|
|
# to the right answer
|
2009-05-07 00:11:28 +04:00
|
|
|
opal_cv_asm_type="#"
|
2008-10-28 20:22:29 +03:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
for type in @ \# % ; do
|
|
|
|
asm_result=0
|
|
|
|
echo "configure: trying $type" >&AC_FD_CC
|
2014-05-07 00:30:37 +04:00
|
|
|
OPAL_TRY_ASSEMBLE([ .type mysym, ${type}function
|
2008-10-28 20:22:29 +03:00
|
|
|
mysym:],
|
2009-05-07 00:11:28 +04:00
|
|
|
[opal_cv_asm_type="${type}"
|
2008-10-28 20:22:29 +03:00
|
|
|
asm_result=1])
|
|
|
|
if test "$asm_result" = "1" ; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
rm -f conftest.out
|
|
|
|
|
|
|
|
unset asm_result type
|
|
|
|
])dnl
|
|
|
|
|
|
|
|
|
|
|
|
dnl #################################################################
|
|
|
|
dnl
|
2014-05-07 05:00:06 +04:00
|
|
|
dnl OPAL_CHECK_ASM_SIZE
|
2008-10-28 20:22:29 +03:00
|
|
|
dnl
|
2009-05-07 00:11:28 +04:00
|
|
|
dnl Sets OPAL_ASM_SIZE to 1 if we should set .size directives for
|
2008-10-28 20:22:29 +03:00
|
|
|
dnl each function, 0 otherwise.
|
|
|
|
dnl
|
|
|
|
dnl #################################################################
|
2014-05-07 05:00:06 +04:00
|
|
|
AC_DEFUN([OPAL_CHECK_ASM_SIZE],[
|
2008-10-28 20:22:29 +03:00
|
|
|
AC_CACHE_CHECK([if .size is needed],
|
2014-05-07 05:00:06 +04:00
|
|
|
[opal_cv_asm_need_size],
|
|
|
|
[opal_cv_asm_need_size="no"
|
2014-05-07 00:30:37 +04:00
|
|
|
OPAL_TRY_ASSEMBLE([ .size mysym, 1],
|
2014-05-07 05:00:06 +04:00
|
|
|
[opal_cv_asm_need_size="yes"])
|
2008-10-28 20:22:29 +03:00
|
|
|
rm -f conftest.out])
|
|
|
|
|
2014-05-07 05:00:06 +04:00
|
|
|
if test "$opal_cv_asm_need_size" = "yes" ; then
|
2009-05-07 00:11:28 +04:00
|
|
|
opal_asm_size=1
|
2008-10-28 20:22:29 +03:00
|
|
|
else
|
2009-05-07 00:11:28 +04:00
|
|
|
opal_asm_size=0
|
2008-10-28 20:22:29 +03:00
|
|
|
fi
|
|
|
|
|
2009-05-07 00:11:28 +04:00
|
|
|
AC_DEFINE_UNQUOTED([OPAL_ASM_SIZE], ["$opal_asm_size"],
|
2008-10-28 20:22:29 +03:00
|
|
|
[Do we need to give a .size directive])
|
2009-05-07 00:11:28 +04:00
|
|
|
OPAL_ASM_SIZE="$opal_asm_size"
|
|
|
|
AC_SUBST(OPAL_ASM_TYPE)
|
2008-10-28 20:22:29 +03:00
|
|
|
unset asm_result
|
|
|
|
])dnl
|
|
|
|
|
|
|
|
|
2014-05-07 05:00:06 +04:00
|
|
|
# OPAL_CHECK_ASM_GNU_STACKEXEC(var)
|
2008-10-28 20:22:29 +03:00
|
|
|
# ----------------------------------
|
|
|
|
# sets shell variable var to the things necessary to
|
|
|
|
# disable execable stacks with GAS
|
2014-05-07 05:00:06 +04:00
|
|
|
AC_DEFUN([OPAL_CHECK_ASM_GNU_STACKEXEC], [
|
2008-10-28 20:22:29 +03:00
|
|
|
AC_REQUIRE([AC_PROG_GREP])
|
|
|
|
|
|
|
|
AC_CHECK_PROG([OBJDUMP], [objdump], [objdump])
|
|
|
|
AC_CACHE_CHECK([if .note.GNU-stack is needed],
|
2014-05-07 05:00:06 +04:00
|
|
|
[opal_cv_asm_gnu_stack_result],
|
2008-10-28 20:22:29 +03:00
|
|
|
[AS_IF([test "$OBJDUMP" != ""],
|
|
|
|
[ # first, see if a simple C program has it set
|
|
|
|
cat >conftest.c <<EOF
|
|
|
|
int testfunc() {return 0; }
|
|
|
|
EOF
|
2010-11-13 02:22:11 +03:00
|
|
|
OPAL_LOG_COMMAND([$CC $CFLAGS -c conftest.c -o conftest.$OBJEXT],
|
2014-05-07 05:00:06 +04:00
|
|
|
[$OBJDUMP -x conftest.$OBJEXT | $GREP '\.note\.GNU-stack' > /dev/null && opal_cv_asm_gnu_stack_result=yes],
|
2010-11-13 02:22:11 +03:00
|
|
|
[OPAL_LOG_MSG([the failed program was:], 1)
|
|
|
|
OPAL_LOG_FILE([conftest.c])
|
2014-05-07 05:00:06 +04:00
|
|
|
opal_cv_asm_gnu_stack_result=no])
|
|
|
|
if test "$opal_cv_asm_gnu_stack_result" != "yes" ; then
|
|
|
|
opal_cv_asm_gnu_stack_result="no"
|
2008-10-28 20:22:29 +03:00
|
|
|
fi
|
|
|
|
rm -rf conftest.*],
|
2014-05-07 05:00:06 +04:00
|
|
|
[opal_cv_asm_gnu_stack_result="no"])])
|
|
|
|
if test "$opal_cv_asm_gnu_stack_result" = "yes" ; then
|
|
|
|
opal_cv_asm_gnu_stack=1
|
2008-10-28 20:22:29 +03:00
|
|
|
else
|
2014-05-07 05:00:06 +04:00
|
|
|
opal_cv_asm_gnu_stack=0
|
2008-10-28 20:22:29 +03:00
|
|
|
fi
|
|
|
|
])dnl
|
|
|
|
|
|
|
|
|
|