Page MenuHomeFreeBSD

Make the system C11 atomics headers fully compatible with external GCC.
ClosedPublic

Authored by jhb on Aug 3 2018, 8:50 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 27 2024, 6:30 AM
Unknown Object (File)
Oct 25 2024, 12:12 AM
Unknown Object (File)
Oct 14 2024, 3:25 PM
Unknown Object (File)
Sep 27 2024, 7:04 PM
Unknown Object (File)
Sep 21 2024, 8:45 PM
Unknown Object (File)
Sep 19 2024, 3:26 PM
Unknown Object (File)
Sep 18 2024, 2:43 PM
Unknown Object (File)
Sep 4 2024, 4:49 PM
Subscribers

Details

Summary

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.

Test Plan
  • compile a simple test program using C11 atomics using different combinations:
    • gcc -c bar.c
    • gcc -std=c99 -c bar.c
    • gcc -std=c99 -nostdinc -I /usr/include -c bar.c
    • gcc -nostdinc -I /usr/include -c bar.c
  • cross-build a world using i386-xtoolchain-gcc

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 18567
Build 18262: arc lint + arc unit