mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
LibCore: Make MachPort build on GNU Mach
This commit is contained in:
committed by
Andrew Kaster
parent
e720eadd9e
commit
9d2d78c57c
@@ -8,6 +8,13 @@
|
||||
#include <AK/Format.h>
|
||||
#include <LibCore/MachPort.h>
|
||||
|
||||
#if defined(AK_OS_GNU_HURD)
|
||||
extern "C" {
|
||||
# include <mach_error.h>
|
||||
}
|
||||
// This is in <mach/mach_error.h> on Darwin, and doesn't seem to be required.
|
||||
#endif
|
||||
|
||||
#if defined(AK_OS_MACOS)
|
||||
# include <bootstrap.h>
|
||||
#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)
|
||||
|
||||
@@ -14,7 +14,10 @@
|
||||
|
||||
#include <AK/Error.h>
|
||||
#include <AK/Noncopyable.h>
|
||||
|
||||
extern "C" {
|
||||
#include <mach/mach.h>
|
||||
}
|
||||
|
||||
namespace Core {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user