Hi,
is there any reason why I need -latomic on SPARC and not on x86?
$ cat sync_bool.c
#include <stdio.h>
long n;
int
main(void)
{
if (!__sync_bool_compare_and_swap(&n, 0, 1)) {
fprintf(stderr, "__sync_bool_compare_and_swap() failed\n");
}
if (__sync_bool_compare_and_swap(&n, (long)0, 1)) {
fprintf(stderr, "__sync_bool_compare_and_swap() succeeded\n");
}
fprintf(stderr, "all clear\n");
}
x86 Box:
$ cc -m64 sync_bool.c
$ ./a.out
all clear
SPARC box:
$ cc -m64 sync_bool.c
Undefined first referenced
symbol in file
__atomic_compare_exchange_8 sync_bool.o
ld: fatal: symbol referencing errors
$ cc -m64 sync_bool.c -latomic
$ ./a.out
__sync_bool_compare_and_swap() failed
__sync_bool_compare_and_swap() succeeded
all clear