HelloMachine
HelloMachine

Reputation: 353

C built-in or inline-asm for lock OR

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

Answers (1)

Chris Dodd
Chris Dodd

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

Related Questions