Replace getpagesize() with sysconf(_SC_PAGESIZE).
getpagesize() has been removed from POSIX.1-2001. Its recommended replacement is sysconf(_SC_PAGESIZE).
This commit is contained in:
@@ -63,7 +63,7 @@ DEFINE_bool(snappy_dump_decompression_table, false,
|
|||||||
|
|
||||||
namespace snappy {
|
namespace snappy {
|
||||||
|
|
||||||
#ifdef HAVE_FUNC_MMAP
|
#if defined(HAVE_FUNC_MMAP) && defined(HAVE_FUNC_SYSCONF)
|
||||||
|
|
||||||
// To test against code that reads beyond its input, this class copies a
|
// 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
|
// string to a newly allocated group of pages, the last of which
|
||||||
@@ -74,7 +74,7 @@ namespace snappy {
|
|||||||
class DataEndingAtUnreadablePage {
|
class DataEndingAtUnreadablePage {
|
||||||
public:
|
public:
|
||||||
explicit DataEndingAtUnreadablePage(const string& s) {
|
explicit DataEndingAtUnreadablePage(const string& s) {
|
||||||
const size_t page_size = getpagesize();
|
const size_t page_size = sysconf(_SC_PAGESIZE);
|
||||||
const size_t size = s.size();
|
const size_t size = s.size();
|
||||||
// Round up space for string to a multiple of page_size.
|
// Round up space for string to a multiple of page_size.
|
||||||
size_t space_for_string = (size + page_size - 1) & ~(page_size - 1);
|
size_t space_for_string = (size + page_size - 1) & ~(page_size - 1);
|
||||||
@@ -92,8 +92,9 @@ class DataEndingAtUnreadablePage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
~DataEndingAtUnreadablePage() {
|
~DataEndingAtUnreadablePage() {
|
||||||
|
const size_t page_size = sysconf(_SC_PAGESIZE);
|
||||||
// Undo the mprotect.
|
// Undo the mprotect.
|
||||||
CHECK_EQ(0, mprotect(protected_page_, getpagesize(), PROT_READ|PROT_WRITE));
|
CHECK_EQ(0, mprotect(protected_page_, page_size, PROT_READ|PROT_WRITE));
|
||||||
CHECK_EQ(0, munmap(mem_, alloc_size_));
|
CHECK_EQ(0, munmap(mem_, alloc_size_));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +109,7 @@ class DataEndingAtUnreadablePage {
|
|||||||
size_t size_;
|
size_t size_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#else // HAVE_FUNC_MMAP
|
#else // defined(HAVE_FUNC_MMAP) && defined(HAVE_FUNC_SYSCONF)
|
||||||
|
|
||||||
// Fallback for systems without mmap.
|
// Fallback for systems without mmap.
|
||||||
typedef string DataEndingAtUnreadablePage;
|
typedef string DataEndingAtUnreadablePage;
|
||||||
|
|||||||
Reference in New Issue
Block a user