Home > front end >  C built-in or inline-asm for lock OR
C built-in or inline-asm for lock OR

Time:12-20

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).

CodePudding user response:

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);
  • Related