Browse Source

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.

tempestpy_adaptions
dehnert 12 years ago
parent
commit
18b72bc8d7
  1. 9
      src/parser/parser.cpp
  2. 3
      src/utility/osDetection.h

9
src/parser/parser.cpp

@ -7,6 +7,9 @@
#include <sys/stat.h>
#include <fcntl.h>
#if defined MACOSX
#include <unistd.h>
#endif
#include <errno.h>
#include <iostream>
#include <cstring>
@ -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);

3
src/utility/osDetection.h

@ -2,8 +2,9 @@
#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

Loading…
Cancel
Save