OSDN Git Service

Undefine _Atomic before redefining
authorHans Boehm <hboehm@google.com>
Tue, 26 Aug 2014 22:58:15 +0000 (15:58 -0700)
committerHans Boehm <hboehm@google.com>
Tue, 2 Sep 2014 17:32:34 +0000 (10:32 -0700)
Stdatomic.h was potentially redefining _Atomic, in spite of a
prior definition by <atomic>.  This could cause g++ builds that
included <stdatomic.h> with an available <atomic> header to break.

A functional stdatomic.h is a prerequisite for fixing the
following bugs.  This is the middle of 3 AOSP updates to
bionics stdatomic.h that are needded to get there.

Bug:16880454
Bug:16513433

Change-Id: I562c7115118c0587d594d4d5b62d25101e47bfd8
(cherry picked from commit 3e4a0099a179d7acee63d78c8fc4c3cc7b0bae42)

libc/include/stdatomic.h

index e5420ff..47b333c 100644 (file)
 
 #include <atomic>
 
+#undef _Atomic
+        /* Also defined by <atomic> for gcc.  But not used in macros. */
+        /* Also a clang intrinsic.                                    */
+        /* Should not be used by client code before this file is      */
+        /* included.  The definitions in <atomic> themselves see      */
+        /* the old definition, as they should.                        */
+        /* Client code sees the following definition.                 */
 #define _Atomic(t) std::atomic<t>
 
 using std::atomic_is_lock_free;