michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * vim: sw=2 ts=8 et : michael@0: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include // mprotect michael@0: #include // sysconf michael@0: michael@0: #include "mozilla/ipc/SharedMemory.h" michael@0: michael@0: namespace mozilla { michael@0: namespace ipc { michael@0: michael@0: void michael@0: SharedMemory::SystemProtect(char* aAddr, size_t aSize, int aRights) michael@0: { michael@0: int flags = 0; michael@0: if (aRights & RightsRead) michael@0: flags |= PROT_READ; michael@0: if (aRights & RightsWrite) michael@0: flags |= PROT_WRITE; michael@0: if (RightsNone == aRights) michael@0: flags = PROT_NONE; michael@0: michael@0: if (0 < mprotect(aAddr, aSize, flags)) michael@0: NS_RUNTIMEABORT("can't mprotect()"); michael@0: } michael@0: michael@0: size_t michael@0: SharedMemory::SystemPageSize() michael@0: { michael@0: return sysconf(_SC_PAGESIZE); michael@0: } michael@0: michael@0: } // namespace ipc michael@0: } // namespace mozilla