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
# 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',