Android.patch revision 3b98d134e310bb1cf5d549a1eb8a34d66831b9a5
1diff -r -u -d /Users/jeffbrown/Downloads/strace-4.6/bjm.c ./bjm.c
2--- /Users/jeffbrown/Downloads/strace-4.6/bjm.c	2009-11-06 09:27:46.000000000 -0800
3+++ ./bjm.c	2012-03-02 15:17:11.000000000 -0800
4@@ -39,7 +39,9 @@
5 #include <sys/wait.h>
6 #include <sys/resource.h>
7 #include <sys/utsname.h>
8+#ifndef HAVE_ANDROID_OS
9 #include <sys/user.h>
10+#endif
11 #include <sys/syscall.h>
12 #include <signal.h>
13 
14diff -r -u -d /Users/jeffbrown/Downloads/strace-4.6/file.c ./file.c
15--- /Users/jeffbrown/Downloads/strace-4.6/file.c	2011-03-03 18:08:02.000000000 -0800
16+++ ./file.c	2012-03-02 15:11:14.000000000 -0800
17@@ -45,6 +45,41 @@
18 # define kernel_dirent dirent
19 #endif
20 
21+#ifdef HAVE_ANDROID_OS
22+#include <linux/fadvise.h>
23+
24+// ANDROID: From linux/dirent.h
25+
26+struct dirent64 {
27+ __u64 d_ino;
28+ __s64 d_off;
29+ unsigned short d_reclen;
30+ unsigned char d_type;
31+ char d_name[256];
32+};
33+
34+// ANDROID: From kernel_headers/asm/statfs.h
35+
36+/*
37+ * With EABI there is 4 bytes of padding added to this structure.
38+ * Let's pack it so the padding goes away to simplify dual ABI support.
39+ * Note that user space does NOT have to pack this structure.
40+ */
41+struct statfs64 {
42+        __u32 f_type;
43+        __u32 f_bsize;
44+        __u64 f_blocks;
45+        __u64 f_bfree;
46+        __u64 f_bavail;
47+        __u64 f_files;
48+        __u64 f_ffree;
49+        __kernel_fsid_t f_fsid;
50+        __u32 f_namelen;
51+        __u32 f_frsize;
52+        __u32 f_spare[5];
53+} __attribute__ ((packed,aligned(4)));
54+#endif /* HAVE_ANDROID_OS */
55+
56 #ifdef LINUX
57 #  ifdef LINUXSPARC
58 struct stat {
59diff -r -u -d /Users/jeffbrown/Downloads/strace-4.6/ioctl.c ./ioctl.c
60--- /Users/jeffbrown/Downloads/strace-4.6/ioctl.c	2011-01-15 12:15:31.000000000 -0800
61+++ ./ioctl.c	2012-03-02 15:53:36.000000000 -0800
62@@ -155,9 +155,11 @@
63 	case 0x03:
64 	case 0x12:
65 		return block_ioctl(tcp, code, arg);
66+#ifndef HAVE_ANDROID_OS
67 	case 0x22:
68 		return scsi_ioctl(tcp, code, arg);
69 #endif
70+#endif
71 	default:
72 		break;
73 	}
74diff -r -u -d /Users/jeffbrown/Downloads/strace-4.6/ipc.c ./ipc.c
75--- /Users/jeffbrown/Downloads/strace-4.6/ipc.c	2010-03-31 15:22:01.000000000 -0700
76+++ ./ipc.c	2012-03-02 16:12:52.000000000 -0800
77@@ -40,9 +40,15 @@
78 
79 #include <fcntl.h>
80 #include <sys/ipc.h>
81+#ifdef HAVE_ANDROID_OS
82+#include <linux/sem.h>
83+#include <linux/msg.h>
84+#include <linux/shm.h>
85+#else
86 #include <sys/sem.h>
87 #include <sys/msg.h>
88 #include <sys/shm.h>
89+#endif
90 
91 #ifndef MSG_STAT
92 #define MSG_STAT 11
93diff -r -u -d /Users/jeffbrown/Downloads/strace-4.6/process.c ./process.c
94--- /Users/jeffbrown/Downloads/strace-4.6/process.c	2011-03-14 14:58:59.000000000 -0700
95+++ ./process.c	2012-03-02 15:16:28.000000000 -0800
96@@ -45,7 +45,11 @@
97 #include <sys/wait.h>
98 #include <sys/resource.h>
99 #include <sys/utsname.h>
100+#ifdef HAVE_ANDROID_OS
101+#include <asm/user.h>
102+#else
103 #include <sys/user.h>
104+#endif
105 #include <sys/syscall.h>
106 #include <signal.h>
107 #ifdef SUNOS4
108@@ -114,6 +118,10 @@
109 #define GETGROUPS32_T __kernel_gid32_t
110 #endif /* LINUX */
111 
112+#ifdef HAVE_ANDROID_OS
113+#define __sched_priority sched_priority
114+#endif
115+
116 #if defined(LINUX) && defined(IA64)
117 # include <asm/ptrace_offsets.h>
118 # include <asm/rse.h>
119diff -r -u -d /Users/jeffbrown/Downloads/strace-4.6/signal.c ./signal.c
120--- /Users/jeffbrown/Downloads/strace-4.6/signal.c	2011-03-10 15:14:47.000000000 -0800
121+++ ./signal.c	2012-03-02 15:22:07.000000000 -0800
122@@ -37,9 +37,17 @@
123 
124 #include <stdint.h>
125 #include <signal.h>
126+#ifndef HAVE_ANDROID_OS
127 #include <sys/user.h>
128+#endif
129 #include <fcntl.h>
130 
131+#ifdef HAVE_ANDROID_OS
132+//FIXME use "sigprocmask" or something
133+#define sigmask(sig)    (1UL << ((sig) - 1))
134+#define sigcontext_struct sigcontext
135+#endif
136+
137 #ifdef SVR4
138 #include <sys/ucontext.h>
139 #endif /* SVR4 */
140@@ -455,7 +463,7 @@
141 
142 #endif /* LINUX */
143 
144-#if __GLIBC_MINOR__ < 1
145+#if __GLIBC_MINOR__ < 1 && !defined(HAVE_ANDROID_OS)
146 /* Type for data associated with a signal.  */
147 typedef union sigval
148 {
149diff -r -u -d /Users/jeffbrown/Downloads/strace-4.6/syscall.c ./syscall.c
150--- /Users/jeffbrown/Downloads/strace-4.6/syscall.c	2011-02-18 16:02:27.000000000 -0800
151+++ ./syscall.c	2012-03-02 15:00:35.000000000 -0800
152@@ -38,10 +38,16 @@
153 #include <signal.h>
154 #include <time.h>
155 #include <errno.h>
156+#ifndef HAVE_ANDROID_OS
157 #include <sys/user.h>
158+#endif
159 #include <sys/syscall.h>
160 #include <sys/param.h>
161 
162+#ifdef HAVE_ANDROID_OS
163+#include "syscall-android.h"
164+#endif
165+
166 #ifdef HAVE_SYS_REG_H
167 #include <sys/reg.h>
168 #ifndef PTRACE_PEEKUSR
169@@ -2600,6 +2606,7 @@
170 	}
171 
172 	switch (known_scno(tcp)) {
173+#ifndef __ARM_EABI__
174 #ifdef SYS_socket_subcall
175 	case SYS_socketcall:
176 		decode_subcall(tcp, SYS_socket_subcall,
177@@ -2612,6 +2619,7 @@
178 			SYS_ipc_nsubcalls, shift_style);
179 		break;
180 #endif
181+#endif
182 #ifdef SVR4
183 #ifdef SYS_pgrpsys_subcall
184 	case SYS_pgrpsys:
185diff -r -u -d /Users/jeffbrown/Downloads/strace-4.6/system.c ./system.c
186--- /Users/jeffbrown/Downloads/strace-4.6/system.c	2011-02-22 02:22:13.000000000 -0800
187+++ ./system.c	2012-03-02 15:50:24.000000000 -0800
188@@ -32,6 +32,11 @@
189 
190 #include "defs.h"
191 
192+#ifdef HAVE_ANDROID_OS
193+#undef __unused
194+#include <linux/socket.h>
195+#endif
196+
197 #ifdef LINUX
198 #define _LINUX_SOCKET_H
199 #define _LINUX_FS_H
200diff -r -u -d /Users/jeffbrown/Downloads/strace-4.6/time.c ./time.c
201--- /Users/jeffbrown/Downloads/strace-4.6/time.c	2011-03-03 18:08:02.000000000 -0800
202+++ ./time.c	2012-03-02 15:23:05.000000000 -0800
203@@ -33,7 +33,11 @@
204 
205 #ifdef LINUX
206 #include <linux/version.h>
207+#ifdef HAVE_ANDROID_OS
208+#include <linux/timex.h>
209+#else
210 #include <sys/timex.h>
211+#endif
212 #include <linux/ioctl.h>
213 #include <linux/rtc.h>
214 
215diff -r -u -d /Users/jeffbrown/Downloads/strace-4.6/util.c ./util.c
216--- /Users/jeffbrown/Downloads/strace-4.6/util.c	2011-03-03 18:08:02.000000000 -0800
217+++ ./util.c	2012-03-02 15:01:45.000000000 -0800
218@@ -37,7 +37,9 @@
219 
220 #include <signal.h>
221 #include <sys/syscall.h>
222+#ifndef HAVE_ANDROID_OS
223 #include <sys/user.h>
224+#endif
225 #include <sys/param.h>
226 #include <fcntl.h>
227 #if HAVE_SYS_UIO_H
228@@ -49,6 +51,10 @@
229 #include <link.h>
230 #endif /* SUNOS4 */
231 
232+#ifdef HAVE_ANDROID_OS
233+#include "syscall-android.h"
234+#endif
235+
236 #if defined(linux) && (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1))
237 #include <linux/ptrace.h>
238 #endif
239