是否有一个网站列出了各种平台及其对 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?
发布评论
评论(2)
我不知道是否有这样的列表,但是 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.
[虽然这是一个老问题,但我认为我应该更新并完成答案]
我不知道每个架构版本和每个 gcc 版本表,描述支持的内置程序。
gcc 的 __sync 内置函数自版本 4.1 起就存在(例如,参见 gcc 4.1.2 手册。如所述:
因此,当没有针对特定体系结构的实现时,将会出现编译警告,并且我猜会出现链接时错误,除非您提供具有适当名称的所需函数。
在 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:
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