Skip to content

[TSAN][Darwin] Forward declare spinlock functions on darwin for TSAN … #6529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler-rt/lib/tsan/rtl/tsan_interceptors_mac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "tsan_interceptors.h"
#include "tsan_interface.h"
#include "tsan_interface_ann.h"
#include "tsan_spinlock_defs_mac.h"
#include "sanitizer_common/sanitizer_addrhashmap.h"

#include <errno.h>
Expand Down
45 changes: 45 additions & 0 deletions compiler-rt/lib/tsan/rtl/tsan_spinlock_defs_mac.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//===-- tsan_spinlock_defs_mac.h -------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file is a part of ThreadSanitizer (TSan), a race detector.
//
// Mac-specific forward-declared function defintions that may be
// deprecated in later versions of the OS.
// These are needed for interceptors.
//
//===----------------------------------------------------------------------===//

#if SANITIZER_APPLE

#ifndef TSAN_SPINLOCK_DEFS_MAC_H
#define TSAN_SPINLOCK_DEFS_MAC_H

#include <stdint.h>

extern "C" {

/*
Provides forward declarations related to OSSpinLocks on Darwin. These functions are
deprecated on macOS version 10.12 and later,
and are no longer included in the system headers.

However, the symbols are still available on the system, so we provide these forward
declarations to prevent compilation errors in tsan_interceptors_mac.cpp, which
references these functions when defining TSAN interceptor functions.
*/

typedef int32_t OSSpinLock;

void OSSpinLockLock(volatile OSSpinLock *__lock);
void OSSpinLockUnlock(volatile OSSpinLock *__lock);
bool OSSpinLockTry(volatile OSSpinLock *__lock);

}

#endif //TSAN_SPINLOCK_DEFS_MAC_H
#endif // SANITIZER_APPLE