This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Clean up linux-specific system includes


We only include them where we actually need them and only on linux.

Change-Id: Ic3065ffab67ba1177f63204fb91a92c5f4336dbb
Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
---
 backends/ChangeLog         | 8 ++++++++
 backends/aarch64_initreg.c | 4 ++--
 backends/arm_initreg.c     | 4 +++-
 backends/ppc_initreg.c     | 4 ++--
 backends/s390_initreg.c    | 4 ++--
 backends/x86_64_initreg.c  | 2 +-
 libdwfl/ChangeLog          | 7 +++++++
 libdwfl/dwfl_frame.c       | 1 -
 libdwfl/frame_unwind.c     | 1 -
 libdwfl/linux-pid-attach.c | 5 +++--
 tests/ChangeLog            | 5 +++++
 tests/backtrace-child.c    | 2 +-
 tests/backtrace-dwarf.c    | 2 +-
 13 files changed, 35 insertions(+), 14 deletions(-)

diff --git a/backends/ChangeLog b/backends/ChangeLog
index 39390cb..c6e0e08 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,11 @@
+2017-04-20  Ulf Hermann <ulf.hermann@qt.io>
+
+	* aarch64_initreg.c: Compile register initialization only on linux.
+	* arm_initreg.c: Likewise.
+	* ppc_initreg.c: Likewise.
+	* s390_initreg.c: Likewise.
+	* x86_64_initreg.c: Likewise.
+
 2017-02-15  Mark Wielaard  <mark@klomp.org>
 
 	* ppc64_init.c (ppc64_init): Add check_object_attribute HOOK.
diff --git a/backends/aarch64_initreg.c b/backends/aarch64_initreg.c
index 9706205..daf6f37 100644
--- a/backends/aarch64_initreg.c
+++ b/backends/aarch64_initreg.c
@@ -32,7 +32,7 @@
 
 #include "system.h"
 #include <assert.h>
-#ifdef __aarch64__
+#if defined(__aarch64__) && defined(__linux__)
 # include <linux/uio.h>
 # include <sys/user.h>
 # include <sys/ptrace.h>
@@ -51,7 +51,7 @@ aarch64_set_initial_registers_tid (pid_t tid __attribute__ ((unused)),
 			  ebl_tid_registers_t *setfunc __attribute__ ((unused)),
 				void *arg __attribute__ ((unused)))
 {
-#ifndef __aarch64__
+#if !defined(__aarch64__) || !defined(__linux__)
   return false;
 #else /* __aarch64__ */
 
diff --git a/backends/arm_initreg.c b/backends/arm_initreg.c
index a0a9be9..efcabaf 100644
--- a/backends/arm_initreg.c
+++ b/backends/arm_initreg.c
@@ -30,6 +30,7 @@
 # include <config.h>
 #endif
 
+#ifdef __linux__
 #if defined __arm__
 # include <sys/types.h>
 # include <sys/user.h>
@@ -45,6 +46,7 @@
 #  define user_regs_struct user_pt_regs
 # endif
 #endif
+#endif
 
 #define BACKEND arm_
 #include "libebl_CPU.h"
@@ -54,7 +56,7 @@ arm_set_initial_registers_tid (pid_t tid __attribute__ ((unused)),
 			  ebl_tid_registers_t *setfunc __attribute__ ((unused)),
 			       void *arg __attribute__ ((unused)))
 {
-#if !defined __arm__ && !defined __aarch64__
+#if !defined(__linux__) || (!defined __arm__ && !defined __aarch64__)
   return false;
 #else	/* __arm__ || __aarch64__ */
 #if defined __arm__
diff --git a/backends/ppc_initreg.c b/backends/ppc_initreg.c
index 64f5379..69d623b 100644
--- a/backends/ppc_initreg.c
+++ b/backends/ppc_initreg.c
@@ -32,7 +32,7 @@
 
 #include "system.h"
 #include <stdlib.h>
-#ifdef __powerpc__
+#if defined(__powerpc__) && defined(__linux__)
 # include <sys/user.h>
 # include <sys/ptrace.h>
 #endif
@@ -70,7 +70,7 @@ ppc_set_initial_registers_tid (pid_t tid __attribute__ ((unused)),
 			  ebl_tid_registers_t *setfunc __attribute__ ((unused)),
 			       void *arg __attribute__ ((unused)))
 {
-#ifndef __powerpc__
+#if !defined(__powerpc__) || !defined(__linux__)
   return false;
 #else /* __powerpc__ */
   union
diff --git a/backends/s390_initreg.c b/backends/s390_initreg.c
index b4c4b67..011305c 100644
--- a/backends/s390_initreg.c
+++ b/backends/s390_initreg.c
@@ -32,7 +32,7 @@
 
 #include "system.h"
 #include <assert.h>
-#ifdef __s390__
+#if defined(__s390__) && defined(__linux__)
 # include <sys/user.h>
 # include <asm/ptrace.h>
 # include <sys/ptrace.h>
@@ -46,7 +46,7 @@ s390_set_initial_registers_tid (pid_t tid __attribute__ ((unused)),
 			  ebl_tid_registers_t *setfunc __attribute__ ((unused)),
 				void *arg __attribute__ ((unused)))
 {
-#ifndef __s390__
+#if !defined(__s390__) || !defined(__linux__)
   return false;
 #else /* __s390__ */
   struct user user_regs;
diff --git a/backends/x86_64_initreg.c b/backends/x86_64_initreg.c
index db9216e..50e9002 100644
--- a/backends/x86_64_initreg.c
+++ b/backends/x86_64_initreg.c
@@ -31,7 +31,7 @@
 #endif
 
 #include <stdlib.h>
-#ifdef __x86_64__
+#if defined(__x86_64__) && defined(__linux__)
 # include <sys/user.h>
 # include <sys/ptrace.h>
 #endif
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 1ed9dd4..705b93d 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,5 +1,12 @@
 2017-04-20  Ulf Hermann <ulf.hermann@qt.io>
 
+	* dwfl_frame.c: Drop unused sys/ptrace.h include.
+	* frame_unwind.c: Likewise.
+	* linux-pid-attach.c: Include sys/ptrace.h and sys/syscall.h only on
+	linux.
+
+2017-04-20  Ulf Hermann <ulf.hermann@qt.io>
+
 	* linux-kernel-modules.c: Include sys/types.h before fts.h
 
 2017-03-24  Mark Wielaard  <mark@klomp.org>
diff --git a/libdwfl/dwfl_frame.c b/libdwfl/dwfl_frame.c
index d639939..1dc0c8d 100644
--- a/libdwfl/dwfl_frame.c
+++ b/libdwfl/dwfl_frame.c
@@ -27,7 +27,6 @@
    not, see <http://www.gnu.org/licenses/>.  */
 
 #include "libdwflP.h"
-#include <sys/ptrace.h>
 #include <unistd.h>
 
 /* Set STATE->pc_set from STATE->regs according to the backend.  Return true on
diff --git a/libdwfl/frame_unwind.c b/libdwfl/frame_unwind.c
index fb42c1a..4dc9c43 100644
--- a/libdwfl/frame_unwind.c
+++ b/libdwfl/frame_unwind.c
@@ -34,7 +34,6 @@
 #include <stdlib.h>
 #include "libdwflP.h"
 #include "../libdw/dwarf.h"
-#include <sys/ptrace.h>
 #include <system.h>
 
 /* Maximum number of DWARF expression stack slots before returning an error.  */
diff --git a/libdwfl/linux-pid-attach.c b/libdwfl/linux-pid-attach.c
index adfc7f8..398df96 100644
--- a/libdwfl/linux-pid-attach.c
+++ b/libdwfl/linux-pid-attach.c
@@ -31,14 +31,15 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <sys/ptrace.h>
 #include <sys/wait.h>
 #include <dirent.h>
-#include <sys/syscall.h>
 #include <unistd.h>
 
 #ifdef __linux__
 
+#include <sys/ptrace.h>
+#include <sys/syscall.h>
+
 static bool
 linux_proc_pid_is_stopped (pid_t pid)
 {
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 5f7bcdd..ebcd7bc 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,8 @@
+2017-04-20  Ulf Hermann <ulf.hermann@qt.io>
+
+	* backtrace-child.c: Include sys/ptrace.h only on linux.
+	* backtrace-dwarf.c: Likewise.
+
 2017-04-05  Mark Wielaard  <mark@klomp.org>
 
 	* test-subr.sh (testrun_on_self_compressed): New function.
diff --git a/tests/backtrace-child.c b/tests/backtrace-child.c
index cf4547c..2c27414 100644
--- a/tests/backtrace-child.c
+++ b/tests/backtrace-child.c
@@ -83,7 +83,6 @@
 #include <stdlib.h>
 #include <signal.h>
 #include <errno.h>
-#include <sys/ptrace.h>
 #include <string.h>
 #include <pthread.h>
 #include <stdio.h>
@@ -100,6 +99,7 @@ main (int argc __attribute__ ((unused)), char **argv)
 }
 
 #else /* __linux__ */
+#include <sys/ptrace.h>
 
 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
 #define NOINLINE_NOCLONE __attribute__ ((noinline, noclone))
diff --git a/tests/backtrace-dwarf.c b/tests/backtrace-dwarf.c
index a644c8a..2dc8a9a 100644
--- a/tests/backtrace-dwarf.c
+++ b/tests/backtrace-dwarf.c
@@ -24,7 +24,6 @@
 #include <errno.h>
 #include <error.h>
 #include <unistd.h>
-#include <sys/ptrace.h>
 #include <sys/types.h>
 #include <sys/wait.h>
 #include ELFUTILS_HEADER(dwfl)
@@ -40,6 +39,7 @@ main (int argc __attribute__ ((unused)), char **argv)
 }
 
 #else /* __linux__ */
+#include <sys/ptrace.h>
 
 #define main cleanup_13_main
 #include "cleanup-13.c"
-- 
2.1.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]