|
Packit Service |
c5cf8c |
dnl /*D PAC_C_MEMATOMIC - Try and determine how to implement memory-atomic
|
|
Packit Service |
c5cf8c |
dnl operations with the selected C compiler
|
|
Packit Service |
c5cf8c |
dnl
|
|
Packit Service |
c5cf8c |
dnl Synopsis:
|
|
Packit Service |
c5cf8c |
dnl PAC_C_MEMATOMIC
|
|
Packit Service |
c5cf8c |
dnl
|
|
Packit Service |
c5cf8c |
dnl Notes:
|
|
Packit Service |
c5cf8c |
dnl Defines names of the following form
|
|
Packit Service |
c5cf8c |
dnl + HAVE_GCC_ASM_AND_X86_{MFENCE,LFENCE,SFENCE} - gcc __asm__ will issue
|
|
Packit Service |
c5cf8c |
dnl mfence, lfence, or sfence
|
|
Packit Service |
c5cf8c |
dnl . HAVE___ASM_AND_X86_{MFENCE,LFENCE,SFENCE} - __asm _emit will issue
|
|
Packit Service |
c5cf8c |
dnl mfence, lfence, or sfence
|
|
Packit Service |
c5cf8c |
dnl . HAVE_ASM_AND_X86_{MFENCE,LFENCE,SFENCE} - asm("...") will issue
|
|
Packit Service |
c5cf8c |
dnl mfence, lfence, or sfence
|
|
Packit Service |
c5cf8c |
dnl . HAVE__INTERLOCKEDEXCHANGE - _InterlockedExchange intrinsic is available
|
|
Packit Service |
c5cf8c |
dnl (IA64)
|
|
Packit Service |
c5cf8c |
dnl . HAVE_GCC_ASM_SPARC_MEMBAR - gcc __asm__ will issue SPARC architecture
|
|
Packit Service |
c5cf8c |
dnl memory barrier instruction
|
|
Packit Service |
c5cf8c |
dnl . HAVE_SOLARIS_ASM_SPARC_MEMBAR - Solaris asm() will issue SPARC
|
|
Packit Service |
c5cf8c |
dnl architecture memory barrier instruction
|
|
Packit Service |
c5cf8c |
dnl . HAVE_GCC_ASM_SPARC_STBAR - gcc __asm__ will issue stbar
|
|
Packit Service |
c5cf8c |
dnl - HAVE_SOLARIS_ASM_SPARC_STBAR - Solaris __asm() will issue stbar
|
|
Packit Service |
c5cf8c |
dnl
|
|
Packit Service |
c5cf8c |
dnl D*/
|
|
Packit Service |
c5cf8c |
AC_DEFUN([PAC_C_MEMATOMIC],[
|
|
Packit Service |
c5cf8c |
AC_CACHE_CHECK([for x86 mfence instruction using __asm__],
|
|
Packit Service |
c5cf8c |
pac_cv_have_gcc_asm_and_x86_mfence,[
|
|
Packit Service |
c5cf8c |
AC_TRY_RUN([
|
|
Packit Service |
c5cf8c |
int main(int argc, char **argv)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
__asm__ __volatile__ ( ".byte 0x0f, 0xae, 0xf0" ::: "memory" );
|
|
Packit Service |
c5cf8c |
exit(0);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
],
|
|
Packit Service |
c5cf8c |
pac_cv_have_gcc_asm_and_x86_mfence=yes,pac_cv_have_gcc_asm_and_x86_mfence=no)])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if test "$pac_cv_have_gcc_asm_and_x86_mfence" = "yes" ; then
|
|
Packit Service |
c5cf8c |
AC_DEFINE(HAVE_GCC_ASM_AND_X86_MFENCE, 1, [Define if using gcc on a x86 system with the mfence instruction])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AC_CACHE_CHECK([for x86 sfence instruction using __asm__],
|
|
Packit Service |
c5cf8c |
pac_cv_have_gcc_asm_and_x86_sfence,[
|
|
Packit Service |
c5cf8c |
AC_TRY_RUN([
|
|
Packit Service |
c5cf8c |
int main(int argc, char **argv)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
__asm__ __volatile__ ( ".byte 0x0f, 0xae, 0xf8" ::: "memory" );
|
|
Packit Service |
c5cf8c |
exit(0);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
],
|
|
Packit Service |
c5cf8c |
pac_cv_have_gcc_asm_and_x86_sfence=yes,pac_cv_have_gcc_asm_and_x86_sfence=no)])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if test "$pac_cv_have_gcc_asm_and_x86_sfence" = "yes" ; then
|
|
Packit Service |
c5cf8c |
AC_DEFINE(HAVE_GCC_ASM_AND_X86_SFENCE, 1, [Define if using gcc on a x86 system with the sfence instruction])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AC_CACHE_CHECK([for x86 lfence instruction using __asm__],
|
|
Packit Service |
c5cf8c |
pac_cv_have_gcc_asm_and_x86_lfence,[
|
|
Packit Service |
c5cf8c |
AC_TRY_RUN([
|
|
Packit Service |
c5cf8c |
int main(int argc, char **argv)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
__asm__ __volatile__ ( ".byte 0x0f, 0xae, 0xe8" ::: "memory" );
|
|
Packit Service |
c5cf8c |
exit(0);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
],
|
|
Packit Service |
c5cf8c |
pac_cv_have_gcc_asm_and_x86_lfence=yes,pac_cv_have_gcc_asm_and_x86_lfence=no)])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if test "$pac_cv_have_gcc_asm_and_x86_lfence" = "yes" ; then
|
|
Packit Service |
c5cf8c |
AC_DEFINE(HAVE_GCC_ASM_AND_X86_LFENCE, 1, [Define if using gcc on a x86 system with the lfence instruction])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
dnl Some compilers, like icc, may want __asm _emit
|
|
Packit Service |
c5cf8c |
AC_CACHE_CHECK([for x86 mfence instruction using __asm],
|
|
Packit Service |
c5cf8c |
pac_cv_have___asm_and_x86_mfence,[
|
|
Packit Service |
c5cf8c |
AC_TRY_RUN([
|
|
Packit Service |
c5cf8c |
int main(int argc, char **argv)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
__asm _emit 0x0f __asm _emit 0xae __asm _emit 0xf0 ;
|
|
Packit Service |
c5cf8c |
exit(0);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
],
|
|
Packit Service |
c5cf8c |
pac_cv_have___asm_and_x86_mfence=yes,pac_cv_have___asm_and_x86_mfence=no)])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if test "$pac_cv_have___asm_and_x86_mfence" = "yes" ; then
|
|
Packit Service |
c5cf8c |
AC_DEFINE(HAVE___ASM_AND_X86_MFENCE, 1, [Define if using __asm on a x86 system with the mfence instruction])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AC_CACHE_CHECK([for x86 sfence instruction using __asm],
|
|
Packit Service |
c5cf8c |
pac_cv_have___asm_and_x86_sfence,[
|
|
Packit Service |
c5cf8c |
AC_TRY_RUN([
|
|
Packit Service |
c5cf8c |
int main(int argc, char **argv)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
__asm sfence ;
|
|
Packit Service |
c5cf8c |
exit(0);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
],
|
|
Packit Service |
c5cf8c |
pac_cv_have___asm_and_x86_sfence=yes,pac_cv_have___asm_and_x86_sfence=no)])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if test "$pac_cv_have___asm_and_x86_sfence" = "yes" ; then
|
|
Packit Service |
c5cf8c |
AC_DEFINE(HAVE___ASM_AND_X86_SFENCE, 1, [Define if using __asm on a x86 system with the sfence instruction])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AC_CACHE_CHECK([for x86 lfence instruction using __asm],
|
|
Packit Service |
c5cf8c |
pac_cv_have___asm_and_x86_lfence,[
|
|
Packit Service |
c5cf8c |
AC_TRY_RUN([
|
|
Packit Service |
c5cf8c |
int main(int argc, char **argv)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
__asm _emit 0x0f __asm _emit 0xae __asm _emit 0xe8 ;
|
|
Packit Service |
c5cf8c |
exit(0);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
],
|
|
Packit Service |
c5cf8c |
pac_cv_have___asm_and_x86_lfence=yes,pac_cv_have___asm_and_x86_lfence=no)])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if test "$lac_cv_have___asm_and_x86_lfence" = "yes" ; then
|
|
Packit Service |
c5cf8c |
AC_DEFINE(HAVE___ASM_AND_X86_LFENCE, 1, [Define if using __asm on a x86 system with the lfence instruction])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
dnl
|
|
Packit Service |
c5cf8c |
dnl Some compilers, such as pgcc, may require additional arguments.
|
|
Packit Service |
c5cf8c |
dnl pgcc may need -Masmkeyword flag. We may want to try this with and
|
|
Packit Service |
c5cf8c |
dnl without adding -Masmkeyword to CFLAGS
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AC_CACHE_CHECK([for x86 mfence instruction using asm()],
|
|
Packit Service |
c5cf8c |
pac_cv_have_asm_and_x86_mfence,[
|
|
Packit Service |
c5cf8c |
AC_TRY_RUN([
|
|
Packit Service |
c5cf8c |
int main(int argc, char **argv)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
asm("_emit 0x0f __asm _emit 0xae __asm _emit 0xf0");
|
|
Packit Service |
c5cf8c |
exit(0);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
],
|
|
Packit Service |
c5cf8c |
pac_cv_have_asm_and_x86_mfence=yes,pac_cv_have_asm_and_x86_mfence=no)])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if test "$pac_cv_have_asm_and_x86_mfence" = "yes" ; then
|
|
Packit Service |
c5cf8c |
AC_DEFINE(HAVE_ASM_AND_X86_MFENCE, 1, [Define if using asm() on a x86 system with the mfence instruction])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AC_CACHE_CHECK([for x86 sfence instruction using asm()],
|
|
Packit Service |
c5cf8c |
pac_cv_have_asm_and_x86_sfence,[
|
|
Packit Service |
c5cf8c |
AC_TRY_RUN([
|
|
Packit Service |
c5cf8c |
int main(int argc, char **argv)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
asm("sfence");
|
|
Packit Service |
c5cf8c |
exit(0);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
],
|
|
Packit Service |
c5cf8c |
pac_cv_have_asm_and_x86_sfence=yes,pac_cv_have_asm_and_x86_sfence=no)])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if test "$pac_cv_have_asm_and_x86_sfence" = "yes" ; then
|
|
Packit Service |
c5cf8c |
AC_DEFINE(HAVE_ASM_AND_X86_SFENCE, 1, [Define if using asm() on a x86 system with the sfence instruction])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AC_CACHE_CHECK([for x86 lfence instruction using asm()],
|
|
Packit Service |
c5cf8c |
pac_cv_have_asm_and_x86_lfence,[
|
|
Packit Service |
c5cf8c |
AC_TRY_RUN([
|
|
Packit Service |
c5cf8c |
int main(int argc, char **argv)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
asm("_emit 0x0f __asm _emit 0xae __asm _emit 0xe8");
|
|
Packit Service |
c5cf8c |
exit(0);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
],
|
|
Packit Service |
c5cf8c |
pac_cv_have_asm_and_x86_lfence=yes,pac_cv_have_asm_and_x86_lfence=no)])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if test "$pac_cv_have_asm_and_x86_lfence" = "yes" ; then
|
|
Packit Service |
c5cf8c |
AC_DEFINE(HAVE_ASM_AND_X86_LFENCE, 1, [Define if using asm() on a x86 system with the lfence instruction])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AC_CACHE_CHECK([for _InterlockedExchange intrinsic],
|
|
Packit Service |
c5cf8c |
pac_cv_have__InterlockedExchange,[
|
|
Packit Service |
c5cf8c |
AC_TRY_RUN([
|
|
Packit Service |
c5cf8c |
int main(int argc, char **argv)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
unsigned long lock, *lock_ptr;
|
|
Packit Service |
c5cf8c |
lock_ptr = &loc;;
|
|
Packit Service |
c5cf8c |
_InterlockedExchange(lock_ptr, 1);
|
|
Packit Service |
c5cf8c |
exit(0);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
],
|
|
Packit Service |
c5cf8c |
pac_cv_have__InterlockedExchange=yes,pac_cv_have__InterlockedExchange=no)])
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if test "$pac_cv_have__InterlockedExchange" = "yes" ; then
|
|
Packit Service |
c5cf8c |
AC_DEFINE(HAVE__INTERLOCKEDEXCHANGE, 1, [Define if _InterlockedExchange intrinsic is available])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AC_CACHE_CHECK([for SPARC membar instruction with gcc],
|
|
Packit Service |
c5cf8c |
pac_cv_gcc_sparc_membar,[
|
|
Packit Service |
c5cf8c |
AC_TRY_RUN([
|
|
Packit Service |
c5cf8c |
int main(int argc, char **argv){
|
|
Packit Service |
c5cf8c |
__asm__ __volatile__ ( "membar #StoreLoad | #StoreStore" : : : "memory" );
|
|
Packit Service |
c5cf8c |
exit(0);
|
|
Packit Service |
c5cf8c |
}],pac_cv_gcc_sparc_membar=yes,pac_cv_gcc_sparc_membar=no)])
|
|
Packit Service |
c5cf8c |
if test "$pac_cv_gcc_sparc_membar" = yes ; then
|
|
Packit Service |
c5cf8c |
AC_DEFINE(HAVE_GCC_ASM_SPARC_MEMBAR,1,[Define if gcc asm membar supported])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AC_CACHE_CHECK([for SPARC membar instruction with Solaris C],
|
|
Packit Service |
c5cf8c |
pac_cv_solaris_sparc_membar,[
|
|
Packit Service |
c5cf8c |
AC_TRY_RUN([
|
|
Packit Service |
c5cf8c |
int main(int argc, char **argv){
|
|
Packit Service |
c5cf8c |
__asm ( "membar #StoreLoad | #StoreStore");
|
|
Packit Service |
c5cf8c |
exit(0);
|
|
Packit Service |
c5cf8c |
}],pac_cv_solaris_sparc_membar=yes,pac_cv_solaris_sparc_membar=no)])
|
|
Packit Service |
c5cf8c |
if test "$pac_cv_solaris_sparc_membar" = yes ; then
|
|
Packit Service |
c5cf8c |
AC_DEFINE(HAVE_SOLARIS_ASM_SPARC_MEMBAR,1,[Define if solaris asm membar supported])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AC_CACHE_CHECK([for SPARC stbar instruction with gcc],
|
|
Packit Service |
c5cf8c |
pac_cv_gcc_sparc_stbar,[
|
|
Packit Service |
c5cf8c |
AC_TRY_RUN([
|
|
Packit Service |
c5cf8c |
int main(int argc, char **argv){
|
|
Packit Service |
c5cf8c |
__asm__ __volatile__ ( "stbar" : : : "memory" );
|
|
Packit Service |
c5cf8c |
exit(0);
|
|
Packit Service |
c5cf8c |
}],pac_cv_gcc_sparc_stbar=yes,pac_cv_gcc_sparc_stbar=no)])
|
|
Packit Service |
c5cf8c |
if test "$pac_cv_gcc_sparc_stbar" = yes ; then
|
|
Packit Service |
c5cf8c |
AC_DEFINE(HAVE_GCC_ASM_SPARC_STBAR,1,[Define if gcc asm stbar supported])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
AC_CACHE_CHECK([for SPARC stbar instruction with Solaris C],
|
|
Packit Service |
c5cf8c |
pac_cv_solaris_sparc_stbar,[
|
|
Packit Service |
c5cf8c |
AC_TRY_RUN([
|
|
Packit Service |
c5cf8c |
int main(int argc, char **argv){
|
|
Packit Service |
c5cf8c |
__asm ( "stbar" );
|
|
Packit Service |
c5cf8c |
exit(0);
|
|
Packit Service |
c5cf8c |
}],pac_cv_solaris_sparc_stbar=yes,pac_cv_solaris_sparc_stbar=no)])
|
|
Packit Service |
c5cf8c |
if test "$pac_cv_solaris_sparc_stbar" = yes ; then
|
|
Packit Service |
c5cf8c |
AC_DEFINE(HAVE_SOLARIS_ASM_SPARC_STBAR,1,[Define if solaris asm stbar supported])
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
])
|