Skip to content

Instantly share code, notes, and snippets.

@Alcaro
Created August 26, 2016 12:46
Show Gist options
  • Save Alcaro/362082e3e8b3edb42a43c8d4c7aa2a3d to your computer and use it in GitHub Desktop.
Save Alcaro/362082e3e8b3edb42a43c8d4c7aa2a3d to your computer and use it in GitHub Desktop.
Compiled with https://gcc.godbolt.org/ ARM gcc 4.8.2, flags -Os
void g(volatile int* p, volatile int* q)
{
*p=0;
*q=0;
}
void h(int* p, int* q)
{
*p=0;
*q=0;
}
void i(int* p, int* q)
{
__atomic_store_n(p, 0, __ATOMIC_RELEASE);
__atomic_store_n(q, 0, __ATOMIC_RELEASE);
}
g(int volatile*, int volatile*):
movs r3, #0
str r3, [r0]
str r3, [r1]
bx lr
h(int*, int*):
movs r3, #0
str r3, [r0]
str r3, [r1]
bx lr
i(int*, int*):
dmb ish
movs r3, #0
str r3, [r0]
dmb ish
str r3, [r1]
bx lr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment