summaryrefslogtreecommitdiffstats
path: root/compiler-rt/test/tsan/Darwin/external-noninstrumented-module.cpp
blob: ce65970834e51a9dc7572be03276ee401e3de5e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// This file is used from other tests.
// RUN: true

#include <thread>

#include <stdio.h>
#include <stdlib.h>

struct MyObject;
typedef MyObject *MyObjectRef;
extern "C" {
  void InitializeLibrary();
  MyObject *ObjectCreate();
  long ObjectRead(MyObject *);
  void ObjectWrite(MyObject *, long);
  void ObjectWriteAnother(MyObject *, long);
}

extern "C" void NonInstrumentedModule() {
  InitializeLibrary();
  
  MyObjectRef ref = ObjectCreate();
  std::thread t1([ref]{ ObjectWrite(ref, 42); });
  std::thread t2([ref]{ ObjectWrite(ref, 43); });
  t1.join();
  t2.join();
}
OpenPOWER on IntegriCloud