os/ossrv/genericopenlibs/openenvcore/libc/src/mmap.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/openenvcore/libc/src/mmap.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,90 @@
     1.4 +/*
     1.5 +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:  Implementation of mmap/munmap/msync.
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +// INCLUDE FILES
    1.23 +
    1.24 +#include <sys/mman.h>
    1.25 +#include "mmap.h"
    1.26 +
    1.27 +extern "C" 
    1.28 +{
    1.29 +
    1.30 +// -----------------------------------------------------------------------------
    1.31 +// Funcation name: mmap
    1.32 +// Description: Provides mmap functionality.
    1.33 +// Returns:  valid address : On success
    1.34 +//           -1    		   : On error
    1.35 +// In case of error, errno value set
    1.36 +//      
    1.37 +// -----------------------------------------------------------------------------
    1.38 +
    1.39 +EXPORT_C void* mmap(void */*addr*/, size_t len, int prot, int flags, int fildes, off_t offset)
    1.40 +	{
    1.41 +	//TODO;To validate addr for page boundry and sharedmemory
    1.42 +	return _mmap_r(_REENT, len, prot, flags, fildes, offset);
    1.43 +	}
    1.44 +
    1.45 +// -----------------------------------------------------------------------------
    1.46 +// Funcation name: munmap
    1.47 +// Description: Provides munmap functionality.
    1.48 +// Returns:   0 : On success
    1.49 +//           -1 : On error
    1.50 +// In case of error, errno value set
    1.51 +// Remark: support for unmapping part of the mapped pages is not supported
    1.52 +//         Unmap will remove all mappings those were mapped starting from the offset
    1.53 +//         to offset + len (refer to mmap signature)  
    1.54 +// -----------------------------------------------------------------------------
    1.55 +
    1.56 +EXPORT_C int munmap(void *addr, size_t len)
    1.57 +	{
    1.58 +	//TODO;To validate addr for page boundry and sharedmemory		
    1.59 +	return _munmap_r(_REENT, addr, len);				
    1.60 +	}
    1.61 +
    1.62 +// -----------------------------------------------------------------------------
    1.63 +// Funcation name: msync
    1.64 +// Description: Provides msync functionality.
    1.65 +// Returns:   0 : On success
    1.66 +//           -1 : On error
    1.67 +// In case of error, errno value set
    1.68 +//      
    1.69 +// -----------------------------------------------------------------------------
    1.70 +
    1.71 +EXPORT_C int msync(void *addr, size_t len, int flags)
    1.72 +	{	
    1.73 +	return _msync_r(_REENT, addr, len, flags);
    1.74 +	}
    1.75 +
    1.76 +// -----------------------------------------------------------------------------
    1.77 +// Funcation name: mprotect
    1.78 +// Description: Provides msync functionality.
    1.79 +// Returns:   0 : On success
    1.80 +//           -1 : On error
    1.81 +// In case of error, errno value set
    1.82 +// Remark: mprotect is only build enabled and not functional     
    1.83 +// -----------------------------------------------------------------------------
    1.84 +
    1.85 +EXPORT_C int mprotect(const void *addr, size_t len, int prot)
    1.86 +	{	
    1.87 +	return _mprotect_r(_REENT, addr, len, prot);
    1.88 +	}
    1.89 +
    1.90 +    
    1.91 +} // extern "C"
    1.92 +
    1.93 +//  End of File