Skip to content

Commit

Permalink
src: reduce large pages code duplication
Browse files Browse the repository at this point in the history
Declaring and initializing a `struct text_region` is common to all
three implementations of the large pages mapping code. Let's make it
unconditional.

PR-URL: #31385
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Jiawen Geng <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: JungMinu - Minwoo Jung <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
  • Loading branch information
Gabriel Schulhof authored and codebytere committed Feb 17, 2020
1 parent 6256d0a commit b8face2
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/large_pages/node_large_page.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,15 @@ inline uintptr_t hugepage_align_down(uintptr_t addr) {
// This is also handling the case where the first line is not the binary.

static struct text_region FindNodeTextRegion() {
struct text_region nregion;
nregion.found_text_region = false;
#if defined(__linux__)
std::ifstream ifs;
std::string map_line;
std::string permission;
std::string dev;
char dash;
uintptr_t start, end, offset, inode;
struct text_region nregion;

nregion.found_text_region = false;

ifs.open("/proc/self/maps");
if (!ifs) {
Expand Down Expand Up @@ -161,9 +160,6 @@ static struct text_region FindNodeTextRegion() {

ifs.close();
#elif defined(__FreeBSD__)
struct text_region nregion;
nregion.found_text_region = false;

std::string exename;
{
char selfexe[PATH_MAX];
Expand Down Expand Up @@ -220,8 +216,6 @@ static struct text_region FindNodeTextRegion() {
start += cursz;
}
#elif defined(__APPLE__)
struct text_region nregion;
nregion.found_text_region = false;
struct vm_region_submap_info_64 map;
mach_msg_type_number_t count = VM_REGION_SUBMAP_INFO_COUNT_64;
vm_address_t addr = 0UL;
Expand Down

0 comments on commit b8face2

Please sign in to comment.