summaryrefslogtreecommitdiff
path: root/linker/linker_mapped_file_fragment.cpp
diff options
context:
space:
mode:
authorDmitriy Ivanov <dimitry@google.com>2015-11-20 13:34:11 -0800
committerDimitry Ivanov <dimitry@google.com>2015-11-20 21:37:51 +0000
commit84bab5a9552cebf57795ade0e1abd5f7aee46479 (patch)
tree0c6fd9d36cd69f86c377a772b3d4b8f8e9ef333b /linker/linker_mapped_file_fragment.cpp
parenta1ab0d8ed1c4025233b0d816164eefb1b84159b9 (diff)
Move some utility functions to linker_utils
Also adds unit-tests for page_start, page_offset, and safe_add Change-Id: Ia1325b4682d367328a01599a19848e4ffcd2c0ea
Diffstat (limited to 'linker/linker_mapped_file_fragment.cpp')
-rw-r--r--linker/linker_mapped_file_fragment.cpp21
1 files changed, 1 insertions, 20 deletions
diff --git a/linker/linker_mapped_file_fragment.cpp b/linker/linker_mapped_file_fragment.cpp
index 6a500ef1e..27c1c69af 100644
--- a/linker/linker_mapped_file_fragment.cpp
+++ b/linker/linker_mapped_file_fragment.cpp
@@ -16,32 +16,13 @@
#include "linker_mapped_file_fragment.h"
#include "linker_debug.h"
+#include "linker_utils.h"
#include <inttypes.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <unistd.h>
-constexpr off64_t kPageMask = ~static_cast<off64_t>(PAGE_SIZE-1);
-
-static off64_t page_start(off64_t offset) {
- return offset & kPageMask;
-}
-
-static bool safe_add(off64_t* out, off64_t a, size_t b) {
- CHECK(a >= 0);
- if (static_cast<uint64_t>(INT64_MAX - a) < b) {
- return false;
- }
-
- *out = a + b;
- return true;
-}
-
-static size_t page_offset(off64_t offset) {
- return static_cast<size_t>(offset & (PAGE_SIZE-1));
-}
-
MappedFileFragment::MappedFileFragment() : map_start_(nullptr), map_size_(0),
data_(nullptr), size_ (0)
{ }