3 * Copyright 2018 gRPC authors.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 #ifndef GRPC_CORE_LIB_IOMGR_DYNAMIC_ANNOTATIONS_H
20 #define GRPC_CORE_LIB_IOMGR_DYNAMIC_ANNOTATIONS_H
22 #include <grpc/support/port_platform.h>
24 #ifdef GRPC_TSAN_ENABLED
26 #define TSAN_ANNOTATE_HAPPENS_BEFORE(addr) \
27 AnnotateHappensBefore(__FILE__, __LINE__, (void*)(addr))
28 #define TSAN_ANNOTATE_HAPPENS_AFTER(addr) \
29 AnnotateHappensAfter(__FILE__, __LINE__, (void*)(addr))
30 #define TSAN_ANNOTATE_RWLOCK_CREATE(addr) \
31 AnnotateRWLockCreate(__FILE__, __LINE__, (void*)(addr))
32 #define TSAN_ANNOTATE_RWLOCK_DESTROY(addr) \
33 AnnotateRWLockDestroy(__FILE__, __LINE__, (void*)(addr))
34 #define TSAN_ANNOTATE_RWLOCK_ACQUIRED(addr, is_w) \
35 AnnotateRWLockAcquired(__FILE__, __LINE__, (void*)(addr), (is_w))
36 #define TSAN_ANNOTATE_RWLOCK_RELEASED(addr, is_w) \
37 AnnotateRWLockReleased(__FILE__, __LINE__, (void*)(addr), (is_w))
42 void AnnotateHappensBefore(const char* file, int line, const volatile void* cv);
43 void AnnotateHappensAfter(const char* file, int line, const volatile void* cv);
44 void AnnotateRWLockCreate(const char* file, int line,
45 const volatile void* lock);
46 void AnnotateRWLockDestroy(const char* file, int line,
47 const volatile void* lock);
48 void AnnotateRWLockAcquired(const char* file, int line,
49 const volatile void* lock, long is_w);
50 void AnnotateRWLockReleased(const char* file, int line,
51 const volatile void* lock, long is_w);
56 #else /* GRPC_TSAN_ENABLED */
58 #define TSAN_ANNOTATE_HAPPENS_BEFORE(addr)
59 #define TSAN_ANNOTATE_HAPPENS_AFTER(addr)
60 #define TSAN_ANNOTATE_RWLOCK_CREATE(addr)
61 #define TSAN_ANNOTATE_RWLOCK_DESTROY(addr)
62 #define TSAN_ANNOTATE_RWLOCK_ACQUIRED(addr, is_w)
63 #define TSAN_ANNOTATE_RWLOCK_RELEASED(addr, is_w)
65 #endif /* GRPC_TSAN_ENABLED */
67 #endif /* GRPC_CORE_LIB_IOMGR_DYNAMIC_ANNOTATIONS_H */