1/*
2 * tsan_annotations.cpp -- ThreadSanitizer annotations to support data
3 * race detection in OpenMP programs.
4 */
5
6//===----------------------------------------------------------------------===//
7//
8// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
9// See https://llvm.org/LICENSE.txt for license information.
10// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
11//
12//===----------------------------------------------------------------------===//
13
14#include "tsan_annotations.h"
15
16#include <stdio.h>
17
18typedef unsigned long uptr;
19typedef signed long sptr;
20
21extern "C" __attribute__((weak)) void AnnotateHappensBefore(const char *f,
22                                                            int l, uptr addr) {}
23extern "C" __attribute__((weak)) void AnnotateHappensAfter(const char *f, int l,
24                                                           uptr addr) {}
25extern "C" __attribute__((weak)) void AnnotateCondVarSignal(const char *f,
26                                                            int l, uptr cv) {}
27extern "C" __attribute__((weak)) void AnnotateCondVarSignalAll(const char *f,
28                                                               int l, uptr cv) {
29}
30extern "C" __attribute__((weak)) void AnnotateMutexIsNotPHB(const char *f,
31                                                            int l, uptr mu) {}
32extern "C" __attribute__((weak)) void AnnotateCondVarWait(const char *f, int l,
33                                                          uptr cv, uptr lock) {}
34extern "C" __attribute__((weak)) void AnnotateRWLockCreate(const char *f, int l,
35                                                           uptr m) {}
36extern "C" __attribute__((weak)) void
37AnnotateRWLockCreateStatic(const char *f, int l, uptr m) {}
38extern "C" __attribute__((weak)) void AnnotateRWLockDestroy(const char *f,
39                                                            int l, uptr m) {}
40extern "C" __attribute__((weak)) void
41AnnotateRWLockAcquired(const char *f, int l, uptr m, uptr is_w) {}
42extern "C" __attribute__((weak)) void
43AnnotateRWLockReleased(const char *f, int l, uptr m, uptr is_w) {}
44extern "C" __attribute__((weak)) void AnnotateTraceMemory(const char *f, int l,
45                                                          uptr mem) {}
46extern "C" __attribute__((weak)) void AnnotateFlushState(const char *f, int l) {
47}
48extern "C" __attribute__((weak)) void AnnotateNewMemory(const char *f, int l,
49                                                        uptr mem, uptr size) {}
50extern "C" __attribute__((weak)) void AnnotateNoOp(const char *f, int l,
51                                                   uptr mem) {}
52extern "C" __attribute__((weak)) void AnnotateFlushExpectedRaces(const char *f,
53                                                                 int l) {}
54extern "C" __attribute__((weak)) void
55AnnotateEnableRaceDetection(const char *f, int l, int enable) {}
56extern "C" __attribute__((weak)) void
57AnnotateMutexIsUsedAsCondVar(const char *f, int l, uptr mu) {}
58extern "C" __attribute__((weak)) void AnnotatePCQGet(const char *f, int l,
59                                                     uptr pcq) {}
60extern "C" __attribute__((weak)) void AnnotatePCQPut(const char *f, int l,
61                                                     uptr pcq) {}
62extern "C" __attribute__((weak)) void AnnotatePCQDestroy(const char *f, int l,
63                                                         uptr pcq) {}
64extern "C" __attribute__((weak)) void AnnotatePCQCreate(const char *f, int l,
65                                                        uptr pcq) {}
66extern "C" __attribute__((weak)) void AnnotateExpectRace(const char *f, int l,
67                                                         uptr mem, char *desc) {
68}
69extern "C" __attribute__((weak)) void
70AnnotateBenignRaceSized(const char *f, int l, uptr mem, uptr size, char *desc) {
71}
72extern "C" __attribute__((weak)) void AnnotateBenignRace(const char *f, int l,
73                                                         uptr mem, char *desc) {
74}
75extern "C" __attribute__((weak)) void AnnotateIgnoreReadsBegin(const char *f,
76                                                               int l) {}
77extern "C" __attribute__((weak)) void AnnotateIgnoreReadsEnd(const char *f,
78                                                             int l) {}
79extern "C" __attribute__((weak)) void AnnotateIgnoreWritesBegin(const char *f,
80                                                                int l) {}
81extern "C" __attribute__((weak)) void AnnotateIgnoreWritesEnd(const char *f,
82                                                              int l) {}
83extern "C" __attribute__((weak)) void AnnotateIgnoreSyncBegin(const char *f,
84                                                              int l) {}
85extern "C" __attribute__((weak)) void AnnotateIgnoreSyncEnd(const char *f,
86                                                            int l) {}
87extern "C" __attribute__((weak)) void
88AnnotatePublishMemoryRange(const char *f, int l, uptr addr, uptr size) {}
89extern "C" __attribute__((weak)) void
90AnnotateUnpublishMemoryRange(const char *f, int l, uptr addr, uptr size) {}
91extern "C" __attribute__((weak)) void AnnotateThreadName(const char *f, int l,
92                                                         char *name) {}
93extern "C" __attribute__((weak)) void
94WTFAnnotateHappensBefore(const char *f, int l, uptr addr) {}
95extern "C" __attribute__((weak)) void
96WTFAnnotateHappensAfter(const char *f, int l, uptr addr) {}
97extern "C" __attribute__((weak)) void
98WTFAnnotateBenignRaceSized(const char *f, int l, uptr mem, uptr sz,
99                           char *desc) {}
100extern "C" __attribute__((weak)) int RunningOnValgrind() { return 0; }
101extern "C" __attribute__((weak)) double ValgrindSlowdown(void) { return 0; }
102extern "C" __attribute__((weak)) const char __attribute__((weak)) *
103    ThreadSanitizerQuery(const char *query) {
104  return 0;
105}
106extern "C" __attribute__((weak)) void
107AnnotateMemoryIsInitialized(const char *f, int l, uptr mem, uptr sz) {}
108