summaryrefslogtreecommitdiffstats
path: root/libutils/FileMap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libutils/FileMap.cpp')
-rw-r--r--libutils/FileMap.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/libutils/FileMap.cpp b/libutils/FileMap.cpp
index f8d6bdabd..6d92f742b 100644
--- a/libutils/FileMap.cpp
+++ b/libutils/FileMap.cpp
@@ -23,7 +23,7 @@
#include <utils/FileMap.h>
#include <utils/Log.h>
-#if defined(HAVE_WIN32_FILEMAP) && !defined(__USE_MINGW_ANSI_STDIO)
+#if defined(__MINGW32__) && !defined(__USE_MINGW_ANSI_STDIO)
# define PRId32 "I32d"
# define PRIx32 "I32x"
# define PRId64 "I64d"
@@ -33,7 +33,7 @@
#include <stdio.h>
#include <stdlib.h>
-#ifdef HAVE_POSIX_FILEMAP
+#if !defined(__MINGW32__)
#include <sys/mman.h>
#endif
@@ -64,12 +64,7 @@ FileMap::~FileMap(void)
if (mFileName != NULL) {
free(mFileName);
}
-#ifdef HAVE_POSIX_FILEMAP
- if (mBasePtr && munmap(mBasePtr, mBaseLength) != 0) {
- ALOGD("munmap(%p, %zu) failed\n", mBasePtr, mBaseLength);
- }
-#endif
-#ifdef HAVE_WIN32_FILEMAP
+#if defined(__MINGW32__)
if (mBasePtr && UnmapViewOfFile(mBasePtr) == 0) {
ALOGD("UnmapViewOfFile(%p) failed, error = %" PRId32 "\n", mBasePtr,
GetLastError() );
@@ -77,6 +72,10 @@ FileMap::~FileMap(void)
if (mFileMapping != INVALID_HANDLE_VALUE) {
CloseHandle(mFileMapping);
}
+#else
+ if (mBasePtr && munmap(mBasePtr, mBaseLength) != 0) {
+ ALOGD("munmap(%p, %zu) failed\n", mBasePtr, mBaseLength);
+ }
#endif
}
@@ -90,7 +89,7 @@ FileMap::~FileMap(void)
bool FileMap::create(const char* origFileName, int fd, off64_t offset, size_t length,
bool readOnly)
{
-#ifdef HAVE_WIN32_FILEMAP
+#if defined(__MINGW32__)
int adjust;
off64_t adjOffset;
size_t adjLength;
@@ -128,8 +127,7 @@ bool FileMap::create(const char* origFileName, int fd, off64_t offset, size_t le
mFileMapping = INVALID_HANDLE_VALUE;
return false;
}
-#endif
-#ifdef HAVE_POSIX_FILEMAP
+#else // !defined(__MINGW32__)
int prot, flags, adjust;
off64_t adjOffset;
size_t adjLength;
@@ -179,7 +177,7 @@ try_again:
return false;
}
mBasePtr = ptr;
-#endif // HAVE_POSIX_FILEMAP
+#endif // !defined(__MINGW32__)
mFileName = origFileName != NULL ? strdup(origFileName) : NULL;
mBaseLength = adjLength;