From 9d2d78c57cf9ad1f274010d52c385d90d24871e2 Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Wed, 24 Apr 2024 17:06:29 +0300 Subject: [PATCH] LibCore: Make MachPort build on GNU Mach --- Userland/Libraries/LibCore/MachPort.cpp | 21 ++++++++++++++++++--- Userland/Libraries/LibCore/MachPort.h | 3 +++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibCore/MachPort.cpp b/Userland/Libraries/LibCore/MachPort.cpp index a221f8f79a3..e060848b8d8 100644 --- a/Userland/Libraries/LibCore/MachPort.cpp +++ b/Userland/Libraries/LibCore/MachPort.cpp @@ -8,6 +8,13 @@ #include #include +#if defined(AK_OS_GNU_HURD) +extern "C" { +# include +} +// This is in on Darwin, and doesn't seem to be required. +#endif + #if defined(AK_OS_MACOS) # include #endif @@ -18,18 +25,24 @@ static constexpr MachPort::PortRight associated_port_right(MachPort::MessageRigh { switch (right) { case MachPort::MessageRight::MoveReceive: - case MachPort::MessageRight::CopyReceive: - case MachPort::MessageRight::DisposeReceive: return MachPort::PortRight::Receive; case MachPort::MessageRight::MoveSend: case MachPort::MessageRight::CopySend: case MachPort::MessageRight::MakeSend: - case MachPort::MessageRight::DisposeSend: return MachPort::PortRight::Send; case MachPort::MessageRight::MoveSendOnce: case MachPort::MessageRight::MakeSendOnce: + return MachPort::PortRight::SendOnce; + +#if defined(AK_OS_MACOS) + case MachPort::MessageRight::CopyReceive: + case MachPort::MessageRight::DisposeReceive: + return MachPort::PortRight::Receive; + case MachPort::MessageRight::DisposeSend: + return MachPort::PortRight::Send; case MachPort::MessageRight::DisposeSendOnce: return MachPort::PortRight::SendOnce; +#endif } VERIFY_NOT_REACHED(); } @@ -41,12 +54,14 @@ Error mach_error_to_error(kern_return_t error) return Error::from_string_view(err_view); } +#if defined(AK_OS_MACOS) static Error bootstrap_error_to_error(kern_return_t error) { char const* err_string = bootstrap_strerror(error); StringView const err_view(err_string, strlen(err_string)); return Error::from_string_view(err_view); } +#endif MachPort::MachPort(PortRight right, mach_port_t port) : m_right(right) diff --git a/Userland/Libraries/LibCore/MachPort.h b/Userland/Libraries/LibCore/MachPort.h index e4209fe4d09..bd435f0b7b9 100644 --- a/Userland/Libraries/LibCore/MachPort.h +++ b/Userland/Libraries/LibCore/MachPort.h @@ -14,7 +14,10 @@ #include #include + +extern "C" { #include +} namespace Core {