blob: ca13bdbd151711cf2fb988cf50f6afe59b7aaedd [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001From 115fcf1daff18aa2f2e130d63704f04031878db0 Mon Sep 17 00:00:00 2001
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05002From: Khem Raj <raj.khem@gmail.com>
3Date: Thu, 24 Mar 2016 15:46:14 +0000
4Subject: [PATCH] Use UINTPTR_MAX instead of __WORDSIZE
5
6Do not include sys/user.h since it conflicts with
7pt_regs struct from kernel APIs in asm/ptrace.h
8
9Signed-off-by: Khem Raj <raj.khem@gmail.com>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050010Upstream-Status: Pending
Brad Bishop19323692019-04-05 15:28:33 -040011---
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050012 src/peekfd.c | 13 ++++++++-----
13 1 file changed, 8 insertions(+), 5 deletions(-)
14
15diff --git a/src/peekfd.c b/src/peekfd.c
Brad Bishop19323692019-04-05 15:28:33 -040016index 5aa990a..7e8e3fc 100644
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050017--- a/src/peekfd.c
18+++ b/src/peekfd.c
19@@ -30,8 +30,11 @@
20 #include <asm/ptrace.h>
21 #include <byteswap.h>
22 #include <endian.h>
23+#ifdef __GLIBC__
24 #include <sys/user.h>
25+#endif
26 #include <stdlib.h>
27+#include <stdint.h>
28 #include <getopt.h>
29 #include <ctype.h>
Brad Bishop19323692019-04-05 15:28:33 -040030 #include <dirent.h>
31@@ -266,11 +269,11 @@ int main(int argc, char **argv)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050032 if (WIFSTOPPED(status)) {
33 #ifdef PPC
34 struct pt_regs regs;
35- regs.gpr[0] = ptrace(PTRACE_PEEKUSER, pid, __WORDSIZE/8 * PT_R0, 0);
36- regs.gpr[3] = ptrace(PTRACE_PEEKUSER, pid, __WORDSIZE/8 * PT_R3, 0);
37- regs.gpr[4] = ptrace(PTRACE_PEEKUSER, pid, __WORDSIZE/8 * PT_R4, 0);
38- regs.gpr[5] = ptrace(PTRACE_PEEKUSER, pid, __WORDSIZE/8 * PT_R5, 0);
39- regs.orig_gpr3 = ptrace(PTRACE_PEEKUSER, pid, __WORDSIZE/8 * PT_ORIG_R3, 0);
40+ regs.gpr[0] = ptrace(PTRACE_PEEKUSER, pid, UINTPTR_MAX/8 * PT_R0, 0);
41+ regs.gpr[3] = ptrace(PTRACE_PEEKUSER, pid, UINTPTR_MAX/8 * PT_R3, 0);
42+ regs.gpr[4] = ptrace(PTRACE_PEEKUSER, pid, UINTPTR_MAX/8 * PT_R4, 0);
43+ regs.gpr[5] = ptrace(PTRACE_PEEKUSER, pid, UINTPTR_MAX/8 * PT_R5, 0);
44+ regs.orig_gpr3 = ptrace(PTRACE_PEEKUSER, pid, UINTPTR_MAX/8 * PT_ORIG_R3, 0);
45 #elif defined(ARM)
46 struct pt_regs regs;
47 ptrace(PTRACE_GETREGS, pid, 0, &regs);