1:
2:
3:
4:
5:
6:
7: #include "syscall_nr.h"
8:
9: #define SOCKOP_socket 1
10: #define SOCKOP_bind 2
11: #define SOCKOP_connect 3
12: #define SOCKOP_listen 4
13: #define SOCKOP_accept 5
14: #define SOCKOP_getsockname 6
15: #define SOCKOP_getpeername 7
16: #define SOCKOP_socketpair 8
17: #define SOCKOP_send 9
18: #define SOCKOP_recv 10
19: #define SOCKOP_sendto 11
20: #define SOCKOP_recvfrom 12
21: #define SOCKOP_shutdown 13
22: #define SOCKOP_setsockopt 14
23: #define SOCKOP_getsockopt 15
24: #define SOCKOP_sendmsg 16
25: #define SOCKOP_recvmsg 17
26:
27: #define IPCOP_semop 1
28: #define IPCOP_semget 2
29: #define IPCOP_semctl 3
30: #define IPCOP_semtimedop 4
31: #define IPCOP_msgsnd 11
32: #define IPCOP_msgrcv 12
33: #define IPCOP_msgget 13
34: #define IPCOP_msgctl 14
35: #define IPCOP_shmat 21
36: #define IPCOP_shmdt 22
37: #define IPCOP_shmget 23
38: #define IPCOP_shmctl 24
39:
40:
41:
42:
43:
44:
45:
46:
47:
48: #define TARGET_IOC_NRBITS 8
49: #define TARGET_IOC_TYPEBITS 8
50:
51: #if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SH4) \
52: || defined(TARGET_M68K) || defined(TARGET_ALPHA) || defined(TARGET_CRIS)
53:
54: #define TARGET_IOC_SIZEBITS 14
55: #define TARGET_IOC_DIRBITS 2
56:
57: #define TARGET_IOC_NONE 0U
58: #define TARGET_IOC_WRITE 1U
59: #define TARGET_IOC_READ 2U
60:
61: #elif defined(TARGET_PPC) || defined(TARGET_ALPHA) || \
62: defined(TARGET_SPARC) || defined(TARGET_MIPS)
63:
64: #define TARGET_IOC_SIZEBITS 13
65: #define TARGET_IOC_DIRBITS 3
66:
67: #define TARGET_IOC_NONE 1U
68: #define TARGET_IOC_READ 2U
69: #define TARGET_IOC_WRITE 4U
70:
71: #else
72: #error unsupported CPU
73: #endif
74:
75: #define TARGET_IOC_NRMASK ((1 << TARGET_IOC_NRBITS)-1)
76: #define TARGET_IOC_TYPEMASK ((1 << TARGET_IOC_TYPEBITS)-1)
77: #define TARGET_IOC_SIZEMASK ((1 << TARGET_IOC_SIZEBITS)-1)
78: #define TARGET_IOC_DIRMASK ((1 << TARGET_IOC_DIRBITS)-1)
79:
80: #define TARGET_IOC_NRSHIFT 0
81: #define TARGET_IOC_TYPESHIFT (TARGET_IOC_NRSHIFT+TARGET_IOC_NRBITS)
82: #define TARGET_IOC_SIZESHIFT (TARGET_IOC_TYPESHIFT+TARGET_IOC_TYPEBITS)
83: #define TARGET_IOC_DIRSHIFT (TARGET_IOC_SIZESHIFT+TARGET_IOC_SIZEBITS)
84:
85: #define TARGET_IOC(dir,type,nr,size) \
86: (((dir) << TARGET_IOC_DIRSHIFT) | \
87: ((type) << TARGET_IOC_TYPESHIFT) | \
88: ((nr) << TARGET_IOC_NRSHIFT) | \
89: ((size) << TARGET_IOC_SIZESHIFT))
90:
91:
92: #define TARGET_IO(type,nr) TARGET_IOC(TARGET_IOC_NONE,(type),(nr),0)
93: #define TARGET_IOR(type,nr,size) TARGET_IOC(TARGET_IOC_READ,(type),(nr),sizeof(size))
94: #define TARGET_IOW(type,nr,size) TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),sizeof(size))
95: #define TARGET_IOWR(type,nr,size) TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),sizeof(size))
96:
97:
98: #define TARGET_IORU(type,nr) TARGET_IOC(TARGET_IOC_READ,(type),(nr),TARGET_IOC_SIZEMASK)
99: #define TARGET_IOWU(type,nr) TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
100: #define TARGET_IOWRU(type,nr) TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
101:
102: struct target_sockaddr {
103: uint16_t sa_family;
104: uint8_t sa_data[14];
105: };
106:
107: struct target_timeval {
108: abi_long tv_sec;
109: abi_long tv_usec;
110: };
111:
112: struct target_timespec {
113: abi_long tv_sec;
114: abi_long tv_nsec;
115: };
116:
117: struct target_itimerval {
118: struct target_timeval it_interval;
119: struct target_timeval it_value;
120: };
121:
122: typedef abi_long target_clock_t;
123:
124: #define TARGET_HZ 100
125:
126: struct target_tms {
127: target_clock_t tms_utime;
128: target_clock_t tms_stime;
129: target_clock_t tms_cutime;
130: target_clock_t tms_cstime;
131: };
132:
133: struct target_utimbuf {
134: abi_long actime;
135: abi_long modtime;
136: };
137:
138: struct target_sel_arg_struct {
139: abi_long n;
140: abi_long inp, outp, exp;
141: abi_long tvp;
142: };
143:
144: struct target_iovec {
145: abi_long iov_base;
146: abi_long iov_len;
147: };
148:
149: struct target_msghdr {
150: abi_long msg_name;
151: int msg_namelen;
152: abi_long msg_iov;
153: abi_long msg_iovlen;
154: abi_long msg_control;
155: abi_long msg_controllen;
156: unsigned int msg_flags;
157: };
158:
159: struct target_cmsghdr {
160: abi_long cmsg_len;
161: int cmsg_level;
162: int cmsg_type;
163: };
164:
165: #define TARGET_CMSG_DATA(cmsg) ((unsigned char *) ((struct target_cmsghdr *) (cmsg) + 1))
166: #define TARGET_CMSG_NXTHDR(mhdr, cmsg) __target_cmsg_nxthdr (mhdr, cmsg)
167: #define TARGET_CMSG_ALIGN(len) (((len) + sizeof (abi_long) - 1) \
168: & (size_t) ~(sizeof (abi_long) - 1))
169: #define TARGET_CMSG_SPACE(len) (TARGET_CMSG_ALIGN (len) \
170: + TARGET_CMSG_ALIGN (sizeof (struct target_cmsghdr)))
171: #define TARGET_CMSG_LEN(len) (TARGET_CMSG_ALIGN (sizeof (struct target_cmsghdr)) + (len))
172:
173: static __inline__ struct target_cmsghdr *
174: __target_cmsg_nxthdr (struct target_msghdr *__mhdr, struct target_cmsghdr *__cmsg)
175: {
176: struct target_cmsghdr *__ptr;
177:
178: __ptr = (struct target_cmsghdr *)((unsigned char *) __cmsg
179: + TARGET_CMSG_ALIGN (tswapl(__cmsg->cmsg_len)));
180: if ((unsigned long)((char *)(__ptr+1) - (char *)(size_t)tswapl(__mhdr->msg_control))
181: > tswapl(__mhdr->msg_controllen))
182:
183: return (struct target_cmsghdr *)0;
184: return __cmsg;
185: }
186:
187:
188: struct target_rusage {
189: struct target_timeval ru_utime;
190: struct target_timeval ru_stime;
191: abi_long ru_maxrss;
192: abi_long ru_ixrss;
193: abi_long ru_idrss;
194: abi_long ru_isrss;
195: abi_long ru_minflt;
196: abi_long ru_majflt;
197: abi_long ru_nswap;
198: abi_long ru_inblock;
199: abi_long ru_oublock;
200: abi_long ru_msgsnd;
201: abi_long ru_msgrcv;
202: abi_long ru_nsignals;
203: abi_long ru_nvcsw;
204: abi_long ru_nivcsw;
205: };
206:
207: typedef struct {
208: int val[2];
209: } kernel_fsid_t;
210:
211: struct kernel_statfs {
212: int f_type;
213: int f_bsize;
214: int f_blocks;
215: int f_bfree;
216: int f_bavail;
217: int f_files;
218: int f_ffree;
219: kernel_fsid_t f_fsid;
220: int f_namelen;
221: int f_spare[6];
222: };
223:
224: struct target_dirent {
225: abi_long d_ino;
226: abi_long d_off;
227: unsigned short d_reclen;
228: char d_name[256];
229: };
230:
231: struct target_dirent64 {
232: uint64_t d_ino;
233: int64_t d_off;
234: unsigned short d_reclen;
235: unsigned char d_type;
236: char d_name[256];
237: };
238:
239:
240:
241: #define TARGET_SIG_DFL ((abi_long)0)
242: #define TARGET_SIG_IGN ((abi_long)1)
243: #define TARGET_SIG_ERR ((abi_long)-1)
244:
245: #ifdef TARGET_MIPS
246: #define TARGET_NSIG 128
247: #else
248: #define TARGET_NSIG 64
249: #endif
250: #define TARGET_NSIG_BPW TARGET_ABI_BITS
251: #define TARGET_NSIG_WORDS (TARGET_NSIG / TARGET_NSIG_BPW)
252:
253: typedef struct {
254: abi_ulong sig[TARGET_NSIG_WORDS];
255: } target_sigset_t;
256:
257: #ifdef BSWAP_NEEDED
258: static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
259: {
260: int i;
261: for(i = 0;i < TARGET_NSIG_WORDS; i++)
262: d->sig[i] = tswapl(s->sig[i]);
263: }
264: #else
265: static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
266: {
267: *d = *s;
268: }
269: #endif
270:
271: static inline void target_siginitset(target_sigset_t *d, abi_ulong set)
272: {
273: int i;
274: d->sig[0] = set;
275: for(i = 1;i < TARGET_NSIG_WORDS; i++)
276: d->sig[i] = 0;
277: }
278:
279: void host_to_target_sigset(target_sigset_t *d, const sigset_t *s);
280: void target_to_host_sigset(sigset_t *d, const target_sigset_t *s);
281: void host_to_target_old_sigset(abi_ulong *old_sigset,
282: const sigset_t *sigset);
283: void target_to_host_old_sigset(sigset_t *sigset,
284: const abi_ulong *old_sigset);
285: struct target_sigaction;
286: int do_sigaction(int sig, const struct target_sigaction *act,
287: struct target_sigaction *oact);
288:
289: #if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) || defined(TARGET_PPC) || defined(TARGET_MIPS) || defined (TARGET_SH4) || defined(TARGET_M68K) || defined(TARGET_ALPHA) || defined(TARGET_CRIS)
290:
291: #if defined(TARGET_SPARC)
292: #define TARGET_SA_NOCLDSTOP 8u
293: #define TARGET_SA_NOCLDWAIT 0x100u
294: #define TARGET_SA_SIGINFO 0x200u
295: #define TARGET_SA_ONSTACK 1u
296: #define TARGET_SA_RESTART 2u
297: #define TARGET_SA_NODEFER 0x20u
298: #define TARGET_SA_RESETHAND 4u
299: #elif defined(TARGET_MIPS)
300: #define TARGET_SA_NOCLDSTOP 0x00000001
301: #define TARGET_SA_NOCLDWAIT 0x00010000
302: #define TARGET_SA_SIGINFO 0x00000008
303: #define TARGET_SA_ONSTACK 0x08000000
304: #define TARGET_SA_NODEFER 0x40000000
305: #define TARGET_SA_RESTART 0x10000000
306: #define TARGET_SA_RESETHAND 0x80000000
307: #if !defined(TARGET_ABI_MIPSN32) && !defined(TARGET_ABI_MIPSN64)
308: #define TARGET_SA_RESTORER 0x04000000
309: #endif
310: #else
311: #define TARGET_SA_NOCLDSTOP 0x00000001
312: #define TARGET_SA_NOCLDWAIT 0x00000002
313: #define TARGET_SA_SIGINFO 0x00000004
314: #define TARGET_SA_ONSTACK 0x08000000
315: #define TARGET_SA_RESTART 0x10000000
316: #define TARGET_SA_NODEFER 0x40000000
317: #define TARGET_SA_RESETHAND 0x80000000
318: #define TARGET_SA_RESTORER 0x04000000
319: #endif
320:
321: #if defined(TARGET_SPARC)
322:
323: #define TARGET_SIGHUP 1
324: #define TARGET_SIGINT 2
325: #define TARGET_SIGQUIT 3
326: #define TARGET_SIGILL 4
327: #define TARGET_SIGTRAP 5
328: #define TARGET_SIGABRT 6
329: #define TARGET_SIGIOT 6
330: #define TARGET_SIGSTKFLT 7
331: #define TARGET_SIGFPE 8
332: #define TARGET_SIGKILL 9
333: #define TARGET_SIGBUS 10
334: #define TARGET_SIGSEGV 11
335: #define TARGET_SIGSYS 12
336: #define TARGET_SIGPIPE 13
337: #define TARGET_SIGALRM 14
338: #define TARGET_SIGTERM 15
339: #define TARGET_SIGURG 16
340: #define TARGET_SIGSTOP 17
341: #define TARGET_SIGTSTP 18
342: #define TARGET_SIGCONT 19
343: #define TARGET_SIGCHLD 20
344: #define TARGET_SIGTTIN 21
345: #define TARGET_SIGTTOU 22
346: #define TARGET_SIGIO 23
347: #define TARGET_SIGXCPU 24
348: #define TARGET_SIGXFSZ 25
349: #define TARGET_SIGVTALRM 26
350: #define TARGET_SIGPROF 27
351: #define TARGET_SIGWINCH 28
352: #define TARGET_SIGPWR 29
353: #define TARGET_SIGUSR1 30
354: #define TARGET_SIGUSR2 31
355: #define TARGET_SIGRTMIN 32
356:
357: #define TARGET_SIG_BLOCK 0x01
358: #define TARGET_SIG_UNBLOCK 0x02
359: #define TARGET_SIG_SETMASK 0x04
360:
361: #elif defined(TARGET_MIPS)
362:
363: #define TARGET_SIGHUP 1
364: #define TARGET_SIGINT 2
365: #define TARGET_SIGQUIT 3
366: #define TARGET_SIGILL 4
367: #define TARGET_SIGTRAP 5
368: #define TARGET_SIGIOT 6
369: #define TARGET_SIGABRT TARGET_SIGIOT
370: #define TARGET_SIGEMT 7
371: #define TARGET_SIGSTKFLT 7
372: #define TARGET_SIGFPE 8
373: #define TARGET_SIGKILL 9
374: #define TARGET_SIGBUS 10
375: #define TARGET_SIGSEGV 11
376: #define TARGET_SIGSYS 12
377: #define TARGET_SIGPIPE 13
378: #define TARGET_SIGALRM 14
379: #define TARGET_SIGTERM 15
380: #define TARGET_SIGUSR1 16
381: #define TARGET_SIGUSR2 17
382: #define TARGET_SIGCHLD 18
383: #define TARGET_SIGCLD TARGET_SIGCHLD
384: #define TARGET_SIGPWR 19
385: #define TARGET_SIGWINCH 20
386: #define TARGET_SIGURG 21
387: #define TARGET_SIGIO 22
388: #define TARGET_SIGPOLL TARGET_SIGIO
389: #define TARGET_SIGSTOP 23
390: #define TARGET_SIGTSTP 24
391: #define TARGET_SIGCONT 25
392: #define TARGET_SIGTTIN 26
393: #define TARGET_SIGTTOU 27
394: #define TARGET_SIGVTALRM 28
395: #define TARGET_SIGPROF 29
396: #define TARGET_SIGXCPU 30
397: #define TARGET_SIGXFSZ 31
398: #define TARGET_SIGRTMIN 32
399:
400: #define TARGET_SIG_BLOCK 1
401: #define TARGET_SIG_UNBLOCK 2
402: #define TARGET_SIG_SETMASK 3
403:
404: #else
405:
406: #define TARGET_SIGHUP 1
407: #define TARGET_SIGINT 2
408: #define TARGET_SIGQUIT 3
409: #define TARGET_SIGILL 4
410: #define TARGET_SIGTRAP 5
411: #define TARGET_SIGABRT 6
412: #define TARGET_SIGIOT 6
413: #define TARGET_SIGBUS 7
414: #define TARGET_SIGFPE 8
415: #define TARGET_SIGKILL 9
416: #define TARGET_SIGUSR1 10
417: #define TARGET_SIGSEGV 11
418: #define TARGET_SIGUSR2 12
419: #define TARGET_SIGPIPE 13
420: #define TARGET_SIGALRM 14
421: #define TARGET_SIGTERM 15
422: #define TARGET_SIGSTKFLT 16
423: #define TARGET_SIGCHLD 17
424: #define TARGET_SIGCONT 18
425: #define TARGET_SIGSTOP 19
426: #define TARGET_SIGTSTP 20
427: #define TARGET_SIGTTIN 21
428: #define TARGET_SIGTTOU 22
429: #define TARGET_SIGURG 23
430: #define TARGET_SIGXCPU 24
431: #define TARGET_SIGXFSZ 25
432: #define TARGET_SIGVTALRM 26
433: #define TARGET_SIGPROF 27
434: #define TARGET_SIGWINCH 28
435: #define TARGET_SIGIO 29
436: #define TARGET_SIGPWR 30
437: #define TARGET_SIGSYS 31
438: #define TARGET_SIGRTMIN 32
439:
440: #define TARGET_SIG_BLOCK 0
441: #define TARGET_SIG_UNBLOCK 1
442: #define TARGET_SIG_SETMASK 2
443:
444: #endif
445:
446: #if defined(TARGET_MIPS)
447:
448: struct target_sigaction {
449: uint32_t sa_flags;