This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
[PATCH v2] Always use the same method to query the system page size
- From: Ulf Hermann <ulf dot hermann at qt dot io>
- To: <elfutils-devel at sourceware dot org>
- Date: Wed, 15 Feb 2017 15:28:38 +0100
- Subject: [PATCH v2] Always use the same method to query the system page size
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=ulf dot hermann at qt dot io;
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qtcompany.onmicrosoft.com; s=selector1-qt-io; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=6G/CQoIOupzASpg536H19NTBukPYR6zkRYt8wL/BII4=; b=doX8a+/ZJ3SSKRFiY1Xx7LGUdFi6d9OJs3+K7Idc0v3k25TboG4+cs7mp2krXXNdaCYi8QjCC1uviKky4DSN/gJyQthZLhWfBDQ/G/23Shz5W1vhuXLMR6kIHvtNGVBB7iVaKKt4a+MyqLvr0ZVb2znbic0Jog6RG026/4dAyUw=
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
This makes it easier to write a replacement for it on systems where
sysconf(3) doesn't exist.
Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
---
lib/ChangeLog | 4 ++++
lib/crc32_file.c | 2 +-
libdwfl/ChangeLog | 5 +++++
libdwfl/linux-kernel-modules.c | 2 +-
libdwfl/linux-proc-maps.c | 2 +-
5 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 5ccf4d6..6578ddb 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,7 @@
+2017-02-15 Ulf Hermann <ulf.hermann@qt.io>
+
+ * crc32_file.c: Use _SC_PAGESIZE rather than _SC_PAGE_SIZE.
+
2017-02-14 Ulf Hermann <ulf.hermann@qt.io>
* color.h: New file.
diff --git a/lib/crc32_file.c b/lib/crc32_file.c
index 57e4298..f7607d0 100644
--- a/lib/crc32_file.c
+++ b/lib/crc32_file.c
@@ -53,7 +53,7 @@ crc32_file (int fd, uint32_t *resp)
void *mapped = mmap (NULL, mapsize, PROT_READ, MAP_PRIVATE, fd, 0);
if (mapped == MAP_FAILED && errno == ENOMEM)
{
- const size_t pagesize = sysconf (_SC_PAGE_SIZE);
+ const size_t pagesize = sysconf (_SC_PAGESIZE);
mapsize = ((mapsize / 2) + pagesize - 1) & -pagesize;
while (mapsize >= pagesize
&& (mapped = mmap (NULL, mapsize, PROT_READ, MAP_PRIVATE,
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 57671ea..52466cc 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,8 @@
+2017-02-15 Ulf Hermann <ulf.hermann@qt.io>
+
+ * linux-kernel-modules.c: Use sysconf(_SC_PAGESIZE) to get page size.
+ * linux-proc-maps.c: Likewise.
+
2016-12-29 Luiz Angelo Daros de Luca <luizluca@gmail.com>
* dwfl_build_id_find_elf.c: Include system.h.
diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c
index 9cd8ea9..a7ac19d 100644
--- a/libdwfl/linux-kernel-modules.c
+++ b/libdwfl/linux-kernel-modules.c
@@ -500,7 +500,7 @@ intuit_kernel_bounds (Dwarf_Addr *start, Dwarf_Addr *end, Dwarf_Addr *notes)
if (*notes == 0 && !strcmp (state.p, "__start_notes\n"))
*notes = *end;
- Dwarf_Addr round_kernel = sysconf (_SC_PAGE_SIZE);
+ Dwarf_Addr round_kernel = sysconf (_SC_PAGESIZE);
*start &= -(Dwarf_Addr) round_kernel;
*end += round_kernel - 1;
*end &= -(Dwarf_Addr) round_kernel;
diff --git a/libdwfl/linux-proc-maps.c b/libdwfl/linux-proc-maps.c
index 4ae1e74..094dd53 100644
--- a/libdwfl/linux-proc-maps.c
+++ b/libdwfl/linux-proc-maps.c
@@ -418,7 +418,7 @@ dwfl_linux_proc_find_elf (Dwfl_Module *mod __attribute__ ((unused)),
if (fd < 0)
goto detach;
- *elfp = elf_from_remote_memory (base, getpagesize (), NULL,
+ *elfp = elf_from_remote_memory (base, sysconf (_SC_PAGESIZE), NULL,
&read_proc_memory, &fd);
close (fd);
--
2.1.4