nsprpub/pr/src/io/prmmap.c

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/nsprpub/pr/src/io/prmmap.c	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,69 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +/*
    1.10 + *********************************************************************
    1.11 + *
    1.12 + * Memory-mapped files
    1.13 + *
    1.14 + *********************************************************************
    1.15 + */
    1.16 +
    1.17 +#include "primpl.h"
    1.18 +
    1.19 +PR_IMPLEMENT(PRFileMap *) PR_CreateFileMap(
    1.20 +    PRFileDesc *fd,
    1.21 +    PRInt64 size,
    1.22 +    PRFileMapProtect prot)
    1.23 +{
    1.24 +    PRFileMap *fmap;
    1.25 +
    1.26 +    PR_ASSERT(prot == PR_PROT_READONLY || prot == PR_PROT_READWRITE
    1.27 +            || prot == PR_PROT_WRITECOPY);
    1.28 +    fmap = PR_NEWZAP(PRFileMap);
    1.29 +    if (NULL == fmap) {
    1.30 +	PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
    1.31 +	return NULL;
    1.32 +    }
    1.33 +    fmap->fd = fd;
    1.34 +    fmap->prot = prot;
    1.35 +    if (_PR_MD_CREATE_FILE_MAP(fmap, size) == PR_SUCCESS) {
    1.36 +	return fmap;
    1.37 +    } else {
    1.38 +	PR_DELETE(fmap);
    1.39 +	return NULL;
    1.40 +    }
    1.41 +}
    1.42 +
    1.43 +PR_IMPLEMENT(PRInt32) PR_GetMemMapAlignment(void)
    1.44 +{
    1.45 +    return _PR_MD_GET_MEM_MAP_ALIGNMENT();
    1.46 +}
    1.47 +
    1.48 +PR_IMPLEMENT(void *) PR_MemMap(
    1.49 +    PRFileMap *fmap,
    1.50 +    PROffset64 offset,
    1.51 +    PRUint32 len)
    1.52 +{
    1.53 +    return _PR_MD_MEM_MAP(fmap, offset, len);
    1.54 +}
    1.55 +
    1.56 +PR_IMPLEMENT(PRStatus) PR_MemUnmap(void *addr, PRUint32 len)
    1.57 +{
    1.58 +    return _PR_MD_MEM_UNMAP(addr, len);
    1.59 +}
    1.60 +
    1.61 +PR_IMPLEMENT(PRStatus) PR_CloseFileMap(PRFileMap *fmap)
    1.62 +{
    1.63 +    return _PR_MD_CLOSE_FILE_MAP(fmap);
    1.64 +}
    1.65 +
    1.66 +PR_IMPLEMENT(PRStatus) PR_SyncMemMap(
    1.67 +    PRFileDesc *fd,
    1.68 +    void *addr,
    1.69 +    PRUint32 len)
    1.70 +{
    1.71 +  return _PR_MD_SYNC_MEM_MAP(fd, addr, len);
    1.72 +}

mercurial