Reputation: 353
Is there any built-in for this operation (in C) ?
lock or QWORD [...], ...
In fact, I'm searching for lock or
in C.
If there isn't any built-in, how can I write it in C inline-asm ?
I'm using GCC (C version 11).
Upvotes: 0
Views: 94
Reputation: 126223
The standard C11 way of doing this is with <stdatomic.h> and atomic_fetch_or
. You can do things like:
#include <stdatomic.h>
atomic_int var;
int res = atomic_fetch_or(&var, 0x100);
Upvotes: 2