1//===-- mutex_posix.cpp -----------------------------------------*- C++ -*-===//
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#include "gwp_asan/mutex.h"
10
11#include <assert.h>
12#include <pthread.h>
13
14namespace gwp_asan {
15void Mutex::lock() {
16  int Status = pthread_mutex_lock(&Mu);
17  assert(Status == 0);
18  // Remove warning for non-debug builds.
19  (void)Status;
20}
21
22bool Mutex::tryLock() { return pthread_mutex_trylock(&Mu) == 0; }
23
24void Mutex::unlock() {
25  int Status = pthread_mutex_unlock(&Mu);
26  assert(Status == 0);
27  // Remove warning for non-debug builds.
28  (void)Status;
29}
30} // namespace gwp_asan
31