Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1 | From 5dc872bb2fba6421cb8e1ee578f7bd4aaed55f61 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Thu, 24 Mar 2016 15:46:14 +0000 |
| 4 | Subject: [PATCH] Use UINTPTR_MAX instead of __WORDSIZE |
| 5 | |
| 6 | Do not include sys/user.h since it conflicts with |
| 7 | pt_regs struct from kernel APIs in asm/ptrace.h |
| 8 | |
| 9 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 10 | --- |
| 11 | Upstream-Status: Pending |
| 12 | |
| 13 | src/peekfd.c | 13 ++++++++----- |
| 14 | 1 file changed, 8 insertions(+), 5 deletions(-) |
| 15 | |
| 16 | diff --git a/src/peekfd.c b/src/peekfd.c |
| 17 | index cba2130..0d39878 100644 |
| 18 | --- a/src/peekfd.c |
| 19 | +++ b/src/peekfd.c |
| 20 | @@ -30,8 +30,11 @@ |
| 21 | #include <asm/ptrace.h> |
| 22 | #include <byteswap.h> |
| 23 | #include <endian.h> |
| 24 | +#ifdef __GLIBC__ |
| 25 | #include <sys/user.h> |
| 26 | +#endif |
| 27 | #include <stdlib.h> |
| 28 | +#include <stdint.h> |
| 29 | #include <getopt.h> |
| 30 | #include <ctype.h> |
| 31 | |
| 32 | @@ -228,11 +231,11 @@ int main(int argc, char **argv) |
| 33 | if (WIFSTOPPED(status)) { |
| 34 | #ifdef PPC |
| 35 | struct pt_regs regs; |
| 36 | - regs.gpr[0] = ptrace(PTRACE_PEEKUSER, pid, __WORDSIZE/8 * PT_R0, 0); |
| 37 | - regs.gpr[3] = ptrace(PTRACE_PEEKUSER, pid, __WORDSIZE/8 * PT_R3, 0); |
| 38 | - regs.gpr[4] = ptrace(PTRACE_PEEKUSER, pid, __WORDSIZE/8 * PT_R4, 0); |
| 39 | - regs.gpr[5] = ptrace(PTRACE_PEEKUSER, pid, __WORDSIZE/8 * PT_R5, 0); |
| 40 | - regs.orig_gpr3 = ptrace(PTRACE_PEEKUSER, pid, __WORDSIZE/8 * PT_ORIG_R3, 0); |
| 41 | + regs.gpr[0] = ptrace(PTRACE_PEEKUSER, pid, UINTPTR_MAX/8 * PT_R0, 0); |
| 42 | + regs.gpr[3] = ptrace(PTRACE_PEEKUSER, pid, UINTPTR_MAX/8 * PT_R3, 0); |
| 43 | + regs.gpr[4] = ptrace(PTRACE_PEEKUSER, pid, UINTPTR_MAX/8 * PT_R4, 0); |
| 44 | + regs.gpr[5] = ptrace(PTRACE_PEEKUSER, pid, UINTPTR_MAX/8 * PT_R5, 0); |
| 45 | + regs.orig_gpr3 = ptrace(PTRACE_PEEKUSER, pid, UINTPTR_MAX/8 * PT_ORIG_R3, 0); |
| 46 | #elif defined(ARM) |
| 47 | struct pt_regs regs; |
| 48 | ptrace(PTRACE_GETREGS, pid, 0, ®s); |
| 49 | -- |
| 50 | 1.9.1 |
| 51 | |