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