From 18b72bc8d7be0333f2227d3a652e04534664f6e2 Mon Sep 17 00:00:00 2001 From: dehnert Date: Sun, 2 Dec 2012 12:13:32 +0100 Subject: [PATCH] Added necessary include of unistd.h (for close()) to parser. Removed flag MAP_DENYWRITE of mmap for Mac OS and Linux as it is non-existent and ignored, respectively. Changed call to stat64 to call to stat for MAC OS, as stat64 is deprecated and 64-bit mode is turned on by macro that is no correctly set during OS-Detection. --- src/parser/parser.cpp | 9 ++++++++- src/utility/osDetection.h | 5 +++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/parser/parser.cpp b/src/parser/parser.cpp index a6daeeb76..4e0a0463e 100644 --- a/src/parser/parser.cpp +++ b/src/parser/parser.cpp @@ -7,6 +7,9 @@ #include #include +#if defined MACOSX + #include +#endif #include #include #include @@ -63,7 +66,11 @@ mrmc::parser::MappedFile::MappedFile(const char* filename) * Do file mapping for reasonable systems. * stat64(), open(), mmap() */ +#ifdef MACOSX + if (stat(filename, &(this->st)) != 0) +#else if (stat64(filename, &(this->st)) != 0) +#endif { LOG4CPLUS_ERROR(logger, "Error in stat(" << filename << ")."); throw exceptions::file_IO_exception("mrmc::parser::MappedFile Error in stat()"); @@ -76,7 +83,7 @@ mrmc::parser::MappedFile::MappedFile(const char* filename) throw exceptions::file_IO_exception("mrmc::parser::MappedFile Error in open()"); } - this->data = (char*) mmap(NULL, this->st.st_size, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, this->file, 0); + this->data = (char*) mmap(NULL, this->st.st_size, PROT_READ, MAP_PRIVATE, this->file, 0); if (this->data == (char*)-1) { close(this->file); diff --git a/src/utility/osDetection.h b/src/utility/osDetection.h index c6c863a60..da72a909f 100644 --- a/src/utility/osDetection.h +++ b/src/utility/osDetection.h @@ -2,10 +2,11 @@ #if defined __linux__ || defined __linux #define LINUX -#elif defined TARGET_OS_MAC || defined __apple__ +#elif defined TARGET_OS_MAC || defined __apple__ || defined __APPLE__ #define MACOSX + #define _DARWIN_USE_64_BIT_INODE #elif defined _WIN32 || defined _WIN64 #define WINDOWS #else #error Could not detect Operating System -#endif \ No newline at end of file +#endif