Skip to content

Instantly share code, notes, and snippets.

@mhaberler
Created July 30, 2015 13:11
Show Gist options
  • Save mhaberler/76ec177206d8b5cee4b5 to your computer and use it in GitHub Desktop.
Save mhaberler/76ec177206d8b5cee4b5 to your computer and use it in GitHub Desktop.
see what gcc and c++ generate for atomic builtins (NOT std::atomic)
#include <stdio.h>
// gcc -x c++ -std=c++11 -Wa,-adhln -g atomic.c > atomic.s
// gcc -std=c11 -Wa,-adhln -g atomic.c > atomic.s
int main(int argc, char **argv) {
int foo = 0;
int bar= 4711;
printf("foo is: %d\n", foo);
__atomic_store(&foo, &bar,__ATOMIC_SEQ_CST);
printf("foo now: %d\n", foo);
return 0;
}
all: atomic-c++.s atomic-c.s atomic-c++ atomic-c
clean:
rm -f atomic-c++.s atomic-c.s atomic-c++ atomic-c
atomic-c++.s: atomic.c
gcc -x c++ -std=c++11 -Wa,-adhln -g $^ > $@
atomic-c++: atomic.c
gcc -x c++ -std=c++11 -g $^ -o $@
atomic-c.s: atomic.c
gcc -x c -std=c11 -Wa,-adhln -g $^ > $@
atomic-c: atomic.c
gcc -x c -std=c11 $^ -o $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment