Created
July 30, 2015 13:11
-
-
Save mhaberler/76ec177206d8b5cee4b5 to your computer and use it in GitHub Desktop.
see what gcc and c++ generate for atomic builtins (NOT std::atomic)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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