1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_ipc_SharedMemoryBasic_mach_h
8 #define mozilla_ipc_SharedMemoryBasic_mach_h
10 #include "base/process.h"
12 #include "mozilla/UniquePtrExtensions.h"
13 #include "mozilla/ipc/SharedMemory.h"
14 #include <mach/port.h>
17 # include "mozilla/ipc/SharedMemoryFuzzer.h"
21 // This is a low-level wrapper around platform shared memory. Don't
22 // use it directly; use Shmem allocated through IPDL interfaces.
31 class SharedMemoryBasic final
32 : public SharedMemoryCommon
<mozilla::UniqueMachSendRight
> {
36 virtual bool SetHandle(Handle aHandle
, OpenRights aRights
) override
;
38 virtual bool Create(size_t aNbytes
) override
;
40 virtual bool Map(size_t nBytes
, void* fixed_address
= nullptr) override
;
42 virtual void Unmap() override
;
44 virtual void CloseHandle() override
;
46 virtual void* memory() const override
{
48 return SharedMemoryFuzzer::MutateSharedMemory(mMemory
, mAllocSize
);
54 static Handle
NULLHandle() { return Handle(); }
56 static void* FindFreeAddressSpace(size_t aSize
);
58 virtual bool IsHandleValid(const Handle
& aHandle
) const override
;
60 virtual Handle
CloneHandle() override
;
65 mozilla::UniqueMachSendRight mPort
;
66 // Pointer to mapped region, null if unmapped.
68 // Access rights to map an existing region with.
69 OpenRights mOpenRights
;
73 } // namespace mozilla
75 #endif // ifndef mozilla_ipc_SharedMemoryBasic_mach_h