Merge pull request #1853 from lioncash/event

kernel/object: Amend handle types to distinguish between readable and writable events
This commit is contained in:
bunnei 2018-12-04 12:25:40 -05:00 committed by GitHub
commit d533767623
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 11 deletions

View file

@ -13,7 +13,7 @@ Object::~Object() = default;
bool Object::IsWaitable() const {
switch (GetHandleType()) {
case HandleType::Event:
case HandleType::ReadableEvent:
case HandleType::Thread:
case HandleType::Timer:
case HandleType::ServerPort:
@ -21,6 +21,7 @@ bool Object::IsWaitable() const {
return true;
case HandleType::Unknown:
case HandleType::WritableEvent:
case HandleType::SharedMemory:
case HandleType::Process:
case HandleType::AddressArbiter:

View file

@ -19,7 +19,8 @@ using Handle = u32;
enum class HandleType : u32 {
Unknown,
Event,
WritableEvent,
ReadableEvent,
SharedMemory,
Thread,
Process,

View file

@ -29,7 +29,7 @@ public:
return reset_type;
}
static const HandleType HANDLE_TYPE = HandleType::Event;
static const HandleType HANDLE_TYPE = HandleType::ReadableEvent;
HandleType GetHandleType() const override {
return HANDLE_TYPE;
}

View file

@ -1602,14 +1602,21 @@ static ResultCode ClearEvent(Handle handle) {
LOG_TRACE(Kernel_SVC, "called, event=0x{:08X}", handle);
const auto& handle_table = Core::CurrentProcess()->GetHandleTable();
SharedPtr<ReadableEvent> evt = handle_table.Get<ReadableEvent>(handle);
if (evt == nullptr) {
LOG_ERROR(Kernel_SVC, "Event handle does not exist, handle=0x{:08X}", handle);
return ERR_INVALID_HANDLE;
auto writable_event = handle_table.Get<WritableEvent>(handle);
if (writable_event) {
writable_event->Clear();
return RESULT_SUCCESS;
}
evt->Clear();
auto readable_event = handle_table.Get<ReadableEvent>(handle);
if (readable_event) {
readable_event->Clear();
return RESULT_SUCCESS;
}
LOG_ERROR(Kernel_SVC, "Event handle does not exist, handle=0x{:08X}", handle);
return ERR_INVALID_HANDLE;
}
static ResultCode GetProcessInfo(u64* out, Handle process_handle, u32 type) {

View file

@ -39,7 +39,7 @@ public:
return name;
}
static const HandleType HANDLE_TYPE = HandleType::Event;
static const HandleType HANDLE_TYPE = HandleType::WritableEvent;
HandleType GetHandleType() const override {
return HANDLE_TYPE;
}

View file

@ -153,7 +153,7 @@ QString WaitTreeWaitObject::GetText() const {
std::unique_ptr<WaitTreeWaitObject> WaitTreeWaitObject::make(const Kernel::WaitObject& object) {
switch (object.GetHandleType()) {
case Kernel::HandleType::Event:
case Kernel::HandleType::ReadableEvent:
return std::make_unique<WaitTreeEvent>(static_cast<const Kernel::ReadableEvent&>(object));
case Kernel::HandleType::Timer:
return std::make_unique<WaitTreeTimer>(static_cast<const Kernel::Timer&>(object));