diff --git a/include/zipr_all.h b/include/zipr_all.h index 8fdbe56185aaa5d477324816b283b96d274cd016..a47f99660d5dc2ba66d931a4add479c78ac16be7 100644 --- a/include/zipr_all.h +++ b/include/zipr_all.h @@ -49,6 +49,8 @@ namespace zipr using namespace Zipr_SDK; +#define PAGE_SIZE 4096 + #include <sled.h> #include <unresolved.h> #include <zipr_mem_space.h> diff --git a/include/zipr_impl.h b/include/zipr_impl.h index 4ad2e11b66560eb9a9528c383dca8c6d83c665bd..a6362210cca7059450a32efdb4427f3a87096880 100644 --- a/include/zipr_impl.h +++ b/include/zipr_impl.h @@ -511,7 +511,6 @@ class ZiprImpl_t : public Zipr_t template <class T> static T page_align(const T& in) { - const T PAGE_SIZE=4096; return align_by(in,PAGE_SIZE); } template <class T> static T align_up_to(const T& in, const T &by) diff --git a/src/elfwrite.cpp b/src/elfwrite.cpp index d705eecd968c9dca8c5c80a0ad0341f27d7fee51..ac32b08becb8a7ab834fa70dd607fe491b731d2e 100644 --- a/src/elfwrite.cpp +++ b/src/elfwrite.cpp @@ -26,14 +26,9 @@ using namespace zipr; using namespace ELFIO; -#ifndef PAGE_SIZE -#define PAGE_SIZE 4096 -#endif - static inline uintptr_t page_round_up(uintptr_t x) { - const int page_size=PAGE_SIZE; - return ( (((uintptr_t)(x)) + page_size-1) & (~(page_size-1)) ); + return ( (((uintptr_t)(x)) + PAGE_SIZE-1) & (~(PAGE_SIZE-1)) ); } diff --git a/src/zipr.cpp b/src/zipr.cpp index 63a6308593e33df450be6d2cbf6498fd4812352b..9979b136d4415552799c912b33e936e48ea1c028 100644 --- a/src/zipr.cpp +++ b/src/zipr.cpp @@ -58,8 +58,12 @@ using namespace IRDBUtility; inline uintptr_t page_round_up(uintptr_t x) { - const int page_size=4096; - return ( (((uintptr_t)(x)) + page_size-1) & (~(page_size-1)) ); + return ( (((uintptr_t)(x)) + PAGE_SIZE-1) & (~(PAGE_SIZE-1)) ); +} + +inline uintptr_t page_round_down(uintptr_t x) +{ + return ( (((uintptr_t)(x)) - (PAGE_SIZE-1)) & (~(PAGE_SIZE-1)) ); } int find_magic_segment_index(ELFIO::elfio *elfiop);