Fixed wxAtomicInc/Dec() to not use asm/atomic.h header on Linux - it's kernel internal, not available for userspace in newer kernel versions and broken for userspace on some platforms. Use GCC's builtins instead.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48640 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
1
aclocal.m4
vendored
1
aclocal.m4
vendored
@@ -12,6 +12,7 @@
|
|||||||
# PARTICULAR PURPOSE.
|
# PARTICULAR PURPOSE.
|
||||||
|
|
||||||
m4_include([build/aclocal/ac_raf_func_which_getservbyname_r.m4])
|
m4_include([build/aclocal/ac_raf_func_which_getservbyname_r.m4])
|
||||||
|
m4_include([build/aclocal/atomic_builtins.m4])
|
||||||
m4_include([build/aclocal/ax_func_which_gethostbyname_r.m4])
|
m4_include([build/aclocal/ax_func_which_gethostbyname_r.m4])
|
||||||
m4_include([build/aclocal/bakefile-dllar.m4])
|
m4_include([build/aclocal/bakefile-dllar.m4])
|
||||||
m4_include([build/aclocal/bakefile-lang.m4])
|
m4_include([build/aclocal/bakefile-lang.m4])
|
||||||
|
26
build/aclocal/atomic_builtins.m4
Normal file
26
build/aclocal/atomic_builtins.m4
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
dnl Checks for availability of GCC's atomic operations builtins.
|
||||||
|
dnl Defines HAVE_GCC_ATOMIC_BUILTINS if available.
|
||||||
|
|
||||||
|
AC_DEFUN([WX_ATOMIC_BUILTINS],
|
||||||
|
[
|
||||||
|
AC_REQUIRE([AC_PROG_CC])
|
||||||
|
if test -n "$GCC"; then
|
||||||
|
AC_MSG_CHECKING([for __sync_fetch_* builtins])
|
||||||
|
AC_CACHE_VAL(wx_cv_cc_gcc_atomic_builtins, [
|
||||||
|
AC_TRY_COMPILE(
|
||||||
|
[],
|
||||||
|
[
|
||||||
|
int value=0;
|
||||||
|
__sync_fetch_and_add(&value, 1);
|
||||||
|
__sync_sub_and_fetch(&value, 1);
|
||||||
|
],
|
||||||
|
wx_cv_cc_gcc_atomic_builtins=yes,
|
||||||
|
wx_cv_cc_gcc_atomic_builtins=no)
|
||||||
|
])
|
||||||
|
AC_MSG_RESULT([$wx_cv_cc_gcc_atomic_builtins])
|
||||||
|
if test $wx_cv_cc_gcc_atomic_builtins = yes; then
|
||||||
|
AC_DEFINE([HAVE_GCC_ATOMIC_BUILTINS])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
])
|
@@ -1987,6 +1987,9 @@ if test "$wxUSE_STL" = "yes"; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
dnl check for atomic operations builtins for wx/atomic.h:
|
||||||
|
WX_ATOMIC_BUILTINS
|
||||||
|
|
||||||
dnl pop C++
|
dnl pop C++
|
||||||
AC_LANG_POP()
|
AC_LANG_POP()
|
||||||
|
|
||||||
|
@@ -25,7 +25,25 @@
|
|||||||
|
|
||||||
#if wxUSE_THREADS
|
#if wxUSE_THREADS
|
||||||
|
|
||||||
#if defined(__WXMSW__)
|
#if defined(HAVE_GCC_ATOMIC_BUILTINS)
|
||||||
|
|
||||||
|
// NB: we intentionally don't use Linux's asm/atomic.h header, because it's
|
||||||
|
// an internal kernel header that doesn't always work in userspace:
|
||||||
|
// http://bugs.mysql.com/bug.php?id=28456
|
||||||
|
// http://golubenco.org/blog/atomic-operations/
|
||||||
|
|
||||||
|
inline void wxAtomicInc (wxUint32 &value)
|
||||||
|
{
|
||||||
|
__sync_fetch_and_add(&value, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline wxUint32 wxAtomicDec (wxUint32 &value)
|
||||||
|
{
|
||||||
|
return __sync_sub_and_fetch(&value, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#elif defined(__WXMSW__)
|
||||||
|
|
||||||
// include standard Windows headers
|
// include standard Windows headers
|
||||||
#include "wx/msw/wrapwin.h"
|
#include "wx/msw/wrapwin.h"
|
||||||
@@ -53,20 +71,6 @@ inline wxUint32 wxAtomicDec (wxUint32 &value)
|
|||||||
return OSAtomicDecrement32 ((int32_t*)&value);
|
return OSAtomicDecrement32 ((int32_t*)&value);
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(__LINUX__)
|
|
||||||
|
|
||||||
#include <asm/atomic.h>
|
|
||||||
|
|
||||||
inline void wxAtomicInc (wxUint32 &value)
|
|
||||||
{
|
|
||||||
atomic_inc ((atomic_t*)&value);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline wxUint32 wxAtomicDec (wxUint32 &value)
|
|
||||||
{
|
|
||||||
return atomic_dec_and_test ((atomic_t*)&value) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined (__SOLARIS__)
|
#elif defined (__SOLARIS__)
|
||||||
|
|
||||||
#include <atomic.h>
|
#include <atomic.h>
|
||||||
|
@@ -675,6 +675,11 @@
|
|||||||
*/
|
*/
|
||||||
#undef HAVE_VISIBILITY
|
#undef HAVE_VISIBILITY
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define if the compiler supports GCC's atomic memory access builtins
|
||||||
|
*/
|
||||||
|
#undef HAVE_GCC_ATOMIC_BUILTINS
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Define if compiler's visibility support in libstdc++ is broken
|
* Define if compiler's visibility support in libstdc++ is broken
|
||||||
*/
|
*/
|
||||||
|
@@ -674,6 +674,11 @@ typedef pid_t GPid;
|
|||||||
*/
|
*/
|
||||||
#undef HAVE_VISIBILITY
|
#undef HAVE_VISIBILITY
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define if the compiler supports GCC's atomic memory access builtins
|
||||||
|
*/
|
||||||
|
#undef HAVE_GCC_ATOMIC_BUILTINS
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The built-in regex supports advanced REs in additional to POSIX's basic
|
* The built-in regex supports advanced REs in additional to POSIX's basic
|
||||||
* and extended. Your system regex probably won't support this, and in this
|
* and extended. Your system regex probably won't support this, and in this
|
||||||
|
Reference in New Issue
Block a user