sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description: Implementation of mmap/munmap/msync.
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
// INCLUDE FILES
|
sl@0
|
20 |
|
sl@0
|
21 |
#include <sys/mman.h>
|
sl@0
|
22 |
#include "mmap.h"
|
sl@0
|
23 |
|
sl@0
|
24 |
extern "C"
|
sl@0
|
25 |
{
|
sl@0
|
26 |
|
sl@0
|
27 |
// -----------------------------------------------------------------------------
|
sl@0
|
28 |
// Funcation name: mmap
|
sl@0
|
29 |
// Description: Provides mmap functionality.
|
sl@0
|
30 |
// Returns: valid address : On success
|
sl@0
|
31 |
// -1 : On error
|
sl@0
|
32 |
// In case of error, errno value set
|
sl@0
|
33 |
//
|
sl@0
|
34 |
// -----------------------------------------------------------------------------
|
sl@0
|
35 |
|
sl@0
|
36 |
EXPORT_C void* mmap(void */*addr*/, size_t len, int prot, int flags, int fildes, off_t offset)
|
sl@0
|
37 |
{
|
sl@0
|
38 |
//TODO;To validate addr for page boundry and sharedmemory
|
sl@0
|
39 |
return _mmap_r(_REENT, len, prot, flags, fildes, offset);
|
sl@0
|
40 |
}
|
sl@0
|
41 |
|
sl@0
|
42 |
// -----------------------------------------------------------------------------
|
sl@0
|
43 |
// Funcation name: munmap
|
sl@0
|
44 |
// Description: Provides munmap functionality.
|
sl@0
|
45 |
// Returns: 0 : On success
|
sl@0
|
46 |
// -1 : On error
|
sl@0
|
47 |
// In case of error, errno value set
|
sl@0
|
48 |
// Remark: support for unmapping part of the mapped pages is not supported
|
sl@0
|
49 |
// Unmap will remove all mappings those were mapped starting from the offset
|
sl@0
|
50 |
// to offset + len (refer to mmap signature)
|
sl@0
|
51 |
// -----------------------------------------------------------------------------
|
sl@0
|
52 |
|
sl@0
|
53 |
EXPORT_C int munmap(void *addr, size_t len)
|
sl@0
|
54 |
{
|
sl@0
|
55 |
//TODO;To validate addr for page boundry and sharedmemory
|
sl@0
|
56 |
return _munmap_r(_REENT, addr, len);
|
sl@0
|
57 |
}
|
sl@0
|
58 |
|
sl@0
|
59 |
// -----------------------------------------------------------------------------
|
sl@0
|
60 |
// Funcation name: msync
|
sl@0
|
61 |
// Description: Provides msync functionality.
|
sl@0
|
62 |
// Returns: 0 : On success
|
sl@0
|
63 |
// -1 : On error
|
sl@0
|
64 |
// In case of error, errno value set
|
sl@0
|
65 |
//
|
sl@0
|
66 |
// -----------------------------------------------------------------------------
|
sl@0
|
67 |
|
sl@0
|
68 |
EXPORT_C int msync(void *addr, size_t len, int flags)
|
sl@0
|
69 |
{
|
sl@0
|
70 |
return _msync_r(_REENT, addr, len, flags);
|
sl@0
|
71 |
}
|
sl@0
|
72 |
|
sl@0
|
73 |
// -----------------------------------------------------------------------------
|
sl@0
|
74 |
// Funcation name: mprotect
|
sl@0
|
75 |
// Description: Provides msync functionality.
|
sl@0
|
76 |
// Returns: 0 : On success
|
sl@0
|
77 |
// -1 : On error
|
sl@0
|
78 |
// In case of error, errno value set
|
sl@0
|
79 |
// Remark: mprotect is only build enabled and not functional
|
sl@0
|
80 |
// -----------------------------------------------------------------------------
|
sl@0
|
81 |
|
sl@0
|
82 |
EXPORT_C int mprotect(const void *addr, size_t len, int prot)
|
sl@0
|
83 |
{
|
sl@0
|
84 |
return _mprotect_r(_REENT, addr, len, prot);
|
sl@0
|
85 |
}
|
sl@0
|
86 |
|
sl@0
|
87 |
|
sl@0
|
88 |
} // extern "C"
|
sl@0
|
89 |
|
sl@0
|
90 |
// End of File
|