update mmap.c to use ssize_t instead of off_t for 64bit
This commit is contained in:
@@ -2,7 +2,6 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
|
|
||||||
|
|
||||||
#ifndef FILE_MAP_EXECUTE
|
#ifndef FILE_MAP_EXECUTE
|
||||||
#define FILE_MAP_EXECUTE 0x0020
|
#define FILE_MAP_EXECUTE 0x0020
|
||||||
#endif /* FILE_MAP_EXECUTE */
|
#endif /* FILE_MAP_EXECUTE */
|
||||||
@@ -53,10 +52,9 @@ static DWORD __map_mmap_prot_file(const int prot)
|
|||||||
return desiredAccess;
|
return desiredAccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off)
|
void* mmap(void *addr, size_t len, int prot, int flags, int fildes, ssize_t off)
|
||||||
{
|
{
|
||||||
HANDLE fm, h;
|
HANDLE fm, h;
|
||||||
|
|
||||||
void * map = MAP_FAILED;
|
void * map = MAP_FAILED;
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
@@ -64,18 +62,18 @@ void* mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off)
|
|||||||
#pragma warning(disable: 4293)
|
#pragma warning(disable: 4293)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const DWORD dwFileOffsetLow = (sizeof(off_t) <= sizeof(DWORD)) ?
|
const DWORD dwFileOffsetLow = (sizeof(ssize_t) <= sizeof(DWORD)) ?
|
||||||
(DWORD)off : (DWORD)(off & 0xFFFFFFFFL);
|
(DWORD)off : (DWORD)(off & 0xFFFFFFFFL);
|
||||||
const DWORD dwFileOffsetHigh = (sizeof(off_t) <= sizeof(DWORD)) ?
|
const DWORD dwFileOffsetHigh = (sizeof(ssize_t) <= sizeof(DWORD)) ?
|
||||||
(DWORD)0 : (DWORD)((off >> 32) & 0xFFFFFFFFL);
|
(DWORD)0 : (DWORD)((off >> 32) & 0xFFFFFFFFL);
|
||||||
const DWORD protect = __map_mmap_prot_page(prot);
|
const DWORD protect = __map_mmap_prot_page(prot);
|
||||||
const DWORD desiredAccess = __map_mmap_prot_file(prot);
|
const DWORD desiredAccess = __map_mmap_prot_file(prot);
|
||||||
|
|
||||||
const off_t maxSize = off + (off_t)len;
|
const ssize_t maxSize = off + (ssize_t)len;
|
||||||
|
|
||||||
const DWORD dwMaxSizeLow = (sizeof(off_t) <= sizeof(DWORD)) ?
|
const DWORD dwMaxSizeLow = (sizeof(ssize_t) <= sizeof(DWORD)) ?
|
||||||
(DWORD)maxSize : (DWORD)(maxSize & 0xFFFFFFFFL);
|
(DWORD)maxSize : (DWORD)(maxSize & 0xFFFFFFFFL);
|
||||||
const DWORD dwMaxSizeHigh = (sizeof(off_t) <= sizeof(DWORD)) ?
|
const DWORD dwMaxSizeHigh = (sizeof(ssize_t) <= sizeof(DWORD)) ?
|
||||||
(DWORD)0 : (DWORD)((maxSize >> 32) & 0xFFFFFFFFL);
|
(DWORD)0 : (DWORD)((maxSize >> 32) & 0xFFFFFFFFL);
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ extern "C" {
|
|||||||
/* Flags for portable clock_gettime call. */
|
/* Flags for portable clock_gettime call. */
|
||||||
#define CLOCK_REALTIME 0
|
#define CLOCK_REALTIME 0
|
||||||
|
|
||||||
void* mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off);
|
void* mmap(void *addr, size_t len, int prot, int flags, int fildes, ssize_t off);
|
||||||
int munmap(void *addr, size_t len);
|
int munmap(void *addr, size_t len);
|
||||||
int mprotect(void *addr, size_t len, int prot);
|
int mprotect(void *addr, size_t len, int prot);
|
||||||
int msync(void *addr, size_t len, int flags);
|
int msync(void *addr, size_t len, int flags);
|
||||||
|
|||||||
Reference in New Issue
Block a user