Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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 ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I’m using GCC (C version 11).

>Solution :

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);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading