2014-05-20 20:03:45 -07:00
|
|
|
// Copyright 2014 Citra Emulator Project
|
2014-12-16 21:38:14 -08:00
|
|
|
// Licensed under GPLv2 or any later version
|
2014-11-19 00:49:13 -08:00
|
|
|
// Refer to the license.txt file included.
|
2014-05-20 20:03:45 -07:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "common/common_types.h"
|
2018-08-01 19:40:00 -07:00
|
|
|
#include "core/hle/kernel/object.h"
|
2018-07-31 05:06:09 -07:00
|
|
|
|
|
|
|
union ResultCode;
|
2014-05-20 20:03:45 -07:00
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
2018-08-28 09:30:33 -07:00
|
|
|
class HandleTable;
|
2015-01-22 17:12:19 -08:00
|
|
|
class Thread;
|
|
|
|
|
2018-04-20 12:42:29 -07:00
|
|
|
class Mutex final {
|
2015-01-22 17:12:19 -08:00
|
|
|
public:
|
2018-04-20 10:01:14 -07:00
|
|
|
/// Flag that indicates that a mutex still has threads waiting for it.
|
|
|
|
static constexpr u32 MutexHasWaitersFlag = 0x40000000;
|
|
|
|
/// Mask of the bits in a mutex address value that contain the mutex owner.
|
|
|
|
static constexpr u32 MutexOwnerMask = 0xBFFFFFFF;
|
|
|
|
|
|
|
|
/// Attempts to acquire a mutex at the specified address.
|
2018-08-28 09:30:33 -07:00
|
|
|
static ResultCode TryAcquire(HandleTable& handle_table, VAddr address,
|
|
|
|
Handle holding_thread_handle, Handle requesting_thread_handle);
|
2018-04-20 10:01:14 -07:00
|
|
|
|
|
|
|
/// Releases the mutex at the specified address.
|
|
|
|
static ResultCode Release(VAddr address);
|
|
|
|
|
2015-01-22 17:12:19 -08:00
|
|
|
private:
|
2018-04-20 12:42:29 -07:00
|
|
|
Mutex() = default;
|
|
|
|
~Mutex() = default;
|
2015-01-22 17:12:19 -08:00
|
|
|
};
|
2014-05-20 20:03:45 -07:00
|
|
|
|
2018-01-01 11:02:26 -08:00
|
|
|
} // namespace Kernel
|