最近看ovs的代码,发现了这个功能,看着非常有必要使用,在代码编译阶段可以帮助发现同步问题
#if __has_feature(c_thread_safety_attributes)
/* "clang" annotations for thread safety check.** OVS_LOCKABLE indicates that the struct contains mutex element* which can be locked by functions like ovs_mutex_lock().** Below, the word MUTEX stands for the name of an object with an OVS_LOCKABLE* struct type. It can also be a comma-separated list of multiple structs,* e.g. to require a function to hold multiple locks while invoked.
https://clang.llvm.org/docs/ThreadSafetyAnalysis.html