1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-26 21:57:41 +03:00

Fix CHECK_CODE usage in atomics builtin detection

CHECK_CODE already wraps the code with main().  Adding another layer
results in a nested function, eg

  int main(void) { int main(void) { __sync_fetch_and_add(); } }

Since the inner function isn't called it is optimized out at cc -O2,
thus the linker doesn't fail if __sync_fetch_and_add() isn't available.

Issue noticed on OpenBSD/hppa.

Signed-off-by: Jérémie Courrèges-Anglas <jca@wxcvbn.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Apr 26 01:19:40 CEST 2016 on sn-devel-144
This commit is contained in:
Jérémie Courrèges-Anglas 2016-04-25 16:10:03 +02:00 committed by Jeremy Allison
parent ad5a4a9e36
commit 53e0860122

View File

@ -202,23 +202,15 @@ def configure(conf):
# Check for atomic builtins. */
conf.CHECK_CODE('''
int main(void) {
int i;
(void)__sync_fetch_and_add(&i, 1);
return 0;
}
int i;
(void)__sync_fetch_and_add(&i, 1);
''',
'HAVE___SYNC_FETCH_AND_ADD',
msg='Checking for __sync_fetch_and_add compiler builtin')
conf.CHECK_CODE('''
#include <stdint.h>
#include <sys/atomic.h>
int main(void) {
int32_t i;
atomic_add_32(&i, 1);
return 0;
}
int32_t i;
atomic_add_32(&i, 1);
''',
'HAVE_ATOMIC_ADD_32',
headers='stdint.h sys/atomic.h',