Make the unit test work on systems without mmap(). This is required for,
among others, Windows support. For Windows in specific, we could have used CreateFileMapping/MapViewOfFile, but this should at least get us a bit closer to compiling, and is of course also relevant for embedded systems with no MMU. (Part 2/2) R=csilvers DELTA=15 (12 added, 3 deleted, 0 changed) Revision created by MOE tool push_codebase. MOE_MIGRATION=1032 git-svn-id: https://snappy.googlecode.com/svn/trunk@16 03e5f5b5-db94-4691-08a0-1a8bf15f6143
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
@@ -54,15 +53,14 @@ DEFINE_bool(write_uncompressed, false,
|
||||
namespace snappy {
|
||||
|
||||
|
||||
#ifdef HAVE_FUNC_MMAP
|
||||
|
||||
// To test against code that reads beyond its input, this class copies a
|
||||
// string to a newly allocated group of pages, the last of which
|
||||
// is made unreadable via mprotect. Note that we need to allocate the
|
||||
// memory with mmap(), as POSIX allows mprotect() only on memory allocated
|
||||
// with mmap(), and some malloc/posix_memalign implementations expect to
|
||||
// be able to read previously allocated memory while doing heap allocations.
|
||||
//
|
||||
// TODO(user): Add support for running the unittest without the protection
|
||||
// checks if the target system doesn't have mmap.
|
||||
class DataEndingAtUnreadablePage {
|
||||
public:
|
||||
explicit DataEndingAtUnreadablePage(const string& s) {
|
||||
@@ -100,6 +98,13 @@ class DataEndingAtUnreadablePage {
|
||||
size_t size_;
|
||||
};
|
||||
|
||||
#else // HAVE_FUNC_MMAP
|
||||
|
||||
// Fallback for systems without mmap.
|
||||
typedef string DataEndingAtUnreadablePage;
|
||||
|
||||
#endif
|
||||
|
||||
enum CompressorType {
|
||||
ZLIB, LZO, LIBLZF, QUICKLZ, FASTLZ, SNAPPY,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user