[zircon] Guard general __TA_xx macros behind _LIBCPP check
We use the __TA_xxx macros to annotate code for clang's thread safety analysis features. The thread safety analysis feature works by comparing the annotations on types with the annotations on code using those types and generating a warning if the code is identified that is inconsistent with the annotations or the defined semantics of the annotations. We frequently use these annotations to describe the relationship between code and types from the C++ standard library, such as std::mutex. These types are annotated in the libc++ standard library implementation if the preprocessor define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS is set. In the Fuchsia build, we always set -Wthread-safety and -D_LIBCPP_... compiler flags together so the annotations are consistent internally. Some SDK customers use the fuchsia SDK and -Wthread-safety flag without setting the preprocessor define as they use other libraries which use the C++ standard library types in ways incompatible with thread safety analysis. This causes issues when compiling code that uses the __TA_xxx macros with types like std::mutex. This updates the __TA_xxx macros to only enable annotations if we can tell that C++ standard library types are annotated (using the _LIBCPP_... macro) or if we're in kernel code that we always control. This also updates zircon/kernel code to use the non-public macros defined in zircon/system/private so that they are enabled even when libc++ is not involved. ZX-4091 #done Change-Id: I74910f6963d79bd2a53cf5d89a183252c5b58e7e
Showing
- zircon/kernel/arch/x86/hypervisor/pvclock.cpp 2 additions, 1 deletionzircon/kernel/arch/x86/hypervisor/pvclock.cpp
- zircon/kernel/include/kernel/mutex.h 9 additions, 8 deletionszircon/kernel/include/kernel/mutex.h
- zircon/kernel/lib/heap/cmpctmalloc/include/lib/cmpctmalloc.h 10 additions, 9 deletionszircon/kernel/lib/heap/cmpctmalloc/include/lib/cmpctmalloc.h
- zircon/kernel/tests/lock_dep_tests.cpp 34 additions, 33 deletionszircon/kernel/tests/lock_dep_tests.cpp
- zircon/system/public/zircon/compiler.h 8 additions, 1 deletionzircon/system/public/zircon/compiler.h
Loading
Please register or sign in to comment