Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Studio 12.6; Why do I need -latomic for __sync_bool_compare_and_swap on SPARC?

RaiderOfTheLostSPARCAug 21 2017 — edited Aug 28 2017

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

This post has been answered by Peter.Damron-Oracle on Aug 23 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 20 2017
Added on Aug 21 2017
4 comments
822 views