Mitch expressed a preference to not have `#ifdef`s in platform agnostic code, this change tries to accomodate this. I am not attached to the method this CL proposes, so if anyone has a suggestion, I am open. We move the platform specific member of the mutex into its own platform specific class that the main `Mutex` class inherits from. Functions are implemented in their respective platform specific compilation units. For Fuchsia, we use the sync APIs, as those are also the ones being used in Scudo. Differential Revision: https://reviews.llvm.org/D90351
22 lines
731 B
C++
22 lines
731 B
C++
//===-- mutex_fuchsia.cpp ---------------------------------------*- C++ -*-===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "gwp_asan/mutex.h"
|
|
|
|
#include <lib/sync/mutex.h>
|
|
|
|
namespace gwp_asan {
|
|
void Mutex::lock() __TA_NO_THREAD_SAFETY_ANALYSIS { sync_mutex_lock(&Mu); }
|
|
|
|
bool Mutex::tryLock() __TA_NO_THREAD_SAFETY_ANALYSIS {
|
|
return sync_mutex_trylock(&Mu) == ZX_OK;
|
|
}
|
|
|
|
void Mutex::unlock() __TA_NO_THREAD_SAFETY_ANALYSIS { sync_mutex_unlock(&Mu); }
|
|
} // namespace gwp_asan
|