开发者

Equivalent of InterlockedIncrement in Linux/gcc

开发者 https://www.devze.com 2022-12-17 03:54 出处:网络
It would be a very simple question (could be duplicated), but I was unable to find it. Win32 API provides a very开发者_StackOverflow handy set of atomic operations (as intrinsics) such as Interlocked

It would be a very simple question (could be duplicated), but I was unable to find it.

Win32 API provides a very开发者_StackOverflow handy set of atomic operations (as intrinsics) such as InterlockedIncrement which emits lock add x86 code. Also, InterlockedCompareExchange is mapped to lock cmpxchg.

But, I want to do that in Linux with gcc. Since I'm working 64-bit, it's impossible to use inline assembly. Are there intrinsics for gcc?


GCC Atomic Built-ins

0

精彩评论

暂无评论...
验证码 换一张
取 消