tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

tsan_mutex_interface.h (2521B)


      1 // Copyright 2017 The Abseil Authors.
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of the License at
      6 //
      7 //      https://www.apache.org/licenses/LICENSE-2.0
      8 //
      9 // Unless required by applicable law or agreed to in writing, software
     10 // distributed under the License is distributed on an "AS IS" BASIS,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 //
     15 // This file is intended solely for spinlock.h.
     16 // It provides ThreadSanitizer annotations for custom mutexes.
     17 // See <sanitizer/tsan_interface.h> for meaning of these annotations.
     18 
     19 #ifndef ABSL_BASE_INTERNAL_TSAN_MUTEX_INTERFACE_H_
     20 #define ABSL_BASE_INTERNAL_TSAN_MUTEX_INTERFACE_H_
     21 
     22 #include "absl/base/config.h"
     23 
     24 // ABSL_INTERNAL_HAVE_TSAN_INTERFACE
     25 // Macro intended only for internal use.
     26 //
     27 // Checks whether LLVM Thread Sanitizer interfaces are available.
     28 // First made available in LLVM 5.0 (Sep 2017).
     29 #ifdef ABSL_INTERNAL_HAVE_TSAN_INTERFACE
     30 #error "ABSL_INTERNAL_HAVE_TSAN_INTERFACE cannot be directly set."
     31 #endif
     32 
     33 #if defined(ABSL_HAVE_THREAD_SANITIZER) && defined(__has_include)
     34 #if __has_include(<sanitizer/tsan_interface.h>)
     35 #define ABSL_INTERNAL_HAVE_TSAN_INTERFACE 1
     36 #endif
     37 #endif
     38 
     39 #ifdef ABSL_INTERNAL_HAVE_TSAN_INTERFACE
     40 #include <sanitizer/tsan_interface.h>
     41 
     42 #define ABSL_TSAN_MUTEX_CREATE __tsan_mutex_create
     43 #define ABSL_TSAN_MUTEX_DESTROY __tsan_mutex_destroy
     44 #define ABSL_TSAN_MUTEX_PRE_LOCK __tsan_mutex_pre_lock
     45 #define ABSL_TSAN_MUTEX_POST_LOCK __tsan_mutex_post_lock
     46 #define ABSL_TSAN_MUTEX_PRE_UNLOCK __tsan_mutex_pre_unlock
     47 #define ABSL_TSAN_MUTEX_POST_UNLOCK __tsan_mutex_post_unlock
     48 #define ABSL_TSAN_MUTEX_PRE_SIGNAL __tsan_mutex_pre_signal
     49 #define ABSL_TSAN_MUTEX_POST_SIGNAL __tsan_mutex_post_signal
     50 #define ABSL_TSAN_MUTEX_PRE_DIVERT __tsan_mutex_pre_divert
     51 #define ABSL_TSAN_MUTEX_POST_DIVERT __tsan_mutex_post_divert
     52 
     53 #else
     54 
     55 #define ABSL_TSAN_MUTEX_CREATE(...)
     56 #define ABSL_TSAN_MUTEX_DESTROY(...)
     57 #define ABSL_TSAN_MUTEX_PRE_LOCK(...)
     58 #define ABSL_TSAN_MUTEX_POST_LOCK(...)
     59 #define ABSL_TSAN_MUTEX_PRE_UNLOCK(...)
     60 #define ABSL_TSAN_MUTEX_POST_UNLOCK(...)
     61 #define ABSL_TSAN_MUTEX_PRE_SIGNAL(...)
     62 #define ABSL_TSAN_MUTEX_POST_SIGNAL(...)
     63 #define ABSL_TSAN_MUTEX_PRE_DIVERT(...)
     64 #define ABSL_TSAN_MUTEX_POST_DIVERT(...)
     65 
     66 #endif
     67 
     68 #endif  // ABSL_BASE_INTERNAL_TSAN_MUTEX_INTERFACE_H_