mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-22 16:26:39 +00:00
71308351a8
Original commit message from CVS: Several new files from Steve Lhomme's MSVC patch (bug #141317): * win32/GStreamer.vcproj: * win32/Makefile: * win32/config.h: * win32/dirent.c: (_topendir), (_treaddir), (_tclosedir), (_trewinddir), (_ttelldir), (_tseekdir): * win32/dirent.h: * win32/gst-inspect.vcproj: * win32/gst-launch.vcproj: * win32/gst-register.vcproj: * win32/gstbytestream.vcproj: * win32/gstelements.vcproj: * win32/gstoptimalscheduler.vcproj: * win32/gstspider.vcproj: * win32/gtchar.h: * win32/mman.c: (mmap), (mprotect), (msync), (munmap): * win32/mman.h: * win32/mman.inl: * win32/msvc71.sln:
87 lines
1.8 KiB
C
87 lines
1.8 KiB
C
/* $Id$
|
|
|
|
* =============================================================================
|
|
*
|
|
* = LIBRARY
|
|
* pace
|
|
*
|
|
* = FILENAME
|
|
* pace/win32/mman.c
|
|
*
|
|
* = AUTHOR
|
|
* Luther Baker
|
|
*
|
|
* ============================================================================= */
|
|
|
|
#include "mman.h"
|
|
|
|
void *
|
|
mmap (void *addr, size_t len, int prot, int flags, HANDLE fildes, long off)
|
|
{
|
|
void *addr_mapping = 0;
|
|
int nt_flags = 0;
|
|
HANDLE file_mapping = INVALID_HANDLE_VALUE;
|
|
|
|
if (flags | MAP_PRIVATE) {
|
|
prot = PAGE_WRITECOPY;
|
|
nt_flags = FILE_MAP_COPY;
|
|
} else if (flags | MAP_SHARED) {
|
|
if (prot | PAGE_READONLY)
|
|
nt_flags = FILE_MAP_READ;
|
|
if (prot | PAGE_READWRITE)
|
|
nt_flags = FILE_MAP_WRITE;
|
|
}
|
|
|
|
file_mapping = CreateFileMapping (fildes, 0, prot, 0, 0, 0);
|
|
if (file_mapping == 0)
|
|
return MAP_FAILED;
|
|
|
|
# if defined (PACE_OS_EXTRA_MMAP_FLAGS)
|
|
nt_flags |= PACE_OS_EXTRA_MMAP_FLAGS;
|
|
# endif /* PACE_OS_EXTRA_MMAP_FLAGS */
|
|
|
|
//ACE_UNUSED_ARG (addr); /* WinCE does not allow specifying <addr>.*/
|
|
addr_mapping = MapViewOfFile (file_mapping, nt_flags, 0, off, len);
|
|
|
|
/* Only close this down if we used the temporary. */
|
|
if (file_mapping == INVALID_HANDLE_VALUE)
|
|
CloseHandle (file_mapping);
|
|
|
|
if (addr_mapping == 0)
|
|
return MAP_FAILED;
|
|
|
|
else if ((flags | MAP_FIXED)
|
|
&& addr_mapping != addr) {
|
|
errno = 22;
|
|
return MAP_FAILED;
|
|
} else
|
|
return addr_mapping;
|
|
}
|
|
|
|
int
|
|
mprotect (void *addr, size_t len, int prot)
|
|
{
|
|
DWORD dummy; /* Sigh! */
|
|
|
|
return VirtualProtect (addr, len, prot, &dummy) ? 0 : -1;
|
|
}
|
|
|
|
|
|
int
|
|
msync (void *addr, size_t len, int flags)
|
|
{
|
|
//PACE_UNUSED_ARG (flags);
|
|
if (!FlushViewOfFile (addr, len))
|
|
return -1;
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
munmap (void *addr, size_t len)
|
|
{
|
|
//PACE_UNUSED_ARG (len);
|
|
if (!UnmapViewOfFile (addr))
|
|
return -1;
|
|
return 0;
|
|
|
|
}
|