GCC 原子内置函数:是否有一个列表显示哪些平台支持哪些函数?

发布于 2024-12-10 21:07:32 字数 203 浏览 4 评论 0 原文

是否有一个网站列出了各种平台及其对 GCC 原子内置函数、各种 GCC 版本的支持?

编辑:

更清楚地说: GCC 添加 _sync... 作为其支持的平台上的内在函数。在所有其他平台上,它将它们保留为普通函数声明,但不提供实现。这必须通过某种框架来完成。

所以问题是:GCC 为哪些平台提供哪些内在函数而不需要添加函数实现?

Is there a site listing the various platforms and their support for GCC's atomic built-ins, for the various GCC versions?

EDIT:

To be more clear:
GCC adds _sync... as intrinsics on platforms it contains support for. On all other platforms it keeps those as normal functions declarations but does not supply an implementation. This must be done by some framework.

So the question is: For which platforms does GCC supply which intrinsics without need to add a function implementation?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

摘星┃星的人 2024-12-17 21:07:32

我不知道是否有这样的列表,但是 http://gcc.gnu.org/projects /cxx0x.html 表示自 GCC 4.4 起就支持原子。

GCC libstdc++ 实现了在内置函数 `__sync_fetch_and_add' 和朋友之上 ( http ://gcc.gnu.org/onlinedocs/gcc-4.6.1/gcc/Atomic-Builtins.html)。

这些函数可以使用目标机器描述中的机器特定扩展器(通常在名为“sync.md”的文件中)进行扩展,或者在缺少此类扩展器的情况下使用 CAS 循环。如果“sync.md”文件的存在表明了适当的原子支持,那么您可以考虑 MIPS、i386、ARM、BlackFin、Alpha、PowerPC、IA64 和 Sparc。

I'm not aware if there's such a list, however http://gcc.gnu.org/projects/cxx0x.html says atomics are supported since GCC 4.4.

GCC libstdc++ implements <atomic> on top of the builtin functions `__sync_fetch_and_add' and friends ( http://gcc.gnu.org/onlinedocs/gcc-4.6.1/gcc/Atomic-Builtins.html ).

These functions are expanded either using machine specific expanders in the machine description of the target (usually in a file named `sync.md') or, lacking such expanders, using a CAS loop. If the presense of `sync.md' file is any indication for a proper atomics support, then you can count in MIPS, i386, ARM, BlackFin, Alpha, PowerPC, IA64 and Sparc.

唔猫 2024-12-17 21:07:32

[虽然这是一个老问题,但我认为我应该更新并完成答案]

我不知道每个架构版本和每个 gcc 版本表,描述支持的内置程序。

gcc 的 __sync 内置函数自版本 4.1 起就存在(例如,参见 gcc 4.1.2 手册。如所述:

并非所有目标处理器都支持所有操作。如果无法在目标处理器上执行特定操作,则会生成警告并生成外部函数调用。外部函数将具有与内置函数相同的名称,并带有附加后缀“_n”,其中 n 是数据类型的大小。

因此,当没有针对特定体系结构的实现时,将会出现编译警告,并且我猜会出现链接时错误,除非您提供具有适当名称的所需函数。

在 gcc 4.7 之后,还有 __atomic 内置函数,并且 __sync 内置函数已被弃用。
例如,请在此处了解 Fedora 如何使用 gcc __sync 和 __atomic

[Though this is an old question, I thought I should update and complete the answer]

I am not aware of a per-architecture-version and per-gcc-version table, describing supported built-ins.

The __sync built-in functions of gcc exist since version 4.1 (see, e.g., gcc 4.1.2 manual. As stated there:

Not all operations are supported by all target processors. If a particular operation cannot be implemented on the target processor, a warning will be generated and a call an external function will be generated. The external function will carry the same name as the builtin, with an additional suffix `_n' where n is the size of the data type.

So, when there is not an implementation for a specific architecture, a compilation warning will appear and, I guess, a link-time error, unless you provide the required function with the appropriate name.

After gcc 4.7 there are also __atomic built-ins and __sync built-ins are deprecated.
For example, see how Fedora uses gcc __sync and __atomic here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文