在Linux中InterlockedIncrement的当量/ GCC [英] Equivalent of InterlockedIncrement in Linux/gcc

查看:866
本文介绍了在Linux中InterlockedIncrement的当量/ GCC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这将是一个很简单的问题(可复制),但我无法找到它。

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

的Win32 API提供了一个非常方便的一套原子操作(如内部函数),如 InterlockedIncrement 发射锁定添加 86 code。此外, InterlockedCompareExchange 映射到锁定CMPXCHG

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

不过,我想这样做,在Linux下使用gcc。由于我工作的64位,这是不可能使用内联汇编。是否有内在的GCC?

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原子内置插件

这篇关于在Linux中InterlockedIncrement的当量/ GCC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆