Skip to content

Instantly share code, notes, and snippets.

@stepancheg
Created July 24, 2013 17:32
Show Gist options
  • Save stepancheg/6072671 to your computer and use it in GitHub Desktop.
Save stepancheg/6072671 to your computer and use it in GitHub Desktop.
add.c.diff
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