michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 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: /* michael@0: ********************************************************************* michael@0: * michael@0: * Memory-mapped files michael@0: * michael@0: ********************************************************************* michael@0: */ michael@0: michael@0: #include "primpl.h" michael@0: michael@0: PR_IMPLEMENT(PRFileMap *) PR_CreateFileMap( michael@0: PRFileDesc *fd, michael@0: PRInt64 size, michael@0: PRFileMapProtect prot) michael@0: { michael@0: PRFileMap *fmap; michael@0: michael@0: PR_ASSERT(prot == PR_PROT_READONLY || prot == PR_PROT_READWRITE michael@0: || prot == PR_PROT_WRITECOPY); michael@0: fmap = PR_NEWZAP(PRFileMap); michael@0: if (NULL == fmap) { michael@0: PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0); michael@0: return NULL; michael@0: } michael@0: fmap->fd = fd; michael@0: fmap->prot = prot; michael@0: if (_PR_MD_CREATE_FILE_MAP(fmap, size) == PR_SUCCESS) { michael@0: return fmap; michael@0: } else { michael@0: PR_DELETE(fmap); michael@0: return NULL; michael@0: } michael@0: } michael@0: michael@0: PR_IMPLEMENT(PRInt32) PR_GetMemMapAlignment(void) michael@0: { michael@0: return _PR_MD_GET_MEM_MAP_ALIGNMENT(); michael@0: } michael@0: michael@0: PR_IMPLEMENT(void *) PR_MemMap( michael@0: PRFileMap *fmap, michael@0: PROffset64 offset, michael@0: PRUint32 len) michael@0: { michael@0: return _PR_MD_MEM_MAP(fmap, offset, len); michael@0: } michael@0: michael@0: PR_IMPLEMENT(PRStatus) PR_MemUnmap(void *addr, PRUint32 len) michael@0: { michael@0: return _PR_MD_MEM_UNMAP(addr, len); michael@0: } michael@0: michael@0: PR_IMPLEMENT(PRStatus) PR_CloseFileMap(PRFileMap *fmap) michael@0: { michael@0: return _PR_MD_CLOSE_FILE_MAP(fmap); michael@0: } michael@0: michael@0: PR_IMPLEMENT(PRStatus) PR_SyncMemMap( michael@0: PRFileDesc *fd, michael@0: void *addr, michael@0: PRUint32 len) michael@0: { michael@0: return _PR_MD_SYNC_MEM_MAP(fd, addr, len); michael@0: }