Files
tubestation/ipc/glue/SharedMemoryImpl_mach.h
Sandor Molnar abe7f841ca Backed out 4 changesets (bug 1454816) for causing build bustages. CLOSED TREE
Backed out changeset 3e8d2c47138c (bug 1454816)
Backed out changeset 80ff20241831 (bug 1454816)
Backed out changeset 28c2d6d2a683 (bug 1454816)
Backed out changeset 236943ab4142 (bug 1454816)
2024-10-21 20:15:13 +03:00

57 lines
1.4 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_ipc_SharedMemoryImpl_mach_h
#define mozilla_ipc_SharedMemoryImpl_mach_h
#include "mozilla/UniquePtrExtensions.h"
#include <mach/port.h>
namespace {
enum Rights { RightsNone = 0, RightsRead = 1 << 0, RightsWrite = 1 << 1 };
} // namespace
namespace mozilla::ipc {
class SharedMemoryImpl {
public:
using Handle = mozilla::UniqueMachSendRight;
enum OpenRights {
RightsReadOnly = RightsRead,
RightsReadWrite = RightsRead | RightsWrite,
};
Handle CloneHandle();
Handle TakeHandle();
bool IsHandleValid(const Handle& aHandle) const;
bool SetHandle(Handle aHandle, OpenRights aRights);
static Handle NULLHandle();
static void* FindFreeAddressSpace(size_t size);
protected:
SharedMemoryImpl();
~SharedMemoryImpl() {}
bool CreateImpl(size_t size);
bool MapImpl(size_t nBytes, void* fixedAddress);
void UnmapImpl(size_t mappedSize);
void* MemoryImpl() const;
private:
mozilla::UniqueMachSendRight mPort;
// Pointer to mapped region, null if unmapped.
void* mMemory;
// Access rights to map an existing region with.
OpenRights mOpenRights;
};
} // namespace mozilla::ipc
#endif