Skip to content

Instantly share code, notes, and snippets.

@ADKaster
Created April 4, 2024 14:36
Show Gist options
  • Save ADKaster/9744a6f9d43b2e885693f4c1e64deeaf to your computer and use it in GitHub Desktop.
Save ADKaster/9744a6f9d43b2e885693f4c1e64deeaf to your computer and use it in GitHub Desktop.
/*
* Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Platform.h>
#ifndef AK_OS_MACH
# error "MachPort is only available on Mach platforms"
#endif
#include <AK/Noncopyable.h>
#include <AK/Error.h>
#include <mach/mach.h>
namespace Core {
class MachPort {
AK_MAKE_NONCOPYABLE(MachPort);
AK_MAKE_DEFAULT_MOVABLE(MachPort);
public:
enum class Right {
Send,
Receive,
SendOnce,
PortSet,
DeadName,
};
MachPort() = default;
~MachPort();
static ErrorOr<MachPort> create_with_right(Right);
ErrorOr<void> insert_right(Right);
ErrorOr<void> register_with_bootstrap(StringView service_name);
// FIXME: mach_send wrapper?
private:
mach_port_t m_port { MACH_PORT_NULL };
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment