Thread overview
Atomic bit operations
Dec 10, 2018
Crayo List
Dec 11, 2018
Adam D. Ruppe
Dec 11, 2018
Crayo List
December 10, 2018
Are there atomic equivalents of bt(), btc(), bts(), btr() ... etc from core.bitop?

Thanks
December 11, 2018
On Monday, 10 December 2018 at 23:20:22 UTC, Crayo List wrote:
> Are there atomic equivalents of bt(), btc(), bts(), btr() ... etc from core.bitop?

Those are intrinsics that compile into a single cpu instruction, so they are probably already atomic...
December 11, 2018
On Tuesday, 11 December 2018 at 01:37:25 UTC, Adam D. Ruppe wrote:
> On Monday, 10 December 2018 at 23:20:22 UTC, Crayo List wrote:
>> Are there atomic equivalents of bt(), btc(), bts(), btr() ... etc from core.bitop?
>
> Those are intrinsics that compile into a single cpu instruction, so they are probably already atomic...

Thanks Adam,

They need to be prefixed with 'lock' (on x86) in order to be atomic.
That's what _interlockedbittestandset() on Windows does.
And what this page says; https://www.felixcloutier.com/x86/LOCK.html

It may be possible to implement using asm { }, but I was wondering if there wasn't something out there already doing it.