Skip to content

Commit b8face2

Browse files
Gabriel Schulhofcodebytere
Gabriel Schulhof
authored andcommittedFeb 17, 2020
src: reduce large pages code duplication
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]>
1 parent 6256d0a commit b8face2

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed
 

‎src/large_pages/node_large_page.cc

+2-8
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,15 @@ inline uintptr_t hugepage_align_down(uintptr_t addr) {
100100
// This is also handling the case where the first line is not the binary.
101101

102102
static struct text_region FindNodeTextRegion() {
103+
struct text_region nregion;
104+
nregion.found_text_region = false;
103105
#if defined(__linux__)
104106
std::ifstream ifs;
105107
std::string map_line;
106108
std::string permission;
107109
std::string dev;
108110
char dash;
109111
uintptr_t start, end, offset, inode;
110-
struct text_region nregion;
111-
112-
nregion.found_text_region = false;
113112

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

162161
ifs.close();
163162
#elif defined(__FreeBSD__)
164-
struct text_region nregion;
165-
nregion.found_text_region = false;
166-
167163
std::string exename;
168164
{
169165
char selfexe[PATH_MAX];
@@ -220,8 +216,6 @@ static struct text_region FindNodeTextRegion() {
220216
start += cursz;
221217
}
222218
#elif defined(__APPLE__)
223-
struct text_region nregion;
224-
nregion.found_text_region = false;
225219
struct vm_region_submap_info_64 map;
226220
mach_msg_type_number_t count = VM_REGION_SUBMAP_INFO_COUNT_64;
227221
vm_address_t addr = 0UL;

0 commit comments

Comments
 (0)
Please sign in to comment.