Skip to content

Commit 442d36f

Browse files
Merge pull request #6529 from apple/cherrypick/spinlock
[TSAN][Darwin] Forward declare spinlock functions on darwin for TSAN …
2 parents a34ab3c + 8593e97 commit 442d36f

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

compiler-rt/lib/tsan/rtl/tsan_interceptors_mac.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "tsan_interceptors.h"
1919
#include "tsan_interface.h"
2020
#include "tsan_interface_ann.h"
21+
#include "tsan_spinlock_defs_mac.h"
2122
#include "sanitizer_common/sanitizer_addrhashmap.h"
2223

2324
#include <errno.h>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//===-- tsan_spinlock_defs_mac.h -------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file is a part of ThreadSanitizer (TSan), a race detector.
10+
//
11+
// Mac-specific forward-declared function defintions that may be
12+
// deprecated in later versions of the OS.
13+
// These are needed for interceptors.
14+
//
15+
//===----------------------------------------------------------------------===//
16+
17+
#if SANITIZER_APPLE
18+
19+
#ifndef TSAN_SPINLOCK_DEFS_MAC_H
20+
#define TSAN_SPINLOCK_DEFS_MAC_H
21+
22+
#include <stdint.h>
23+
24+
extern "C" {
25+
26+
/*
27+
Provides forward declarations related to OSSpinLocks on Darwin. These functions are
28+
deprecated on macOS version 10.12 and later,
29+
and are no longer included in the system headers.
30+
31+
However, the symbols are still available on the system, so we provide these forward
32+
declarations to prevent compilation errors in tsan_interceptors_mac.cpp, which
33+
references these functions when defining TSAN interceptor functions.
34+
*/
35+
36+
typedef int32_t OSSpinLock;
37+
38+
void OSSpinLockLock(volatile OSSpinLock *__lock);
39+
void OSSpinLockUnlock(volatile OSSpinLock *__lock);
40+
bool OSSpinLockTry(volatile OSSpinLock *__lock);
41+
42+
}
43+
44+
#endif //TSAN_SPINLOCK_DEFS_MAC_H
45+
#endif // SANITIZER_APPLE

0 commit comments

Comments
 (0)