Coverage Report

Created: 2025-07-01 06:25

/src/nspr/pr/src/io/prmmap.c
Line
Count
Source (jump to first uncovered line)
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*)
17
0
PR_CreateFileMap(PRFileDesc* fd, PRInt64 size, PRFileMapProtect prot) {
18
0
  PRFileMap* fmap;
19
20
0
  PR_ASSERT(prot == PR_PROT_READONLY || prot == PR_PROT_READWRITE ||
21
0
            prot == PR_PROT_WRITECOPY);
22
0
  fmap = PR_NEWZAP(PRFileMap);
23
0
  if (NULL == fmap) {
24
0
    PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
25
0
    return NULL;
26
0
  }
27
0
  fmap->fd = fd;
28
0
  fmap->prot = prot;
29
0
  if (_PR_MD_CREATE_FILE_MAP(fmap, size) == PR_SUCCESS) {
30
0
    return fmap;
31
0
  }
32
0
  PR_DELETE(fmap);
33
0
  return NULL;
34
0
}
35
36
0
PR_IMPLEMENT(PRInt32) PR_GetMemMapAlignment(void) {
37
0
  return _PR_MD_GET_MEM_MAP_ALIGNMENT();
38
0
}
39
40
PR_IMPLEMENT(void*)
41
0
PR_MemMap(PRFileMap* fmap, PROffset64 offset, PRUint32 len) {
42
0
  return _PR_MD_MEM_MAP(fmap, offset, len);
43
0
}
44
45
0
PR_IMPLEMENT(PRStatus) PR_MemUnmap(void* addr, PRUint32 len) {
46
0
  return _PR_MD_MEM_UNMAP(addr, len);
47
0
}
48
49
0
PR_IMPLEMENT(PRStatus) PR_CloseFileMap(PRFileMap* fmap) {
50
0
  return _PR_MD_CLOSE_FILE_MAP(fmap);
51
0
}
52
53
0
PR_IMPLEMENT(PRStatus) PR_SyncMemMap(PRFileDesc* fd, void* addr, PRUint32 len) {
54
0
  return _PR_MD_SYNC_MEM_MAP(fd, addr, len);
55
0
}