d840165a32
- `etc` module was renamed to `etcpak` and modified to use the new library. - PKM importer is removed in the process, it's obsolete. - Old library `etc2comp` is removed. - S3TC compression no longer done via `squish` (but decompression still is). - Slight modifications to etcpak sources for MinGW compatibility, to fix LLVM `-Wc++11-narrowing` errors, and to allow using vendored or system libpng. Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
39 lines
956 B
C++
39 lines
956 B
C++
#include "mmap.hpp"
|
|
|
|
#ifdef _WIN32
|
|
# include <io.h>
|
|
# include <windows.h>
|
|
|
|
void* mmap( void* addr, size_t length, int prot, int flags, int fd, off_t offset )
|
|
{
|
|
HANDLE hnd;
|
|
void* map = nullptr;
|
|
|
|
switch( prot )
|
|
{
|
|
case PROT_READ:
|
|
if( hnd = CreateFileMapping( HANDLE( _get_osfhandle( fd ) ), nullptr, PAGE_READONLY, 0, DWORD( length ), nullptr ) )
|
|
{
|
|
map = MapViewOfFile( hnd, FILE_MAP_READ, 0, 0, length );
|
|
CloseHandle( hnd );
|
|
}
|
|
break;
|
|
case PROT_WRITE:
|
|
if( hnd = CreateFileMapping( HANDLE( _get_osfhandle( fd ) ), nullptr, PAGE_READWRITE, 0, DWORD( length ), nullptr ) )
|
|
{
|
|
map = MapViewOfFile( hnd, FILE_MAP_WRITE, 0, 0, length );
|
|
CloseHandle( hnd );
|
|
}
|
|
break;
|
|
}
|
|
|
|
return map ? (char*)map + offset : (void*)-1;
|
|
}
|
|
|
|
int munmap( void* addr, size_t length )
|
|
{
|
|
return UnmapViewOfFile( addr ) != 0 ? 0 : -1;
|
|
}
|
|
|
|
#endif
|