Assigning __sync_sub_and_fetch() result to an unused variable can result in it being optimized away and the function support is then not really tested for, see #4542. So do make sure this variable is kept by making it volatile. Closes #15555. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74934 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
		
			
				
	
	
		
			30 lines
		
	
	
		
			942 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			942 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| 
 | |
| 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_and_add and __sync_sub_and_fetch builtins])
 | |
|     AC_CACHE_VAL(wx_cv_cc_gcc_atomic_builtins, [
 | |
|       AC_TRY_LINK(
 | |
|         [],
 | |
|         [
 | |
|           unsigned int value=0;
 | |
|           /* wxAtomicInc doesn't use return value here */
 | |
|           __sync_fetch_and_add(&value, 2);
 | |
|           __sync_sub_and_fetch(&value, 1);
 | |
|           /* but wxAtomicDec does, so mimic that: */
 | |
|           volatile unsigned int r2 = __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
 | |
| ])
 |