Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get `gcc` to generate `bts` instruction for x86-64 from standard C?
    primarykey
    data
    text
    <p>Inspired by a <a href="https://stackoverflow.com/questions/2039592/effectiveness-of-gcc-optmization-on-bit-operations">recent question</a>, I'd like to know if anyone knows how to get <code>gcc</code> to generate the x86-64 <code>bts</code> instruction (bit test and set) on the Linux x86-64 platforms, <em>without</em> resorting to inline assembly or to nonstandard compiler intrinsics.</p> <p>Related questions:</p> <ul> <li><p><a href="https://stackoverflow.com/questions/2039592/effectiveness-of-gcc-optmization-on-bit-operations">Why doesn't gcc do this for a simple <code>|=</code> operation were the right-hand side has exactly 1 bit set?</a></p></li> <li><p><a href="https://stackoverflow.com/questions/1983303/using-bts-assembly-instruction-with-gcc-compiler">How to get <code>bts</code> using compiler intrinsics or the <code>asm</code> directive</a></p></li> </ul> <p>Portability is more important to me than <code>bts</code>, so I won't use and <code>asm</code> directive, and if there's another solution, I prefer not to use compiler instrinsics.</p> <p><strong>EDIT</strong>: The C source language does not support atomic operations, so I'm not particularly interested in getting <em>atomic</em> test-and-set (even though that's the original reason for test-and-set to exist in the first place). If I want something atomic I know I have no chance of doing it with standard C source: it has to be an intrinsic, a library function, or inline assembly. (I have implemented atomic operations in compilers that support multiple threads.)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload