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