#include <windows.h>
#include "mingw_mmap.h"

void *mingw_mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
{
	HANDLE handle;

	handle = CreateFileMapping((HANDLE)_get_osfhandle(fd), NULL,
		PAGE_WRITECOPY,
		0, 0, NULL);

	if (handle != NULL) {
		start = MapViewOfFile(handle, FILE_MAP_COPY, 0, offset,
			length);
		CloseHandle(handle);
	}

	return start;
}

int mingw_munmap(void *start, size_t length)
{
	UnmapViewOfFile(start);
	return 0;
} 
