nsprpub/pr/src/io/prmmap.c

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 /*
michael@0 7 *********************************************************************
michael@0 8 *
michael@0 9 * Memory-mapped files
michael@0 10 *
michael@0 11 *********************************************************************
michael@0 12 */
michael@0 13
michael@0 14 #include "primpl.h"
michael@0 15
michael@0 16 PR_IMPLEMENT(PRFileMap *) PR_CreateFileMap(
michael@0 17 PRFileDesc *fd,
michael@0 18 PRInt64 size,
michael@0 19 PRFileMapProtect prot)
michael@0 20 {
michael@0 21 PRFileMap *fmap;
michael@0 22
michael@0 23 PR_ASSERT(prot == PR_PROT_READONLY || prot == PR_PROT_READWRITE
michael@0 24 || prot == PR_PROT_WRITECOPY);
michael@0 25 fmap = PR_NEWZAP(PRFileMap);
michael@0 26 if (NULL == fmap) {
michael@0 27 PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
michael@0 28 return NULL;
michael@0 29 }
michael@0 30 fmap->fd = fd;
michael@0 31 fmap->prot = prot;
michael@0 32 if (_PR_MD_CREATE_FILE_MAP(fmap, size) == PR_SUCCESS) {
michael@0 33 return fmap;
michael@0 34 } else {
michael@0 35 PR_DELETE(fmap);
michael@0 36 return NULL;
michael@0 37 }
michael@0 38 }
michael@0 39
michael@0 40 PR_IMPLEMENT(PRInt32) PR_GetMemMapAlignment(void)
michael@0 41 {
michael@0 42 return _PR_MD_GET_MEM_MAP_ALIGNMENT();
michael@0 43 }
michael@0 44
michael@0 45 PR_IMPLEMENT(void *) PR_MemMap(
michael@0 46 PRFileMap *fmap,
michael@0 47 PROffset64 offset,
michael@0 48 PRUint32 len)
michael@0 49 {
michael@0 50 return _PR_MD_MEM_MAP(fmap, offset, len);
michael@0 51 }
michael@0 52
michael@0 53 PR_IMPLEMENT(PRStatus) PR_MemUnmap(void *addr, PRUint32 len)
michael@0 54 {
michael@0 55 return _PR_MD_MEM_UNMAP(addr, len);
michael@0 56 }
michael@0 57
michael@0 58 PR_IMPLEMENT(PRStatus) PR_CloseFileMap(PRFileMap *fmap)
michael@0 59 {
michael@0 60 return _PR_MD_CLOSE_FILE_MAP(fmap);
michael@0 61 }
michael@0 62
michael@0 63 PR_IMPLEMENT(PRStatus) PR_SyncMemMap(
michael@0 64 PRFileDesc *fd,
michael@0 65 void *addr,
michael@0 66 PRUint32 len)
michael@0 67 {
michael@0 68 return _PR_MD_SYNC_MEM_MAP(fd, addr, len);
michael@0 69 }

mercurial