view compiler-rt/test/tsan/Darwin/external-noninstrumented-module.cpp @ 266:00f31e85ec16 default tip

Added tag current for changeset 31d058e83c98
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 14 Oct 2023 10:13:55 +0900
parents 1d019706d866
children
line wrap: on
line source

// 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();
}