]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Make the system C11 atomics headers fully compatible with external GCC.
authorjhb <jhb@FreeBSD.org>
Mon, 6 Aug 2018 23:51:08 +0000 (23:51 +0000)
committerjhb <jhb@FreeBSD.org>
Mon, 6 Aug 2018 23:51:08 +0000 (23:51 +0000)
commitd68a6ef8aa5eaf227e67e1cad4051d2feebd3601
tree36e40e3f94c5cd0497868e30962534d2df1eab50
parent5f12c17c443e1eb9b9db837b9e4b53e9d768a420
Make the system C11 atomics headers fully compatible with external GCC.

The <sys/cdefs.h> and <stdatomic.h> headers already included support for
C11 atomics via intrinsincs in modern versions of GCC, but these versions
tried to "hide" atomic variables inside a wrapper structure.  This wrapper
is not compatible with GCC's internal <stdatomic.h> header, so that if
GCC's <stdatomic.h> was used together with <sys/cdefs.h>, use of C11
atomics would fail to compile.  Fix this by not hiding atomic variables
in a structure for modern versions of GCC.  The headers already avoid
using a wrapper structure on clang.

Note that this wrapper was only used if C11 was not enabled (e.g.
via -std=c99), so this also fixes compile failures if a modern version
of GCC was used with -std=c11 but with FreeBSD's <stdatomic.h> instead
of GCC's <stdatomic.h> and this change fixes that case as well.

Reported by: Mark Millard
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D16585
sys/sys/cdefs.h
sys/sys/stdatomic.h