Created
July 24, 2013 17:32
-
-
Save stepancheg/6072671 to your computer and use it in GitHub Desktop.
add.c.diff
This file contains hidden or 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
diff --git a/add/add.c b/add/add.c | |
index 48f7b17..0d6370c 100644 | |
--- a/add/add.c | |
+++ b/add/add.c | |
@@ -16,6 +16,9 @@ long long microseconds() { | |
#error define USE_ATOMIC 1 or 0 | |
#endif | |
+long x = 1; | |
+long* y = &x; | |
+ | |
static inline long add(long* a, long b) { | |
__asm__ __volatile__( | |
#if USE_ATOMIC | |
@@ -25,6 +28,11 @@ static inline long add(long* a, long b) { | |
: "+r" (b), "+m" (a) | |
: | |
: "memory"); | |
+ __asm__ __volatile__( | |
+ "xadd %0, %1" | |
+ : "+r" (x), "+m" (y) | |
+ : | |
+ : "memory"); | |
return *a + b; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment