xref: /openbmc/qemu/linux-user/syscall_defs.h (revision 24e1003a524922782bb0290ecceef01676f92c16)
131e31b8aSbellard /* common syscall defines for all architectures */
231e31b8aSbellard 
32521d698Sbellard /* Note: although the syscall numbers change between architectures,
42521d698Sbellard    most of them stay the same, so we handle it by puting ifdefs if
52521d698Sbellard    necessary */
62521d698Sbellard 
76180a181Sbellard #include "syscall_nr.h"
82521d698Sbellard 
931e31b8aSbellard #define SOCKOP_socket           1
1031e31b8aSbellard #define SOCKOP_bind             2
1131e31b8aSbellard #define SOCKOP_connect          3
1231e31b8aSbellard #define SOCKOP_listen           4
1331e31b8aSbellard #define SOCKOP_accept           5
1431e31b8aSbellard #define SOCKOP_getsockname      6
1531e31b8aSbellard #define SOCKOP_getpeername      7
1631e31b8aSbellard #define SOCKOP_socketpair       8
1731e31b8aSbellard #define SOCKOP_send             9
1831e31b8aSbellard #define SOCKOP_recv             10
1931e31b8aSbellard #define SOCKOP_sendto           11
2031e31b8aSbellard #define SOCKOP_recvfrom         12
2131e31b8aSbellard #define SOCKOP_shutdown         13
2231e31b8aSbellard #define SOCKOP_setsockopt       14
2331e31b8aSbellard #define SOCKOP_getsockopt       15
2431e31b8aSbellard #define SOCKOP_sendmsg          16
2531e31b8aSbellard #define SOCKOP_recvmsg          17
2631e31b8aSbellard 
278853f86eSbellard #define IPCOP_semop		1
288853f86eSbellard #define IPCOP_semget		2
298853f86eSbellard #define IPCOP_semctl		3
308853f86eSbellard #define IPCOP_semtimedop	4
318853f86eSbellard #define IPCOP_msgsnd		11
328853f86eSbellard #define IPCOP_msgrcv		12
338853f86eSbellard #define IPCOP_msgget		13
348853f86eSbellard #define IPCOP_msgctl		14
358853f86eSbellard #define IPCOP_shmat		21
368853f86eSbellard #define IPCOP_shmdt		22
378853f86eSbellard #define IPCOP_shmget		23
388853f86eSbellard #define IPCOP_shmctl		24
398853f86eSbellard 
402521d698Sbellard /*
412521d698Sbellard  * The following is for compatibility across the various Linux
422521d698Sbellard  * platforms.  The i386 ioctl numbering scheme doesn't really enforce
432521d698Sbellard  * a type field.  De facto, however, the top 8 bits of the lower 16
442521d698Sbellard  * bits are indeed used as a type field, so we might just as well make
452521d698Sbellard  * this explicit here.  Please be sure to use the decoding macros
462521d698Sbellard  * below from now on.
472521d698Sbellard  */
482521d698Sbellard #define TARGET_IOC_NRBITS	8
492521d698Sbellard #define TARGET_IOC_TYPEBITS	8
502521d698Sbellard 
51e6e5906bSpbrook #if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SH4) \
52dccfec67Saurel32     || defined(TARGET_M68K) || defined(TARGET_CRIS)
532521d698Sbellard 
542521d698Sbellard #define TARGET_IOC_SIZEBITS	14
552521d698Sbellard #define TARGET_IOC_DIRBITS	2
562521d698Sbellard 
572521d698Sbellard #define TARGET_IOC_NONE	  0U
582521d698Sbellard #define TARGET_IOC_WRITE  1U
592521d698Sbellard #define TARGET_IOC_READ	  2U
602521d698Sbellard 
61048f6b4dSbellard #elif defined(TARGET_PPC) || defined(TARGET_ALPHA) || \
62048f6b4dSbellard       defined(TARGET_SPARC) || defined(TARGET_MIPS)
632521d698Sbellard 
642521d698Sbellard #define TARGET_IOC_SIZEBITS	13
652521d698Sbellard #define TARGET_IOC_DIRBITS	3
662521d698Sbellard 
672521d698Sbellard #define TARGET_IOC_NONE	  1U
682521d698Sbellard #define TARGET_IOC_READ	  2U
692521d698Sbellard #define TARGET_IOC_WRITE  4U
702521d698Sbellard 
712521d698Sbellard #else
722521d698Sbellard #error unsupported CPU
732521d698Sbellard #endif
742521d698Sbellard 
752521d698Sbellard #define TARGET_IOC_NRMASK	((1 << TARGET_IOC_NRBITS)-1)
762521d698Sbellard #define TARGET_IOC_TYPEMASK	((1 << TARGET_IOC_TYPEBITS)-1)
772521d698Sbellard #define TARGET_IOC_SIZEMASK	((1 << TARGET_IOC_SIZEBITS)-1)
782521d698Sbellard #define TARGET_IOC_DIRMASK	((1 << TARGET_IOC_DIRBITS)-1)
792521d698Sbellard 
802521d698Sbellard #define TARGET_IOC_NRSHIFT	0
812521d698Sbellard #define TARGET_IOC_TYPESHIFT	(TARGET_IOC_NRSHIFT+TARGET_IOC_NRBITS)
822521d698Sbellard #define TARGET_IOC_SIZESHIFT	(TARGET_IOC_TYPESHIFT+TARGET_IOC_TYPEBITS)
832521d698Sbellard #define TARGET_IOC_DIRSHIFT	(TARGET_IOC_SIZESHIFT+TARGET_IOC_SIZEBITS)
842521d698Sbellard 
852521d698Sbellard #define TARGET_IOC(dir,type,nr,size) \
862521d698Sbellard 	(((dir)  << TARGET_IOC_DIRSHIFT) | \
872521d698Sbellard 	 ((type) << TARGET_IOC_TYPESHIFT) | \
882521d698Sbellard 	 ((nr)   << TARGET_IOC_NRSHIFT) | \
892521d698Sbellard 	 ((size) << TARGET_IOC_SIZESHIFT))
902521d698Sbellard 
912521d698Sbellard /* used to create numbers */
922521d698Sbellard #define TARGET_IO(type,nr)		TARGET_IOC(TARGET_IOC_NONE,(type),(nr),0)
932521d698Sbellard #define TARGET_IOR(type,nr,size)	TARGET_IOC(TARGET_IOC_READ,(type),(nr),sizeof(size))
942521d698Sbellard #define TARGET_IOW(type,nr,size)	TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),sizeof(size))
952521d698Sbellard #define TARGET_IOWR(type,nr,size)	TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),sizeof(size))
962521d698Sbellard 
972521d698Sbellard /* the size is automatically computed for these defines */
982521d698Sbellard #define TARGET_IORU(type,nr)	TARGET_IOC(TARGET_IOC_READ,(type),(nr),TARGET_IOC_SIZEMASK)
992521d698Sbellard #define TARGET_IOWU(type,nr)	TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
1002521d698Sbellard #define TARGET_IOWRU(type,nr)	TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
1012521d698Sbellard 
1027854b056Sbellard struct target_sockaddr {
1037854b056Sbellard     uint16_t sa_family;
1047854b056Sbellard     uint8_t sa_data[14];
1057854b056Sbellard };
1067854b056Sbellard 
10731e31b8aSbellard struct target_timeval {
108992f48a0Sblueswir1     abi_long tv_sec;
109992f48a0Sblueswir1     abi_long tv_usec;
11031e31b8aSbellard };
11131e31b8aSbellard 
1121b6b029eSbellard struct target_timespec {
113992f48a0Sblueswir1     abi_long tv_sec;
114992f48a0Sblueswir1     abi_long tv_nsec;
1151b6b029eSbellard };
1161b6b029eSbellard 
11766fb9763Sbellard struct target_itimerval {
11866fb9763Sbellard     struct target_timeval it_interval;
11966fb9763Sbellard     struct target_timeval it_value;
12066fb9763Sbellard };
12166fb9763Sbellard 
122992f48a0Sblueswir1 typedef abi_long target_clock_t;
12332f36bceSbellard 
124c596ed17Sbellard #define TARGET_HZ 100
125c596ed17Sbellard 
12632f36bceSbellard struct target_tms {
12732f36bceSbellard     target_clock_t tms_utime;
12832f36bceSbellard     target_clock_t tms_stime;
12932f36bceSbellard     target_clock_t tms_cutime;
13032f36bceSbellard     target_clock_t tms_cstime;
13132f36bceSbellard };
13232f36bceSbellard 
1336180a181Sbellard struct target_utimbuf {
134992f48a0Sblueswir1     abi_long actime;
135992f48a0Sblueswir1     abi_long modtime;
1366180a181Sbellard };
1376180a181Sbellard 
138f2674e31Sbellard struct target_sel_arg_struct {
139992f48a0Sblueswir1     abi_long n;
140992f48a0Sblueswir1     abi_long inp, outp, exp;
141992f48a0Sblueswir1     abi_long tvp;
142f2674e31Sbellard };
143f2674e31Sbellard 
14431e31b8aSbellard struct target_iovec {
145992f48a0Sblueswir1     abi_long iov_base;   /* Starting address */
146992f48a0Sblueswir1     abi_long iov_len;   /* Number of bytes */
14731e31b8aSbellard };
14831e31b8aSbellard 
1491a9353d2Sbellard struct target_msghdr {
150992f48a0Sblueswir1     abi_long	 msg_name;	 /* Socket name			*/
1511a9353d2Sbellard     int		 msg_namelen;	 /* Length of name		*/
152992f48a0Sblueswir1     abi_long	 msg_iov;	 /* Data blocks			*/
153992f48a0Sblueswir1     abi_long	 msg_iovlen;	 /* Number of blocks		*/
154992f48a0Sblueswir1     abi_long     msg_control;	 /* Per protocol magic (eg BSD file descriptor passing) */
155992f48a0Sblueswir1     abi_long	 msg_controllen; /* Length of cmsg list */
1561a9353d2Sbellard     unsigned int msg_flags;
1571a9353d2Sbellard };
1581a9353d2Sbellard 
1597854b056Sbellard struct target_cmsghdr {
160992f48a0Sblueswir1     abi_long     cmsg_len;
1617854b056Sbellard     int          cmsg_level;
1627854b056Sbellard     int          cmsg_type;
1637854b056Sbellard };
1647854b056Sbellard 
1657854b056Sbellard #define TARGET_CMSG_DATA(cmsg) ((unsigned char *) ((struct target_cmsghdr *) (cmsg) + 1))
1667854b056Sbellard #define TARGET_CMSG_NXTHDR(mhdr, cmsg) __target_cmsg_nxthdr (mhdr, cmsg)
167992f48a0Sblueswir1 #define TARGET_CMSG_ALIGN(len) (((len) + sizeof (abi_long) - 1) \
168992f48a0Sblueswir1                                & (size_t) ~(sizeof (abi_long) - 1))
1697854b056Sbellard #define TARGET_CMSG_SPACE(len) (TARGET_CMSG_ALIGN (len) \
1707854b056Sbellard                                + TARGET_CMSG_ALIGN (sizeof (struct target_cmsghdr)))
1717854b056Sbellard #define TARGET_CMSG_LEN(len)   (TARGET_CMSG_ALIGN (sizeof (struct target_cmsghdr)) + (len))
1727854b056Sbellard 
1737854b056Sbellard static __inline__ struct target_cmsghdr *
1747854b056Sbellard __target_cmsg_nxthdr (struct target_msghdr *__mhdr, struct target_cmsghdr *__cmsg)
1757854b056Sbellard {
1762b8bdefcSths   struct target_cmsghdr *__ptr;
1777854b056Sbellard 
1782b8bdefcSths   __ptr = (struct target_cmsghdr *)((unsigned char *) __cmsg
1797854b056Sbellard                                     + TARGET_CMSG_ALIGN (tswapl(__cmsg->cmsg_len)));
1802b8bdefcSths   if ((unsigned long)((char *)(__ptr+1) - (char *)(size_t)tswapl(__mhdr->msg_control))
1812b8bdefcSths       > tswapl(__mhdr->msg_controllen))
1827854b056Sbellard     /* No more entries.  */
1832b8bdefcSths     return (struct target_cmsghdr *)0;
1847854b056Sbellard   return __cmsg;
1857854b056Sbellard }
1867854b056Sbellard 
1877854b056Sbellard 
18831e31b8aSbellard struct  target_rusage {
18931e31b8aSbellard         struct target_timeval ru_utime;        /* user time used */
19031e31b8aSbellard         struct target_timeval ru_stime;        /* system time used */
191992f48a0Sblueswir1         abi_long    ru_maxrss;                 /* maximum resident set size */
192992f48a0Sblueswir1         abi_long    ru_ixrss;                  /* integral shared memory size */
193992f48a0Sblueswir1         abi_long    ru_idrss;                  /* integral unshared data size */
194992f48a0Sblueswir1         abi_long    ru_isrss;                  /* integral unshared stack size */
195992f48a0Sblueswir1         abi_long    ru_minflt;                 /* page reclaims */
196992f48a0Sblueswir1         abi_long    ru_majflt;                 /* page faults */
197992f48a0Sblueswir1         abi_long    ru_nswap;                  /* swaps */
198992f48a0Sblueswir1         abi_long    ru_inblock;                /* block input operations */
199992f48a0Sblueswir1         abi_long    ru_oublock;                /* block output operations */
200992f48a0Sblueswir1         abi_long    ru_msgsnd;                 /* messages sent */
201992f48a0Sblueswir1         abi_long    ru_msgrcv;                 /* messages received */
202992f48a0Sblueswir1         abi_long    ru_nsignals;               /* signals received */
203992f48a0Sblueswir1         abi_long    ru_nvcsw;                  /* voluntary context switches */
204992f48a0Sblueswir1         abi_long    ru_nivcsw;                 /* involuntary " */
20531e31b8aSbellard };
20631e31b8aSbellard 
20731e31b8aSbellard typedef struct {
20831e31b8aSbellard         int     val[2];
20931e31b8aSbellard } kernel_fsid_t;
21031e31b8aSbellard 
21172f03900Sbellard struct kernel_statfs {
21231e31b8aSbellard 	int f_type;
21331e31b8aSbellard 	int f_bsize;
21431e31b8aSbellard 	int f_blocks;
21531e31b8aSbellard 	int f_bfree;
21631e31b8aSbellard 	int f_bavail;
21731e31b8aSbellard 	int f_files;
21831e31b8aSbellard 	int f_ffree;
21931e31b8aSbellard         kernel_fsid_t f_fsid;
22031e31b8aSbellard 	int f_namelen;
22131e31b8aSbellard 	int f_spare[6];
22231e31b8aSbellard };
22331e31b8aSbellard 
224dab2ed99Sbellard struct target_dirent {
225992f48a0Sblueswir1 	abi_long	d_ino;
226992f48a0Sblueswir1 	abi_long	d_off;
227dab2ed99Sbellard 	unsigned short	d_reclen;
228dab2ed99Sbellard 	char		d_name[256]; /* We must not include limits.h! */
229dab2ed99Sbellard };
230dab2ed99Sbellard 
231dab2ed99Sbellard struct target_dirent64 {
232dab2ed99Sbellard 	uint64_t	d_ino;
233dab2ed99Sbellard 	int64_t		d_off;
234dab2ed99Sbellard 	unsigned short	d_reclen;
235dab2ed99Sbellard 	unsigned char	d_type;
236dab2ed99Sbellard 	char		d_name[256];
237dab2ed99Sbellard };
238dab2ed99Sbellard 
239dab2ed99Sbellard 
24031e31b8aSbellard /* mostly generic signal stuff */
241992f48a0Sblueswir1 #define TARGET_SIG_DFL	((abi_long)0)	/* default signal handling */
242992f48a0Sblueswir1 #define TARGET_SIG_IGN	((abi_long)1)	/* ignore signal */
243992f48a0Sblueswir1 #define TARGET_SIG_ERR	((abi_long)-1)	/* error return from signal */
24431e31b8aSbellard 
24531e31b8aSbellard #ifdef TARGET_MIPS
24631e31b8aSbellard #define TARGET_NSIG	   128
24731e31b8aSbellard #else
24831e31b8aSbellard #define TARGET_NSIG	   64
24931e31b8aSbellard #endif
250992f48a0Sblueswir1 #define TARGET_NSIG_BPW	   TARGET_ABI_BITS
25131e31b8aSbellard #define TARGET_NSIG_WORDS  (TARGET_NSIG / TARGET_NSIG_BPW)
25231e31b8aSbellard 
25331e31b8aSbellard typedef struct {
254992f48a0Sblueswir1     abi_ulong sig[TARGET_NSIG_WORDS];
25531e31b8aSbellard } target_sigset_t;
25631e31b8aSbellard 
25766fb9763Sbellard #ifdef BSWAP_NEEDED
25866fb9763Sbellard static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
25966fb9763Sbellard {
26066fb9763Sbellard     int i;
26166fb9763Sbellard     for(i = 0;i < TARGET_NSIG_WORDS; i++)
26266fb9763Sbellard         d->sig[i] = tswapl(s->sig[i]);
26366fb9763Sbellard }
26466fb9763Sbellard #else
26566fb9763Sbellard static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
26666fb9763Sbellard {
26766fb9763Sbellard     *d = *s;
26866fb9763Sbellard }
26966fb9763Sbellard #endif
27066fb9763Sbellard 
271992f48a0Sblueswir1 static inline void target_siginitset(target_sigset_t *d, abi_ulong set)
27266fb9763Sbellard {
27366fb9763Sbellard     int i;
27466fb9763Sbellard     d->sig[0] = set;
27566fb9763Sbellard     for(i = 1;i < TARGET_NSIG_WORDS; i++)
27666fb9763Sbellard         d->sig[i] = 0;
27766fb9763Sbellard }
27866fb9763Sbellard 
279c596ed17Sbellard void host_to_target_sigset(target_sigset_t *d, const sigset_t *s);
280c596ed17Sbellard void target_to_host_sigset(sigset_t *d, const target_sigset_t *s);
281992f48a0Sblueswir1 void host_to_target_old_sigset(abi_ulong *old_sigset,
28266fb9763Sbellard                                const sigset_t *sigset);
28366fb9763Sbellard void target_to_host_old_sigset(sigset_t *sigset,
284992f48a0Sblueswir1                                const abi_ulong *old_sigset);
28566fb9763Sbellard struct target_sigaction;
28666fb9763Sbellard int do_sigaction(int sig, const struct target_sigaction *act,
28766fb9763Sbellard                  struct target_sigaction *oact);
28866fb9763Sbellard 
28948733d19Sths #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)
2902521d698Sbellard 
291048f6b4dSbellard #if defined(TARGET_SPARC)
292048f6b4dSbellard #define TARGET_SA_NOCLDSTOP    8u
293048f6b4dSbellard #define TARGET_SA_NOCLDWAIT    0x100u
294048f6b4dSbellard #define TARGET_SA_SIGINFO      0x200u
295048f6b4dSbellard #define TARGET_SA_ONSTACK      1u
296048f6b4dSbellard #define TARGET_SA_RESTART      2u
297048f6b4dSbellard #define TARGET_SA_NODEFER      0x20u
298048f6b4dSbellard #define TARGET_SA_RESETHAND    4u
299048f6b4dSbellard #elif defined(TARGET_MIPS)
300048f6b4dSbellard #define TARGET_SA_NOCLDSTOP	0x00000001
301048f6b4dSbellard #define TARGET_SA_NOCLDWAIT	0x00010000
302048f6b4dSbellard #define TARGET_SA_SIGINFO	0x00000008
303048f6b4dSbellard #define TARGET_SA_ONSTACK	0x08000000
304048f6b4dSbellard #define TARGET_SA_NODEFER	0x40000000
305048f6b4dSbellard #define TARGET_SA_RESTART	0x10000000
306048f6b4dSbellard #define TARGET_SA_RESETHAND	0x80000000
307d26bc211Sths #if !defined(TARGET_ABI_MIPSN32) && !defined(TARGET_ABI_MIPSN64)
308d26bc211Sths #define TARGET_SA_RESTORER	0x04000000	/* Only for O32 */
309540635baSths #endif
310048f6b4dSbellard #else
3112521d698Sbellard #define TARGET_SA_NOCLDSTOP	0x00000001
3122521d698Sbellard #define TARGET_SA_NOCLDWAIT	0x00000002 /* not supported yet */
3132521d698Sbellard #define TARGET_SA_SIGINFO	0x00000004
3142521d698Sbellard #define TARGET_SA_ONSTACK	0x08000000
3152521d698Sbellard #define TARGET_SA_RESTART	0x10000000
3162521d698Sbellard #define TARGET_SA_NODEFER	0x40000000
3172521d698Sbellard #define TARGET_SA_RESETHAND	0x80000000
3182521d698Sbellard #define TARGET_SA_RESTORER	0x04000000
3196d5e216dSbellard #endif
3206d5e216dSbellard 
3216d5e216dSbellard #if defined(TARGET_SPARC)
3226d5e216dSbellard 
3236d5e216dSbellard #define TARGET_SIGHUP		 1
3246d5e216dSbellard #define TARGET_SIGINT		 2
3256d5e216dSbellard #define TARGET_SIGQUIT		 3
3266d5e216dSbellard #define TARGET_SIGILL		 4
3276d5e216dSbellard #define TARGET_SIGTRAP		 5
3286d5e216dSbellard #define TARGET_SIGABRT		 6
3296d5e216dSbellard #define TARGET_SIGIOT		 6
3306d5e216dSbellard #define TARGET_SIGSTKFLT	 7 /* actually EMT */
3316d5e216dSbellard #define TARGET_SIGFPE		 8
3326d5e216dSbellard #define TARGET_SIGKILL		 9
3336d5e216dSbellard #define TARGET_SIGBUS		10
3346d5e216dSbellard #define TARGET_SIGSEGV		11
3356d5e216dSbellard #define TARGET_SIGSYS		12
3366d5e216dSbellard #define TARGET_SIGPIPE		13
3376d5e216dSbellard #define TARGET_SIGALRM		14
3386d5e216dSbellard #define TARGET_SIGTERM		15
3396d5e216dSbellard #define TARGET_SIGURG		16
3406d5e216dSbellard #define TARGET_SIGSTOP		17
3416d5e216dSbellard #define TARGET_SIGTSTP		18
3426d5e216dSbellard #define TARGET_SIGCONT		19
3436d5e216dSbellard #define TARGET_SIGCHLD		20
3446d5e216dSbellard #define TARGET_SIGTTIN		21
3456d5e216dSbellard #define TARGET_SIGTTOU		22
3466d5e216dSbellard #define TARGET_SIGIO		23
3476d5e216dSbellard #define TARGET_SIGXCPU		24
3486d5e216dSbellard #define TARGET_SIGXFSZ		25
3496d5e216dSbellard #define TARGET_SIGVTALRM	26
3506d5e216dSbellard #define TARGET_SIGPROF		27
3516d5e216dSbellard #define TARGET_SIGWINCH	        28
3526d5e216dSbellard #define TARGET_SIGPWR		29
3536d5e216dSbellard #define TARGET_SIGUSR1		30
3546d5e216dSbellard #define TARGET_SIGUSR2		31
3556d5e216dSbellard #define TARGET_SIGRTMIN         32
3566d5e216dSbellard 
3576d5e216dSbellard #define TARGET_SIG_BLOCK          0x01 /* for blocking signals */
3586d5e216dSbellard #define TARGET_SIG_UNBLOCK        0x02 /* for unblocking signals */
3596d5e216dSbellard #define TARGET_SIG_SETMASK        0x04 /* for setting the signal mask */
3606d5e216dSbellard 
361048f6b4dSbellard #elif defined(TARGET_MIPS)
362048f6b4dSbellard 
363048f6b4dSbellard #define TARGET_SIGHUP		 1	/* Hangup (POSIX).  */
364048f6b4dSbellard #define TARGET_SIGINT		 2	/* Interrupt (ANSI).  */
365048f6b4dSbellard #define TARGET_SIGQUIT		 3	/* Quit (POSIX).  */
366048f6b4dSbellard #define TARGET_SIGILL		 4	/* Illegal instruction (ANSI).  */
367048f6b4dSbellard #define TARGET_SIGTRAP		 5	/* Trace trap (POSIX).  */
368048f6b4dSbellard #define TARGET_SIGIOT		 6	/* IOT trap (4.2 BSD).  */
369048f6b4dSbellard #define TARGET_SIGABRT		 TARGET_SIGIOT	/* Abort (ANSI).  */
370048f6b4dSbellard #define TARGET_SIGEMT		 7
371048f6b4dSbellard #define TARGET_SIGSTKFLT	 7 /* XXX: incorrect */
372048f6b4dSbellard #define TARGET_SIGFPE		 8	/* Floating-point exception (ANSI).  */
373048f6b4dSbellard #define TARGET_SIGKILL		 9	/* Kill, unblockable (POSIX).  */
374048f6b4dSbellard #define TARGET_SIGBUS		10	/* BUS error (4.2 BSD).  */
375048f6b4dSbellard #define TARGET_SIGSEGV		11	/* Segmentation violation (ANSI).  */
376048f6b4dSbellard #define TARGET_SIGSYS		12
377048f6b4dSbellard #define TARGET_SIGPIPE		13	/* Broken pipe (POSIX).  */
378048f6b4dSbellard #define TARGET_SIGALRM		14	/* Alarm clock (POSIX).  */
379048f6b4dSbellard #define TARGET_SIGTERM		15	/* Termination (ANSI).  */
380048f6b4dSbellard #define TARGET_SIGUSR1		16	/* User-defined signal 1 (POSIX).  */
381048f6b4dSbellard #define TARGET_SIGUSR2		17	/* User-defined signal 2 (POSIX).  */
382048f6b4dSbellard #define TARGET_SIGCHLD		18	/* Child status has changed (POSIX).  */
383048f6b4dSbellard #define TARGET_SIGCLD		TARGET_SIGCHLD	/* Same as TARGET_SIGCHLD (System V).  */
384048f6b4dSbellard #define TARGET_SIGPWR		19	/* Power failure restart (System V).  */
385048f6b4dSbellard #define TARGET_SIGWINCH	20	/* Window size change (4.3 BSD, Sun).  */
386048f6b4dSbellard #define TARGET_SIGURG		21	/* Urgent condition on socket (4.2 BSD).  */
387048f6b4dSbellard #define TARGET_SIGIO		22	/* I/O now possible (4.2 BSD).  */
388048f6b4dSbellard #define TARGET_SIGPOLL		TARGET_SIGIO	/* Pollable event occurred (System V).  */
389048f6b4dSbellard #define TARGET_SIGSTOP		23	/* Stop, unblockable (POSIX).  */
390048f6b4dSbellard #define TARGET_SIGTSTP		24	/* Keyboard stop (POSIX).  */
391048f6b4dSbellard #define TARGET_SIGCONT		25	/* Continue (POSIX).  */
392048f6b4dSbellard #define TARGET_SIGTTIN		26	/* Background read from tty (POSIX).  */
393048f6b4dSbellard #define TARGET_SIGTTOU		27	/* Background write to tty (POSIX).  */
394048f6b4dSbellard #define TARGET_SIGVTALRM	28	/* Virtual alarm clock (4.2 BSD).  */
395048f6b4dSbellard #define TARGET_SIGPROF		29	/* Profiling alarm clock (4.2 BSD).  */
396048f6b4dSbellard #define TARGET_SIGXCPU		30	/* CPU limit exceeded (4.2 BSD).  */
397048f6b4dSbellard #define TARGET_SIGXFSZ		31	/* File size limit exceeded (4.2 BSD).  */
398048f6b4dSbellard #define TARGET_SIGRTMIN         32
399048f6b4dSbellard 
400048f6b4dSbellard #define TARGET_SIG_BLOCK	1	/* for blocking signals */
401048f6b4dSbellard #define TARGET_SIG_UNBLOCK	2	/* for unblocking signals */
402048f6b4dSbellard #define TARGET_SIG_SETMASK	3	/* for setting the signal mask */
403048f6b4dSbellard 
4046d5e216dSbellard #else
4052521d698Sbellard 
4062521d698Sbellard #define TARGET_SIGHUP		 1
4072521d698Sbellard #define TARGET_SIGINT		 2
4082521d698Sbellard #define TARGET_SIGQUIT		 3
4092521d698Sbellard #define TARGET_SIGILL		 4
4102521d698Sbellard #define TARGET_SIGTRAP		 5
4112521d698Sbellard #define TARGET_SIGABRT		 6
4122521d698Sbellard #define TARGET_SIGIOT		 6
4132521d698Sbellard #define TARGET_SIGBUS		 7
4142521d698Sbellard #define TARGET_SIGFPE		 8
4152521d698Sbellard #define TARGET_SIGKILL		 9
4162521d698Sbellard #define TARGET_SIGUSR1		10
4172521d698Sbellard #define TARGET_SIGSEGV		11
4182521d698Sbellard #define TARGET_SIGUSR2		12
4192521d698Sbellard #define TARGET_SIGPIPE		13
4202521d698Sbellard #define TARGET_SIGALRM		14
4212521d698Sbellard #define TARGET_SIGTERM		15
4222521d698Sbellard #define TARGET_SIGSTKFLT	16
4232521d698Sbellard #define TARGET_SIGCHLD		17
4242521d698Sbellard #define TARGET_SIGCONT		18
4252521d698Sbellard #define TARGET_SIGSTOP		19
4262521d698Sbellard #define TARGET_SIGTSTP		20
4272521d698Sbellard #define TARGET_SIGTTIN		21
4282521d698Sbellard #define TARGET_SIGTTOU		22
4292521d698Sbellard #define TARGET_SIGURG		23
4302521d698Sbellard #define TARGET_SIGXCPU		24
4312521d698Sbellard #define TARGET_SIGXFSZ		25
4322521d698Sbellard #define TARGET_SIGVTALRM	26
4332521d698Sbellard #define TARGET_SIGPROF		27
4342521d698Sbellard #define TARGET_SIGWINCH	        28
4352521d698Sbellard #define TARGET_SIGIO		29
436c596ed17Sbellard #define TARGET_SIGPWR		30
437c596ed17Sbellard #define TARGET_SIGSYS		31
4382521d698Sbellard #define TARGET_SIGRTMIN         32
4392521d698Sbellard 
4402521d698Sbellard #define TARGET_SIG_BLOCK          0    /* for blocking signals */
4412521d698Sbellard #define TARGET_SIG_UNBLOCK        1    /* for unblocking signals */
4422521d698Sbellard #define TARGET_SIG_SETMASK        2    /* for setting the signal mask */
4432521d698Sbellard 
4446d5e216dSbellard #endif
4456d5e216dSbellard 
446106ec879Sbellard #if defined(TARGET_MIPS)
447106ec879Sbellard 
448106ec879Sbellard struct target_sigaction {
449540635baSths 	uint32_t	sa_flags;
450d26bc211Sths #if defined(TARGET_ABI_MIPSN32)
451540635baSths 	uint32_t	_sa_handler;
452540635baSths #else
453992f48a0Sblueswir1 	abi_ulong	_sa_handler;
454540635baSths #endif
455106ec879Sbellard 	target_sigset_t	sa_mask;
456106ec879Sbellard };
457106ec879Sbellard 
458106ec879Sbellard #else
4592521d698Sbellard struct target_old_sigaction {
460992f48a0Sblueswir1         abi_ulong _sa_handler;
461992f48a0Sblueswir1         abi_ulong sa_mask;
462992f48a0Sblueswir1         abi_ulong sa_flags;
463992f48a0Sblueswir1         abi_ulong sa_restorer;
4642521d698Sbellard };
4652521d698Sbellard 
4662521d698Sbellard struct target_sigaction {
467992f48a0Sblueswir1         abi_ulong _sa_handler;
468992f48a0Sblueswir1         abi_ulong sa_flags;
469992f48a0Sblueswir1         abi_ulong sa_restorer;
4702521d698Sbellard         target_sigset_t sa_mask;
4712521d698Sbellard };
472106ec879Sbellard #endif
4732521d698Sbellard 
4742521d698Sbellard typedef union target_sigval {
4752521d698Sbellard 	int sival_int;
476992f48a0Sblueswir1         abi_ulong sival_ptr;
4772521d698Sbellard } target_sigval_t;
4786d5e216dSbellard #if 0
4796d5e216dSbellard #if defined (TARGET_SPARC)
4806d5e216dSbellard typedef struct {
4816d5e216dSbellard 	struct {
482992f48a0Sblueswir1 		abi_ulong psr;
483992f48a0Sblueswir1 		abi_ulong pc;
484992f48a0Sblueswir1 		abi_ulong npc;
485992f48a0Sblueswir1 		abi_ulong y;
486992f48a0Sblueswir1 		abi_ulong u_regs[16]; /* globals and ins */
4876d5e216dSbellard 	}		si_regs;
4886d5e216dSbellard 	int		si_mask;
4896d5e216dSbellard } __siginfo_t;
4906d5e216dSbellard 
4916d5e216dSbellard typedef struct {
4926d5e216dSbellard 	unsigned   long si_float_regs [32];
4936d5e216dSbellard 	unsigned   long si_fsr;
4946d5e216dSbellard 	unsigned   long si_fpqdepth;
4956d5e216dSbellard 	struct {
4966d5e216dSbellard 		unsigned long *insn_addr;
4976d5e216dSbellard 		unsigned long insn;
4986d5e216dSbellard 	} si_fpqueue [16];
4996d5e216dSbellard } __siginfo_fpu_t;
5006d5e216dSbellard #endif
5016d5e216dSbellard #endif
5022521d698Sbellard 
5032521d698Sbellard #define TARGET_SI_MAX_SIZE	128
5042521d698Sbellard #define TARGET_SI_PAD_SIZE	((TARGET_SI_MAX_SIZE/sizeof(int)) - 3)
5052521d698Sbellard 
5062521d698Sbellard typedef struct target_siginfo {
5072521d698Sbellard 	int si_signo;
5082521d698Sbellard 	int si_errno;
5092521d698Sbellard 	int si_code;
5102521d698Sbellard 
5112521d698Sbellard 	union {
5122521d698Sbellard 		int _pad[TARGET_SI_PAD_SIZE];
5132521d698Sbellard 
5142521d698Sbellard 		/* kill() */
5152521d698Sbellard 		struct {
5162521d698Sbellard 			pid_t _pid;		/* sender's pid */
5172521d698Sbellard 			uid_t _uid;		/* sender's uid */
5182521d698Sbellard 		} _kill;
5192521d698Sbellard 
5202521d698Sbellard 		/* POSIX.1b timers */
5212521d698Sbellard 		struct {
5222521d698Sbellard 			unsigned int _timer1;
5232521d698Sbellard 			unsigned int _timer2;
5242521d698Sbellard 		} _timer;
5252521d698Sbellard 
5262521d698Sbellard 		/* POSIX.1b signals */
5272521d698Sbellard 		struct {
5282521d698Sbellard 			pid_t _pid;		/* sender's pid */
5292521d698Sbellard 			uid_t _uid;		/* sender's uid */
5302521d698Sbellard 			target_sigval_t _sigval;
5312521d698Sbellard 		} _rt;
5322521d698Sbellard 
5332521d698Sbellard 		/* SIGCHLD */
5342521d698Sbellard 		struct {
5352521d698Sbellard 			pid_t _pid;		/* which child */
5362521d698Sbellard 			uid_t _uid;		/* sender's uid */
5372521d698Sbellard 			int _status;		/* exit code */
5382521d698Sbellard 			target_clock_t _utime;
5392521d698Sbellard                         target_clock_t _stime;
5402521d698Sbellard 		} _sigchld;
5412521d698Sbellard 
5422521d698Sbellard 		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
5432521d698Sbellard 		struct {
544992f48a0Sblueswir1 			abi_ulong _addr; /* faulting insn/memory ref. */
5452521d698Sbellard 		} _sigfault;
5462521d698Sbellard 
5472521d698Sbellard 		/* SIGPOLL */
5482521d698Sbellard 		struct {
5492521d698Sbellard 			int _band;	/* POLL_IN, POLL_OUT, POLL_MSG */
5502521d698Sbellard 			int _fd;
5512521d698Sbellard 		} _sigpoll;
5522521d698Sbellard 	} _sifields;
5532521d698Sbellard } target_siginfo_t;
5542521d698Sbellard 
5552521d698Sbellard /*
5562521d698Sbellard  * si_code values
5572521d698Sbellard  * Digital reserves positive values for kernel-generated signals.
5582521d698Sbellard  */
5592521d698Sbellard #define TARGET_SI_USER		0	/* sent by kill, sigsend, raise */
5602521d698Sbellard #define TARGET_SI_KERNEL	0x80	/* sent by the kernel from somewhere */
5612521d698Sbellard #define TARGET_SI_QUEUE	-1		/* sent by sigqueue */
5622521d698Sbellard #define TARGET_SI_TIMER -2              /* sent by timer expiration */
5632521d698Sbellard #define TARGET_SI_MESGQ	-3		/* sent by real time mesq state change */
5642521d698Sbellard #define TARGET_SI_ASYNCIO	-4	/* sent by AIO completion */
5652521d698Sbellard #define TARGET_SI_SIGIO	-5		/* sent by queued SIGIO */
5662521d698Sbellard 
5672521d698Sbellard /*
5682521d698Sbellard  * SIGILL si_codes
5692521d698Sbellard  */
570ffa65c3bSbellard #define TARGET_ILL_ILLOPC	(1)	/* illegal opcode */
5712521d698Sbellard #define TARGET_ILL_ILLOPN	(2)	/* illegal operand */
572ffa65c3bSbellard #define TARGET_ILL_ILLADR	(3)	/* illegal addressing mode */
573ffa65c3bSbellard #define TARGET_ILL_ILLTRP	(4)	/* illegal trap */
574ffa65c3bSbellard #define TARGET_ILL_PRVOPC	(5)	/* privileged opcode */
575ffa65c3bSbellard #define TARGET_ILL_PRVREG	(6)	/* privileged register */
576ffa65c3bSbellard #define TARGET_ILL_COPROC	(7)	/* coprocessor error */
577ffa65c3bSbellard #define TARGET_ILL_BADSTK	(8)	/* internal stack error */
5782521d698Sbellard 
5792521d698Sbellard /*
5802521d698Sbellard  * SIGFPE si_codes
5812521d698Sbellard  */
5822521d698Sbellard #define TARGET_FPE_INTDIV      (1)  /* integer divide by zero */
5832521d698Sbellard #define TARGET_FPE_INTOVF      (2)  /* integer overflow */
5842521d698Sbellard #define TARGET_FPE_FLTDIV      (3)  /* floating point divide by zero */
5852521d698Sbellard #define TARGET_FPE_FLTOVF      (4)  /* floating point overflow */
5862521d698Sbellard #define TARGET_FPE_FLTUND      (5)  /* floating point underflow */
5872521d698Sbellard #define TARGET_FPE_FLTRES      (6)  /* floating point inexact result */
5882521d698Sbellard #define TARGET_FPE_FLTINV      (7)  /* floating point invalid operation */
5892521d698Sbellard #define TARGET_FPE_FLTSUB      (8)  /* subscript out of range */
5902521d698Sbellard #define TARGET_NSIGFPE         8
5912521d698Sbellard 
5922521d698Sbellard /*
5932521d698Sbellard  * SIGSEGV si_codes
5942521d698Sbellard  */
5952521d698Sbellard #define TARGET_SEGV_MAPERR     (1)  /* address not mapped to object */
5962521d698Sbellard #define TARGET_SEGV_ACCERR     (2)  /* invalid permissions for mapped object */
5972521d698Sbellard 
5982521d698Sbellard /*
599ffa65c3bSbellard  * SIGBUS si_codes
600ffa65c3bSbellard  */
601ffa65c3bSbellard #define TARGET_BUS_ADRALN       (1)	/* invalid address alignment */
602ffa65c3bSbellard #define TARGET_BUS_ADRERR       (2)	/* non-existant physical address */
603ffa65c3bSbellard #define TARGET_BUS_OBJERR       (3)	/* object specific hardware error */
604ffa65c3bSbellard 
605ffa65c3bSbellard /*
6062521d698Sbellard  * SIGTRAP si_codes
6072521d698Sbellard  */
6082521d698Sbellard #define TARGET_TRAP_BRKPT	(1)	/* process breakpoint */
6092521d698Sbellard #define TARGET_TRAP_TRACE	(2)	/* process trace trap */
6102521d698Sbellard 
6112521d698Sbellard #endif /* defined(TARGET_I386) || defined(TARGET_ARM) */
6122521d698Sbellard 
6139de5e440Sbellard struct target_rlimit {
614992f48a0Sblueswir1         abi_ulong   rlim_cur;
615992f48a0Sblueswir1         abi_ulong   rlim_max;
6169de5e440Sbellard };
6179de5e440Sbellard 
6189de5e440Sbellard struct target_pollfd {
6199de5e440Sbellard     int fd;           /* file descriptor */
6209de5e440Sbellard     short events;     /* requested events */
6219de5e440Sbellard     short revents;    /* returned events */
6229de5e440Sbellard };
6239de5e440Sbellard 
6248e5a0667Sbellard /* virtual terminal ioctls */
6250221cfcdSbellard #define TARGET_KIOCSOUND       0x4B2F	/* start sound generation (0 for off) */
6260221cfcdSbellard #define TARGET_KDMKTONE	       0x4B30	/* generate tone */
6278e5a0667Sbellard #define TARGET_KDGKBTYPE       0x4b33
6280221cfcdSbellard #define TARGET_KDGKBENT	       0x4B46	/* gets one entry in translation table */
6290221cfcdSbellard #define TARGET_KDGKBSENT       0x4B48	/* gets one function key string entry */
6308e5a0667Sbellard 
6312521d698Sbellard #define TARGET_SIOCATMARK      0x8905
6322521d698Sbellard 
63331e31b8aSbellard /* Networking ioctls */
63431e31b8aSbellard #define TARGET_SIOCADDRT       0x890B          /* add routing table entry */
63531e31b8aSbellard #define TARGET_SIOCDELRT       0x890C          /* delete routing table entry */
63631e31b8aSbellard #define TARGET_SIOCGIFNAME     0x8910          /* get iface name               */
63731e31b8aSbellard #define TARGET_SIOCSIFLINK     0x8911          /* set iface channel            */
63831e31b8aSbellard #define TARGET_SIOCGIFCONF     0x8912          /* get iface list               */
63931e31b8aSbellard #define TARGET_SIOCGIFFLAGS    0x8913          /* get flags                    */
64031e31b8aSbellard #define TARGET_SIOCSIFFLAGS    0x8914          /* set flags                    */
64131e31b8aSbellard #define TARGET_SIOCGIFADDR     0x8915          /* get PA address               */
64231e31b8aSbellard #define TARGET_SIOCSIFADDR     0x8916          /* set PA address               */
64331e31b8aSbellard #define TARGET_SIOCGIFDSTADDR  0x8917          /* get remote PA address        */
64431e31b8aSbellard #define TARGET_SIOCSIFDSTADDR  0x8918          /* set remote PA address        */
64531e31b8aSbellard #define TARGET_SIOCGIFBRDADDR  0x8919          /* get broadcast PA address     */
64631e31b8aSbellard #define TARGET_SIOCSIFBRDADDR  0x891a          /* set broadcast PA address     */
64731e31b8aSbellard #define TARGET_SIOCGIFNETMASK  0x891b          /* get network PA mask          */
64831e31b8aSbellard #define TARGET_SIOCSIFNETMASK  0x891c          /* set network PA mask          */
64931e31b8aSbellard #define TARGET_SIOCGIFMETRIC   0x891d          /* get metric                   */
65031e31b8aSbellard #define TARGET_SIOCSIFMETRIC   0x891e          /* set metric                   */
65131e31b8aSbellard #define TARGET_SIOCGIFMEM      0x891f          /* get memory address (BSD)     */
65231e31b8aSbellard #define TARGET_SIOCSIFMEM      0x8920          /* set memory address (BSD)     */
65331e31b8aSbellard #define TARGET_SIOCGIFMTU      0x8921          /* get MTU size                 */
65431e31b8aSbellard #define TARGET_SIOCSIFMTU      0x8922          /* set MTU size                 */
65531e31b8aSbellard #define TARGET_SIOCSIFHWADDR   0x8924          /* set hardware address (NI)    */
65631e31b8aSbellard #define TARGET_SIOCGIFENCAP    0x8925          /* get/set slip encapsulation   */
65731e31b8aSbellard #define TARGET_SIOCSIFENCAP    0x8926
65831e31b8aSbellard #define TARGET_SIOCGIFHWADDR   0x8927          /* Get hardware address         */
65931e31b8aSbellard #define TARGET_SIOCGIFSLAVE    0x8929          /* Driver slaving support       */
66031e31b8aSbellard #define TARGET_SIOCSIFSLAVE    0x8930
66131e31b8aSbellard #define TARGET_SIOCADDMULTI    0x8931          /* Multicast address lists      */
66231e31b8aSbellard #define TARGET_SIOCDELMULTI    0x8932
66331e31b8aSbellard 
66431e31b8aSbellard /* Bridging control calls */
66531e31b8aSbellard #define TARGET_SIOCGIFBR       0x8940          /* Bridging support             */
66631e31b8aSbellard #define TARGET_SIOCSIFBR       0x8941          /* Set bridging options         */
66731e31b8aSbellard 
66831e31b8aSbellard #define TARGET_SIOCGIFTXQLEN   0x8942          /* Get the tx queue length      */
66931e31b8aSbellard #define TARGET_SIOCSIFTXQLEN   0x8943          /* Set the tx queue length      */
67031e31b8aSbellard 
67131e31b8aSbellard /* ARP cache control calls. */
67231e31b8aSbellard #define TARGET_OLD_SIOCDARP    0x8950          /* old delete ARP table entry   */
67331e31b8aSbellard #define TARGET_OLD_SIOCGARP    0x8951          /* old get ARP table entry      */
67431e31b8aSbellard #define TARGET_OLD_SIOCSARP    0x8952          /* old set ARP table entry      */
67531e31b8aSbellard #define TARGET_SIOCDARP        0x8953          /* delete ARP table entry       */
67631e31b8aSbellard #define TARGET_SIOCGARP        0x8954          /* get ARP table entry          */
67731e31b8aSbellard #define TARGET_SIOCSARP        0x8955          /* set ARP table entry          */
67831e31b8aSbellard 
67931e31b8aSbellard /* RARP cache control calls. */
68031e31b8aSbellard #define TARGET_SIOCDRARP       0x8960          /* delete RARP table entry      */
68131e31b8aSbellard #define TARGET_SIOCGRARP       0x8961          /* get RARP table entry         */
68231e31b8aSbellard #define TARGET_SIOCSRARP       0x8962          /* set RARP table entry         */
68331e31b8aSbellard 
68431e31b8aSbellard /* Driver configuration calls */
68531e31b8aSbellard #define TARGET_SIOCGIFMAP      0x8970          /* Get device parameters        */
68631e31b8aSbellard #define TARGET_SIOCSIFMAP      0x8971          /* Set device parameters        */
68731e31b8aSbellard 
68831e31b8aSbellard /* DLCI configuration calls */
68931e31b8aSbellard #define TARGET_SIOCADDDLCI     0x8980          /* Create new DLCI device       */
69031e31b8aSbellard #define TARGET_SIOCDELDLCI     0x8981          /* Delete DLCI device           */
69131e31b8aSbellard 
69231e31b8aSbellard 
69331e31b8aSbellard /* From <linux/fs.h> */
69431e31b8aSbellard 
69531e31b8aSbellard #define TARGET_BLKROSET   TARGET_IO(0x12,93) /* set device read-only (0 = read-write) */
69631e31b8aSbellard #define TARGET_BLKROGET   TARGET_IO(0x12,94) /* get read-only status (0 = read_write) */
69731e31b8aSbellard #define TARGET_BLKRRPART  TARGET_IO(0x12,95) /* re-read partition table */
69831e31b8aSbellard #define TARGET_BLKGETSIZE TARGET_IO(0x12,96) /* return device size /512 (long *arg) */
69931e31b8aSbellard #define TARGET_BLKFLSBUF  TARGET_IO(0x12,97) /* flush buffer cache */
70031e31b8aSbellard #define TARGET_BLKRASET   TARGET_IO(0x12,98) /* Set read ahead for block device */
70131e31b8aSbellard #define TARGET_BLKRAGET   TARGET_IO(0x12,99) /* get current read ahead setting */
70231e31b8aSbellard #define TARGET_BLKFRASET  TARGET_IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
70331e31b8aSbellard #define TARGET_BLKFRAGET  TARGET_IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
70431e31b8aSbellard #define TARGET_BLKSECTSET TARGET_IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
70531e31b8aSbellard #define TARGET_BLKSECTGET TARGET_IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
70631e31b8aSbellard #define TARGET_BLKSSZGET  TARGET_IO(0x12,104)/* get block device sector size */
70731e31b8aSbellard /* A jump here: 108-111 have been used for various private purposes. */
70831e31b8aSbellard #define TARGET_BLKBSZGET  TARGET_IOR(0x12,112,sizeof(int))
70931e31b8aSbellard #define TARGET_BLKBSZSET  TARGET_IOW(0x12,113,sizeof(int))
71031e31b8aSbellard #define TARGET_BLKGETSIZE64 TARGET_IOR(0x12,114,sizeof(uint64_t)) /* return device size in bytes (u64 *arg) */
71131e31b8aSbellard #define TARGET_FIBMAP     TARGET_IO(0x00,1)  /* bmap access */
71231e31b8aSbellard #define TARGET_FIGETBSZ   TARGET_IO(0x00,2)  /* get the block size used for bmap */
71331e31b8aSbellard 
71431e31b8aSbellard /* cdrom commands */
71531e31b8aSbellard #define TARGET_CDROMPAUSE		0x5301 /* Pause Audio Operation */
71631e31b8aSbellard #define TARGET_CDROMRESUME		0x5302 /* Resume paused Audio Operation */
71731e31b8aSbellard #define TARGET_CDROMPLAYMSF		0x5303 /* Play Audio MSF (struct cdrom_msf) */
71831e31b8aSbellard #define TARGET_CDROMPLAYTRKIND		0x5304 /* Play Audio Track/index
71931e31b8aSbellard                                            (struct cdrom_ti) */
72031e31b8aSbellard #define TARGET_CDROMREADTOCHDR		0x5305 /* Read TOC header
72131e31b8aSbellard                                            (struct cdrom_tochdr) */
72231e31b8aSbellard #define TARGET_CDROMREADTOCENTRY	0x5306 /* Read TOC entry
72331e31b8aSbellard                                            (struct cdrom_tocentry) */
72431e31b8aSbellard #define TARGET_CDROMSTOP		0x5307 /* Stop the cdrom drive */
72531e31b8aSbellard #define TARGET_CDROMSTART		0x5308 /* Start the cdrom drive */
72631e31b8aSbellard #define TARGET_CDROMEJECT		0x5309 /* Ejects the cdrom media */
72731e31b8aSbellard #define TARGET_CDROMVOLCTRL		0x530a /* Control output volume
72831e31b8aSbellard                                            (struct cdrom_volctrl) */
72931e31b8aSbellard #define TARGET_CDROMSUBCHNL		0x530b /* Read subchannel data
73031e31b8aSbellard                                            (struct cdrom_subchnl) */
73131e31b8aSbellard #define TARGET_CDROMREADMODE2		0x530c /* Read TARGET_CDROM mode 2 data (2336 Bytes)
73231e31b8aSbellard                                            (struct cdrom_read) */
73331e31b8aSbellard #define TARGET_CDROMREADMODE1		0x530d /* Read TARGET_CDROM mode 1 data (2048 Bytes)
73431e31b8aSbellard                                            (struct cdrom_read) */
73531e31b8aSbellard #define TARGET_CDROMREADAUDIO		0x530e /* (struct cdrom_read_audio) */
73631e31b8aSbellard #define TARGET_CDROMEJECT_SW		0x530f /* enable(1)/disable(0) auto-ejecting */
73731e31b8aSbellard #define TARGET_CDROMMULTISESSION	0x5310 /* Obtain the start-of-last-session
73831e31b8aSbellard                                            address of multi session disks
73931e31b8aSbellard                                            (struct cdrom_multisession) */
74031e31b8aSbellard #define TARGET_CDROM_GET_MCN		0x5311 /* Obtain the "Universal Product Code"
74131e31b8aSbellard                                            if available (struct cdrom_mcn) */
74231e31b8aSbellard #define TARGET_CDROM_GET_UPC		TARGET_CDROM_GET_MCN  /* This one is depricated,
74331e31b8aSbellard                                           but here anyway for compatability */
74431e31b8aSbellard #define TARGET_CDROMRESET		0x5312 /* hard-reset the drive */
74531e31b8aSbellard #define TARGET_CDROMVOLREAD		0x5313 /* Get the drive's volume setting
74631e31b8aSbellard                                           (struct cdrom_volctrl) */
74731e31b8aSbellard #define TARGET_CDROMREADRAW		0x5314	/* read data in raw mode (2352 Bytes)
74831e31b8aSbellard                                            (struct cdrom_read) */
74931e31b8aSbellard /*
75031e31b8aSbellard  * These ioctls are used only used in aztcd.c and optcd.c
75131e31b8aSbellard  */
75231e31b8aSbellard #define TARGET_CDROMREADCOOKED		0x5315	/* read data in cooked mode */
75331e31b8aSbellard #define TARGET_CDROMSEEK		0x5316  /* seek msf address */
75431e31b8aSbellard 
75531e31b8aSbellard /*
75631e31b8aSbellard  * This ioctl is only used by the scsi-cd driver.
75731e31b8aSbellard    It is for playing audio in logical block addressing mode.
75831e31b8aSbellard  */
75931e31b8aSbellard #define TARGET_CDROMPLAYBLK		0x5317	/* (struct cdrom_blk) */
76031e31b8aSbellard 
76131e31b8aSbellard /*
76231e31b8aSbellard  * These ioctls are only used in optcd.c
76331e31b8aSbellard  */
76431e31b8aSbellard #define TARGET_CDROMREADALL		0x5318	/* read all 2646 bytes */
76531e31b8aSbellard 
76631e31b8aSbellard /*
76731e31b8aSbellard  * These ioctls are (now) only in ide-cd.c for controlling
76831e31b8aSbellard  * drive spindown time.  They should be implemented in the
76931e31b8aSbellard  * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10,
77031e31b8aSbellard  * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE...
77131e31b8aSbellard  *  -Erik
77231e31b8aSbellard  */
77331e31b8aSbellard #define TARGET_CDROMGETSPINDOWN        0x531d
77431e31b8aSbellard #define TARGET_CDROMSETSPINDOWN        0x531e
77531e31b8aSbellard 
77631e31b8aSbellard /*
77731e31b8aSbellard  * These ioctls are implemented through the uniform CD-ROM driver
77831e31b8aSbellard  * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM
77931e31b8aSbellard  * drivers are eventually ported to the uniform CD-ROM driver interface.
78031e31b8aSbellard  */
78131e31b8aSbellard #define TARGET_CDROMCLOSETRAY		0x5319	/* pendant of CDROMEJECT */
78231e31b8aSbellard #define TARGET_CDROM_SET_OPTIONS	0x5320  /* Set behavior options */
78331e31b8aSbellard #define TARGET_CDROM_CLEAR_OPTIONS	0x5321  /* Clear behavior options */
78431e31b8aSbellard #define TARGET_CDROM_SELECT_SPEED	0x5322  /* Set the CD-ROM speed */
78531e31b8aSbellard #define TARGET_CDROM_SELECT_DISC	0x5323  /* Select disc (for juke-boxes) */
78631e31b8aSbellard #define TARGET_CDROM_MEDIA_CHANGED	0x5325  /* Check is media changed  */
78731e31b8aSbellard #define TARGET_CDROM_DRIVE_STATUS	0x5326  /* Get tray position, etc. */
78831e31b8aSbellard #define TARGET_CDROM_DISC_STATUS	0x5327  /* Get disc type, etc. */
78931e31b8aSbellard #define TARGET_CDROM_CHANGER_NSLOTS    0x5328  /* Get number of slots */
79031e31b8aSbellard #define TARGET_CDROM_LOCKDOOR		0x5329  /* lock or unlock door */
79131e31b8aSbellard #define TARGET_CDROM_DEBUG		0x5330	/* Turn debug messages on/off */
79231e31b8aSbellard #define TARGET_CDROM_GET_CAPABILITY	0x5331	/* get capabilities */
79331e31b8aSbellard 
79431e31b8aSbellard /* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386.
79531e31b8aSbellard  * Future CDROM ioctls should be kept below 0x537F
79631e31b8aSbellard  */
79731e31b8aSbellard 
79831e31b8aSbellard /* This ioctl is only used by sbpcd at the moment */
79931e31b8aSbellard #define TARGET_CDROMAUDIOBUFSIZ        0x5382	/* set the audio buffer size */
80031e31b8aSbellard 					/* conflict with SCSI_IOCTL_GET_IDLUN */
80131e31b8aSbellard 
80231e31b8aSbellard /* DVD-ROM Specific ioctls */
80331e31b8aSbellard #define TARGET_DVD_READ_STRUCT		0x5390  /* Read structure */
80431e31b8aSbellard #define TARGET_DVD_WRITE_STRUCT	0x5391  /* Write structure */
80531e31b8aSbellard #define TARGET_DVD_AUTH		0x5392  /* Authentication */
80631e31b8aSbellard 
80731e31b8aSbellard #define TARGET_CDROM_SEND_PACKET	0x5393	/* send a packet to the drive */
80831e31b8aSbellard #define TARGET_CDROM_NEXT_WRITABLE	0x5394	/* get next writable block */
80931e31b8aSbellard #define TARGET_CDROM_LAST_WRITTEN	0x5395	/* get last block written on disc */
81031e31b8aSbellard 
81131e31b8aSbellard /* HD commands */
81231e31b8aSbellard 
81331e31b8aSbellard /* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x030n/0x031n */
81431e31b8aSbellard #define TARGET_HDIO_GETGEO            0x0301  /* get device geometry */
81531e31b8aSbellard #define TARGET_HDIO_GET_UNMASKINTR    0x0302  /* get current unmask setting */
81631e31b8aSbellard #define TARGET_HDIO_GET_MULTCOUNT     0x0304  /* get current IDE blockmode setting */
81731e31b8aSbellard #define TARGET_HDIO_GET_KEEPSETTINGS  0x0308  /* get keep-settings-on-reset flag */
81831e31b8aSbellard #define TARGET_HDIO_GET_32BIT         0x0309  /* get current io_32bit setting */
81931e31b8aSbellard #define TARGET_HDIO_GET_NOWERR        0x030a  /* get ignore-write-error flag */
82031e31b8aSbellard #define TARGET_HDIO_GET_DMA           0x030b  /* get use-dma flag */
8212521d698Sbellard #define TARGET_HDIO_GET_IDENTITY      0x030d  /* get IDE identification info */
82231e31b8aSbellard #define TARGET_HDIO_DRIVE_CMD         0x031f  /* execute a special drive command */
82331e31b8aSbellard 
82431e31b8aSbellard /* hd/ide ctl's that pass (arg) non-ptr values are numbered 0x032n/0x033n */
82531e31b8aSbellard #define TARGET_HDIO_SET_MULTCOUNT     0x0321  /* change IDE blockmode */
82631e31b8aSbellard #define TARGET_HDIO_SET_UNMASKINTR    0x0322  /* permit other irqs during I/O */
82731e31b8aSbellard #define TARGET_HDIO_SET_KEEPSETTINGS  0x0323  /* keep ioctl settings on reset */
82831e31b8aSbellard #define TARGET_HDIO_SET_32BIT         0x0324  /* change io_32bit flags */
82931e31b8aSbellard #define TARGET_HDIO_SET_NOWERR        0x0325  /* change ignore-write-error flag */
83031e31b8aSbellard #define TARGET_HDIO_SET_DMA           0x0326  /* change use-dma flag */
83131e31b8aSbellard #define TARGET_HDIO_SET_PIO_MODE      0x0327  /* reconfig interface to new speed */
8322521d698Sbellard 
833b8005914Sbalrog /* loop ioctls */
834b8005914Sbalrog #define TARGET_LOOP_SET_FD            0x4C00
835b8005914Sbalrog #define TARGET_LOOP_CLR_FD            0x4C01
836b8005914Sbalrog #define TARGET_LOOP_SET_STATUS        0x4C02
837b8005914Sbalrog #define TARGET_LOOP_GET_STATUS        0x4C03
838b8005914Sbalrog #define TARGET_LOOP_SET_STATUS64      0x4C04
839b8005914Sbalrog #define TARGET_LOOP_GET_STATUS64      0x4C05
840b8005914Sbalrog #define TARGET_LOOP_CHANGE_FD         0x4C06
8412521d698Sbellard 
8422521d698Sbellard /* from asm/termbits.h */
8432521d698Sbellard 
8443bfd9da1Sbellard #define TARGET_NCC 8
8453bfd9da1Sbellard struct target_termio {
8463bfd9da1Sbellard 	unsigned short c_iflag;		/* input mode flags */
8473bfd9da1Sbellard 	unsigned short c_oflag;		/* output mode flags */
8483bfd9da1Sbellard 	unsigned short c_cflag;		/* control mode flags */
8493bfd9da1Sbellard 	unsigned short c_lflag;		/* local mode flags */
8502521d698Sbellard 	unsigned char c_line;		/* line discipline */
8513bfd9da1Sbellard 	unsigned char c_cc[TARGET_NCC];	/* control characters */
8522521d698Sbellard };
8532521d698Sbellard 
8543bfd9da1Sbellard struct target_winsize {
8553bfd9da1Sbellard 	unsigned short ws_row;
8563bfd9da1Sbellard 	unsigned short ws_col;
8573bfd9da1Sbellard 	unsigned short ws_xpixel;
8583bfd9da1Sbellard 	unsigned short ws_ypixel;
8593bfd9da1Sbellard };
8602521d698Sbellard 
8613bfd9da1Sbellard #include "termbits.h"
8622521d698Sbellard 
863e44a3e79Saurel32 /* Common */
8642521d698Sbellard #define TARGET_MAP_SHARED	0x01		/* Share changes */
8652521d698Sbellard #define TARGET_MAP_PRIVATE	0x02		/* Changes are private */
8662521d698Sbellard #define TARGET_MAP_TYPE		0x0f		/* Mask for type of mapping */
867e44a3e79Saurel32 
868e44a3e79Saurel32 /* Target specific */
869048f6b4dSbellard #if defined(TARGET_MIPS)
870e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
871048f6b4dSbellard #define TARGET_MAP_ANONYMOUS	0x0800		/* don't use a file */
872048f6b4dSbellard #define TARGET_MAP_GROWSDOWN	0x1000		/* stack-like segment */
873048f6b4dSbellard #define TARGET_MAP_DENYWRITE	0x2000		/* ETXTBSY */
874048f6b4dSbellard #define TARGET_MAP_EXECUTABLE	0x4000		/* mark it as an executable */
875048f6b4dSbellard #define TARGET_MAP_LOCKED	0x8000		/* pages are locked */
876048f6b4dSbellard #define TARGET_MAP_NORESERVE	0x0400		/* don't check for reservations */
877540635baSths #define TARGET_MAP_POPULATE	0x10000		/* populate (prefault) pagetables */
878540635baSths #define TARGET_MAP_NONBLOCK	0x20000		/* do not block on IO */
879e44a3e79Saurel32 #elif defined(TARGET_PPC)
880e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
8812521d698Sbellard #define TARGET_MAP_ANONYMOUS	0x20		/* don't use a file */
8822521d698Sbellard #define TARGET_MAP_GROWSDOWN	0x0100		/* stack-like segment */
8832521d698Sbellard #define TARGET_MAP_DENYWRITE	0x0800		/* ETXTBSY */
8842521d698Sbellard #define TARGET_MAP_EXECUTABLE	0x1000		/* mark it as an executable */
8857ec93196Sj_mayer #define TARGET_MAP_LOCKED	0x0080		/* pages are locked */
8867ec93196Sj_mayer #define TARGET_MAP_NORESERVE	0x0040		/* don't check for reservations */
887e44a3e79Saurel32 #define TARGET_MAP_POPULATE	0x8000		/* populate (prefault) pagetables */
888e44a3e79Saurel32 #define TARGET_MAP_NONBLOCK	0x10000		/* do not block on IO */
889e44a3e79Saurel32 #elif defined(TARGET_ALPHA)
890e44a3e79Saurel32 #define TARGET_MAP_ANONYMOUS	0x10		/* don't use a file */
891e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x100		/* Interpret addr exactly */
892e44a3e79Saurel32 #define TARGET_MAP_GROWSDOWN	0x01000		/* stack-like segment */
893e44a3e79Saurel32 #define TARGET_MAP_DENYWRITE	0x02000		/* ETXTBSY */
894e44a3e79Saurel32 #define TARGET_MAP_EXECUTABLE	0x04000		/* mark it as an executable */
895e44a3e79Saurel32 #define TARGET_MAP_LOCKED	0x08000		/* lock the mapping */
896e44a3e79Saurel32 #define TARGET_MAP_NORESERVE	0x10000		/* no check for reservations */
897e44a3e79Saurel32 #define TARGET_MAP_POPULATE	0x20000		/* pop (prefault) pagetables */
898e44a3e79Saurel32 #define TARGET_MAP_NONBLOCK	0x40000		/* do not block on IO */
8997ec93196Sj_mayer #else
900e44a3e79Saurel32 #define TARGET_MAP_FIXED	0x10		/* Interpret addr exactly */
901e44a3e79Saurel32 #define TARGET_MAP_ANONYMOUS	0x20		/* don't use a file */
902e44a3e79Saurel32 #define TARGET_MAP_GROWSDOWN	0x0100		/* stack-like segment */
903e44a3e79Saurel32 #define TARGET_MAP_DENYWRITE	0x0800		/* ETXTBSY */
904e44a3e79Saurel32 #define TARGET_MAP_EXECUTABLE	0x1000		/* mark it as an executable */
9052521d698Sbellard #define TARGET_MAP_LOCKED	0x2000		/* pages are locked */
9062521d698Sbellard #define TARGET_MAP_NORESERVE	0x4000		/* don't check for reservations */
907540635baSths #define TARGET_MAP_POPULATE	0x8000		/* populate (prefault) pagetables */
908540635baSths #define TARGET_MAP_NONBLOCK	0x10000		/* do not block on IO */
9097ec93196Sj_mayer #endif
9102521d698Sbellard 
911d2fd1af7Sbellard #if (defined(TARGET_I386) && defined(TARGET_ABI32)) || defined(TARGET_ARM) || defined(TARGET_CRIS)
9122521d698Sbellard struct target_stat {
9132521d698Sbellard 	unsigned short st_dev;
9142521d698Sbellard 	unsigned short __pad1;
915992f48a0Sblueswir1 	abi_ulong st_ino;
9162521d698Sbellard 	unsigned short st_mode;
9172521d698Sbellard 	unsigned short st_nlink;
9182521d698Sbellard 	unsigned short st_uid;
9192521d698Sbellard 	unsigned short st_gid;
9202521d698Sbellard 	unsigned short st_rdev;
9212521d698Sbellard 	unsigned short __pad2;
922992f48a0Sblueswir1 	abi_ulong  st_size;
923992f48a0Sblueswir1 	abi_ulong  st_blksize;
924992f48a0Sblueswir1 	abi_ulong  st_blocks;
925992f48a0Sblueswir1 	abi_ulong  target_st_atime;
926992f48a0Sblueswir1 	abi_ulong  __unused1;
927992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
928992f48a0Sblueswir1 	abi_ulong  __unused2;
929992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
930992f48a0Sblueswir1 	abi_ulong  __unused3;
931992f48a0Sblueswir1 	abi_ulong  __unused4;
932992f48a0Sblueswir1 	abi_ulong  __unused5;
9332521d698Sbellard };
9342521d698Sbellard 
9352521d698Sbellard /* This matches struct stat64 in glibc2.1, hence the absolutely
9362521d698Sbellard  * insane amounts of padding around dev_t's.
9372521d698Sbellard  */
9382521d698Sbellard struct target_stat64 {
9392521d698Sbellard 	unsigned short	st_dev;
9402521d698Sbellard 	unsigned char	__pad0[10];
9412521d698Sbellard 
9422521d698Sbellard #define TARGET_STAT64_HAS_BROKEN_ST_INO	1
943992f48a0Sblueswir1 	abi_ulong	__st_ino;
9442521d698Sbellard 
9452521d698Sbellard 	unsigned int	st_mode;
9462521d698Sbellard 	unsigned int	st_nlink;
9472521d698Sbellard 
948992f48a0Sblueswir1 	abi_ulong	st_uid;
949992f48a0Sblueswir1 	abi_ulong	st_gid;
9502521d698Sbellard 
9512521d698Sbellard 	unsigned short	st_rdev;
9522521d698Sbellard 	unsigned char	__pad3[10];
9532521d698Sbellard 
9542521d698Sbellard 	long long	st_size;
955992f48a0Sblueswir1 	abi_ulong	st_blksize;
9562521d698Sbellard 
957992f48a0Sblueswir1 	abi_ulong	st_blocks;	/* Number 512-byte blocks allocated. */
958992f48a0Sblueswir1 	abi_ulong	__pad4;		/* future possible st_blocks high bits */
9592521d698Sbellard 
960992f48a0Sblueswir1 	abi_ulong	target_st_atime;
961992f48a0Sblueswir1 	abi_ulong	__pad5;
9622521d698Sbellard 
963992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
964992f48a0Sblueswir1 	abi_ulong	__pad6;
9652521d698Sbellard 
966992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
967992f48a0Sblueswir1 	abi_ulong	__pad7;		/* will be high 32 bits of ctime someday */
9682521d698Sbellard 
9692521d698Sbellard 	unsigned long long	st_ino;
9702521d698Sbellard } __attribute__((packed));
9712521d698Sbellard 
972ce4defa0Spbrook #ifdef TARGET_ARM
973ce4defa0Spbrook struct target_eabi_stat64 {
974ce4defa0Spbrook         unsigned long long st_dev;
975ce4defa0Spbrook         unsigned int    __pad1;
976992f48a0Sblueswir1         abi_ulong    __st_ino;
977ce4defa0Spbrook         unsigned int    st_mode;
978ce4defa0Spbrook         unsigned int    st_nlink;
979ce4defa0Spbrook 
980992f48a0Sblueswir1         abi_ulong    st_uid;
981992f48a0Sblueswir1         abi_ulong    st_gid;
982ce4defa0Spbrook 
983ce4defa0Spbrook         unsigned long long st_rdev;
984ce4defa0Spbrook         unsigned int    __pad2[2];
985ce4defa0Spbrook 
986ce4defa0Spbrook         long long       st_size;
987992f48a0Sblueswir1         abi_ulong    st_blksize;
988ce4defa0Spbrook         unsigned int    __pad3;
989ce4defa0Spbrook         unsigned long long st_blocks;
990ce4defa0Spbrook 
991992f48a0Sblueswir1         abi_ulong    target_st_atime;
992992f48a0Sblueswir1         abi_ulong    target_st_atime_nsec;
993ce4defa0Spbrook 
994992f48a0Sblueswir1         abi_ulong    target_st_mtime;
995992f48a0Sblueswir1         abi_ulong    target_st_mtime_nsec;
996ce4defa0Spbrook 
997992f48a0Sblueswir1         abi_ulong    target_st_ctime;
998992f48a0Sblueswir1         abi_ulong    target_st_ctime_nsec;
999ce4defa0Spbrook 
1000ce4defa0Spbrook         unsigned long long st_ino;
1001ce4defa0Spbrook } __attribute__ ((packed));
1002ce4defa0Spbrook #endif
1003ce4defa0Spbrook 
1004992f48a0Sblueswir1 #elif defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
10051b8dd648Sblueswir1 struct target_stat {
10061b8dd648Sblueswir1 	unsigned int	st_dev;
1007992f48a0Sblueswir1 	abi_ulong	st_ino;
10081b8dd648Sblueswir1 	unsigned int	st_mode;
10091b8dd648Sblueswir1 	unsigned int	st_nlink;
10101b8dd648Sblueswir1 	unsigned int	st_uid;
10111b8dd648Sblueswir1 	unsigned int	st_gid;
10121b8dd648Sblueswir1 	unsigned int	st_rdev;
1013992f48a0Sblueswir1 	abi_long	st_size;
1014992f48a0Sblueswir1 	abi_long	target_st_atime;
1015992f48a0Sblueswir1 	abi_long	target_st_mtime;
1016992f48a0Sblueswir1 	abi_long	target_st_ctime;
1017992f48a0Sblueswir1 	abi_long	st_blksize;
1018992f48a0Sblueswir1 	abi_long	st_blocks;
1019992f48a0Sblueswir1 	abi_ulong	__unused4[2];
10201b8dd648Sblueswir1 };
10211b8dd648Sblueswir1 
10221b8dd648Sblueswir1 struct target_stat64 {
10231b8dd648Sblueswir1 	unsigned char	__pad0[6];
10241b8dd648Sblueswir1 	unsigned short	st_dev;
10251b8dd648Sblueswir1 
10261b8dd648Sblueswir1 	uint64_t	st_ino;
10271b8dd648Sblueswir1 	uint64_t	st_nlink;
10281b8dd648Sblueswir1 
10291b8dd648Sblueswir1 	unsigned int	st_mode;
10301b8dd648Sblueswir1 
10311b8dd648Sblueswir1 	unsigned int	st_uid;
10321b8dd648Sblueswir1 	unsigned int	st_gid;
10331b8dd648Sblueswir1 
10341b8dd648Sblueswir1 	unsigned char	__pad2[6];
10351b8dd648Sblueswir1 	unsigned short	st_rdev;
10361b8dd648Sblueswir1 
10371b8dd648Sblueswir1         int64_t		st_size;
10381b8dd648Sblueswir1 	int64_t		st_blksize;
10391b8dd648Sblueswir1 
10401b8dd648Sblueswir1 	unsigned char	__pad4[4];
10411b8dd648Sblueswir1 	unsigned int	st_blocks;
10421b8dd648Sblueswir1 
1043992f48a0Sblueswir1 	abi_ulong	target_st_atime;
1044992f48a0Sblueswir1 	abi_ulong	__unused1;
10451b8dd648Sblueswir1 
1046992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
1047992f48a0Sblueswir1 	abi_ulong	__unused2;
10481b8dd648Sblueswir1 
1049992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
1050992f48a0Sblueswir1 	abi_ulong	__unused3;
10511b8dd648Sblueswir1 
1052992f48a0Sblueswir1 	abi_ulong	__unused4[3];
10531b8dd648Sblueswir1 };
10541b8dd648Sblueswir1 
10553bfd9da1Sbellard #elif defined(TARGET_SPARC)
10563bfd9da1Sbellard 
10573bfd9da1Sbellard struct target_stat {
10583bfd9da1Sbellard 	unsigned short	st_dev;
1059992f48a0Sblueswir1 	abi_ulong	st_ino;
10603bfd9da1Sbellard 	unsigned short	st_mode;
10613bfd9da1Sbellard 	short		st_nlink;
10623bfd9da1Sbellard 	unsigned short	st_uid;
10633bfd9da1Sbellard 	unsigned short	st_gid;
10643bfd9da1Sbellard 	unsigned short	st_rdev;
1065992f48a0Sblueswir1 	abi_long	st_size;
1066992f48a0Sblueswir1 	abi_long	target_st_atime;
1067992f48a0Sblueswir1 	abi_ulong	__unused1;
1068992f48a0Sblueswir1 	abi_long	target_st_mtime;
1069992f48a0Sblueswir1 	abi_ulong	__unused2;
1070992f48a0Sblueswir1 	abi_long	target_st_ctime;
1071992f48a0Sblueswir1 	abi_ulong	__unused3;
1072992f48a0Sblueswir1 	abi_long	st_blksize;
1073992f48a0Sblueswir1 	abi_long	st_blocks;
1074992f48a0Sblueswir1 	abi_ulong	__unused4[2];
10753bfd9da1Sbellard };
10763bfd9da1Sbellard 
10773bfd9da1Sbellard struct target_stat64 {
10783bfd9da1Sbellard 	unsigned char	__pad0[6];
10793bfd9da1Sbellard 	unsigned short	st_dev;
10803bfd9da1Sbellard 
10813bfd9da1Sbellard 	uint64_t st_ino;
10823bfd9da1Sbellard 
10833bfd9da1Sbellard 	unsigned int	st_mode;
10843bfd9da1Sbellard 	unsigned int	st_nlink;
10853bfd9da1Sbellard 
10863bfd9da1Sbellard 	unsigned int	st_uid;
10873bfd9da1Sbellard 	unsigned int	st_gid;
10883bfd9da1Sbellard 
10893bfd9da1Sbellard 	unsigned char	__pad2[6];
10903bfd9da1Sbellard 	unsigned short	st_rdev;
10913bfd9da1Sbellard 
10923bfd9da1Sbellard 	unsigned char	__pad3[8];
10933bfd9da1Sbellard 
10943bfd9da1Sbellard         int64_t	st_size;
10953bfd9da1Sbellard 	unsigned int	st_blksize;
10963bfd9da1Sbellard 
10973bfd9da1Sbellard 	unsigned char	__pad4[8];
10983bfd9da1Sbellard 	unsigned int	st_blocks;
10993bfd9da1Sbellard 
11003bfd9da1Sbellard 	unsigned int	target_st_atime;
11013bfd9da1Sbellard 	unsigned int	__unused1;
11023bfd9da1Sbellard 
11033bfd9da1Sbellard 	unsigned int	target_st_mtime;
11043bfd9da1Sbellard 	unsigned int	__unused2;
11053bfd9da1Sbellard 
11063bfd9da1Sbellard 	unsigned int	target_st_ctime;
11073bfd9da1Sbellard 	unsigned int	__unused3;
11083bfd9da1Sbellard 
11093bfd9da1Sbellard 	unsigned int	__unused4;
11103bfd9da1Sbellard 	unsigned int	__unused5;
11113bfd9da1Sbellard };
11123bfd9da1Sbellard 
111367867308Sbellard #elif defined(TARGET_PPC)
111467867308Sbellard 
111567867308Sbellard struct target_stat {
1116e32448e0Sj_mayer 	abi_ulong st_dev;
1117992f48a0Sblueswir1 	abi_ulong st_ino;
1118325e651fSj_mayer #if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
1119e32448e0Sj_mayer 	abi_ulong st_nlink;
1120325e651fSj_mayer 	unsigned int st_mode;
1121325e651fSj_mayer #else
112267867308Sbellard 	unsigned int st_mode;
112367867308Sbellard 	unsigned short st_nlink;
1124325e651fSj_mayer #endif
112567867308Sbellard 	unsigned int st_uid;
112667867308Sbellard 	unsigned int st_gid;
1127e32448e0Sj_mayer 	abi_ulong  st_rdev;
1128992f48a0Sblueswir1 	abi_ulong  st_size;
1129992f48a0Sblueswir1 	abi_ulong  st_blksize;
1130992f48a0Sblueswir1 	abi_ulong  st_blocks;
1131992f48a0Sblueswir1 	abi_ulong  target_st_atime;
1132e32448e0Sj_mayer 	abi_ulong  target_st_atime_nsec;
1133992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
1134e32448e0Sj_mayer 	abi_ulong  target_st_mtime_nsec;
1135992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
1136e32448e0Sj_mayer 	abi_ulong  target_st_ctime_nsec;
1137992f48a0Sblueswir1 	abi_ulong  __unused4;
1138992f48a0Sblueswir1 	abi_ulong  __unused5;
1139325e651fSj_mayer #if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
1140325e651fSj_mayer 	abi_ulong  __unused6;
1141325e651fSj_mayer #endif
114267867308Sbellard };
114367867308Sbellard 
1144e1ce5e40Saurel32 struct __attribute__((__packed__)) target_stat64 {
114567867308Sbellard 	unsigned long long st_dev;
114667867308Sbellard         unsigned long long st_ino;
114767867308Sbellard 	unsigned int st_mode;
114867867308Sbellard 	unsigned int st_nlink;
114967867308Sbellard 	unsigned int st_uid;
115067867308Sbellard 	unsigned int st_gid;
115167867308Sbellard 	unsigned long long st_rdev;
1152e1ce5e40Saurel32 	unsigned long long __pad0;
115367867308Sbellard 	long long      st_size;
1154e32448e0Sj_mayer 	int	       st_blksize;
115567867308Sbellard 	long long      st_blocks;	/* Number 512-byte blocks allocated. */
1156e1ce5e40Saurel32 	unsigned int   __pad1;
1157e32448e0Sj_mayer 	int	       target_st_atime;
1158e32448e0Sj_mayer         unsigned int   target_st_atime_nsec;
1159e32448e0Sj_mayer 	int	       target_st_mtime;
1160e32448e0Sj_mayer         unsigned int   target_st_mtime_nsec;
1161e32448e0Sj_mayer 	int            target_st_ctime;
1162e32448e0Sj_mayer         unsigned int   target_st_ctime_nsec;
1163e32448e0Sj_mayer         unsigned int   __unused4;
1164e32448e0Sj_mayer         unsigned int   __unused5;
116567867308Sbellard };
116667867308Sbellard 
1167e6e5906bSpbrook #elif defined(TARGET_M68K)
1168e6e5906bSpbrook 
1169e6e5906bSpbrook struct target_stat {
1170e6e5906bSpbrook 	unsigned short st_dev;
1171e6e5906bSpbrook 	unsigned short __pad1;
1172992f48a0Sblueswir1 	abi_ulong st_ino;
1173e6e5906bSpbrook 	unsigned short st_mode;
1174e6e5906bSpbrook 	unsigned short st_nlink;
1175e6e5906bSpbrook 	unsigned short st_uid;
1176e6e5906bSpbrook 	unsigned short st_gid;
1177e6e5906bSpbrook 	unsigned short st_rdev;
1178e6e5906bSpbrook 	unsigned short __pad2;
1179992f48a0Sblueswir1 	abi_ulong  st_size;
1180992f48a0Sblueswir1 	abi_ulong  st_blksize;
1181992f48a0Sblueswir1 	abi_ulong  st_blocks;
1182992f48a0Sblueswir1 	abi_ulong  target_st_atime;
1183992f48a0Sblueswir1 	abi_ulong  __unused1;
1184992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
1185992f48a0Sblueswir1 	abi_ulong  __unused2;
1186992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
1187992f48a0Sblueswir1 	abi_ulong  __unused3;
1188992f48a0Sblueswir1 	abi_ulong  __unused4;
1189992f48a0Sblueswir1 	abi_ulong  __unused5;
1190e6e5906bSpbrook };
1191e6e5906bSpbrook 
1192e6e5906bSpbrook /* This matches struct stat64 in glibc2.1, hence the absolutely
1193e6e5906bSpbrook  * insane amounts of padding around dev_t's.
1194e6e5906bSpbrook  */
1195e6e5906bSpbrook struct target_stat64 {
1196e6e5906bSpbrook 	unsigned long long	st_dev;
1197e6e5906bSpbrook 	unsigned char	__pad1[2];
1198e6e5906bSpbrook 
1199e6e5906bSpbrook #define TARGET_STAT64_HAS_BROKEN_ST_INO	1
1200992f48a0Sblueswir1 	abi_ulong	__st_ino;
1201e6e5906bSpbrook 
1202e6e5906bSpbrook 	unsigned int	st_mode;
1203e6e5906bSpbrook 	unsigned int	st_nlink;
1204e6e5906bSpbrook 
1205992f48a0Sblueswir1 	abi_ulong	st_uid;
1206992f48a0Sblueswir1 	abi_ulong	st_gid;
1207e6e5906bSpbrook 
1208e6e5906bSpbrook 	unsigned long long	st_rdev;
1209e6e5906bSpbrook 	unsigned char	__pad3[2];
1210e6e5906bSpbrook 
1211e6e5906bSpbrook 	long long	st_size;
1212992f48a0Sblueswir1 	abi_ulong	st_blksize;
1213e6e5906bSpbrook 
1214992f48a0Sblueswir1 	abi_ulong	__pad4;		/* future possible st_blocks high bits */
1215992f48a0Sblueswir1 	abi_ulong	st_blocks;	/* Number 512-byte blocks allocated. */
1216e6e5906bSpbrook 
1217992f48a0Sblueswir1 	abi_ulong	target_st_atime;
1218992f48a0Sblueswir1 	abi_ulong	target_st_atime_nsec;
1219e6e5906bSpbrook 
1220992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
1221992f48a0Sblueswir1 	abi_ulong	target_st_mtime_nsec;
1222e6e5906bSpbrook 
1223992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
1224992f48a0Sblueswir1 	abi_ulong	target_st_ctime_nsec;
1225e6e5906bSpbrook 
1226e6e5906bSpbrook 	unsigned long long	st_ino;
1227e6e5906bSpbrook } __attribute__((packed));
1228e6e5906bSpbrook 
1229d26bc211Sths #elif defined(TARGET_ABI_MIPSN64)
1230540635baSths 
1231540635baSths /* The memory layout is the same as of struct stat64 of the 32-bit kernel.  */
1232540635baSths struct target_stat {
1233540635baSths 	unsigned int		st_dev;
1234540635baSths 	unsigned int		st_pad0[3]; /* Reserved for st_dev expansion */
1235540635baSths 
1236992f48a0Sblueswir1 	abi_ulong		st_ino;
1237540635baSths 
1238540635baSths 	unsigned int		st_mode;
1239540635baSths 	unsigned int		st_nlink;
1240540635baSths 
1241540635baSths 	int			st_uid;
1242540635baSths 	int			st_gid;
1243540635baSths 
1244540635baSths 	unsigned int		st_rdev;
1245540635baSths 	unsigned int		st_pad1[3]; /* Reserved for st_rdev expansion */
1246540635baSths 
1247992f48a0Sblueswir1 	abi_ulong		st_size;
1248540635baSths 
1249540635baSths 	/*
1250540635baSths 	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1251540635baSths 	 * but we don't have it under Linux.
1252540635baSths 	 */
1253540635baSths 	unsigned int		target_st_atime;
1254540635baSths 	unsigned int		target_st_atime_nsec;
1255540635baSths 
1256540635baSths 	unsigned int		target_st_mtime;
1257540635baSths 	unsigned int		target_st_mtime_nsec;
1258540635baSths 
1259540635baSths 	unsigned int		target_st_ctime;
1260540635baSths 	unsigned int		target_st_ctime_nsec;
1261540635baSths 
1262540635baSths 	unsigned int		st_blksize;
1263540635baSths 	unsigned int		st_pad2;
1264540635baSths 
1265992f48a0Sblueswir1 	abi_ulong		st_blocks;
1266540635baSths };
1267540635baSths 
1268d26bc211Sths #elif defined(TARGET_ABI_MIPSN32)
1269540635baSths 
1270540635baSths struct target_stat {
1271540635baSths 	unsigned	st_dev;
1272540635baSths 	int		st_pad1[3];		/* Reserved for network id */
1273540635baSths 	unsigned int	st_ino;
1274540635baSths 	unsigned int	st_mode;
1275540635baSths 	unsigned int	st_nlink;
1276540635baSths 	int		st_uid;
1277540635baSths 	int		st_gid;
1278540635baSths 	unsigned 	st_rdev;
1279540635baSths 	unsigned int	st_pad2[2];
1280540635baSths 	unsigned int	st_size;
1281540635baSths 	unsigned int	st_pad3;
1282540635baSths 	/*
1283540635baSths 	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1284540635baSths 	 * but we don't have it under Linux.
1285540635baSths 	 */
1286540635baSths 	unsigned int		target_st_atime;
1287540635baSths 	unsigned int		target_st_atime_nsec;
1288540635baSths 	unsigned int		target_st_mtime;
1289540635baSths 	unsigned int		target_st_mtime_nsec;
1290540635baSths 	unsigned int		target_st_ctime;
1291540635baSths 	unsigned int		target_st_ctime_nsec;
1292540635baSths 	unsigned int		st_blksize;
1293540635baSths 	unsigned int		st_blocks;
1294540635baSths 	unsigned int		st_pad4[14];
1295540635baSths };
1296540635baSths 
1297540635baSths /*
1298540635baSths  * This matches struct stat64 in glibc2.1, hence the absolutely insane
1299540635baSths  * amounts of padding around dev_t's.  The memory layout is the same as of
1300540635baSths  * struct stat of the 64-bit kernel.
1301540635baSths  */
1302540635baSths 
1303540635baSths struct target_stat64 {
1304540635baSths 	unsigned int	st_dev;
1305540635baSths 	unsigned int	st_pad0[3];	/* Reserved for st_dev expansion  */
1306540635baSths 
1307540635baSths 	target_ulong	st_ino;
1308540635baSths 
1309540635baSths         unsigned int	st_mode;
1310540635baSths         unsigned int	st_nlink;
1311540635baSths 
1312540635baSths 	int		st_uid;
1313540635baSths 	int		st_gid;
1314540635baSths 
1315540635baSths 	unsigned int	st_rdev;
1316540635baSths 	unsigned int	st_pad1[3];	/* Reserved for st_rdev expansion  */
1317540635baSths 
1318540635baSths 	int		st_size;
1319540635baSths 
1320540635baSths 	/*
1321540635baSths 	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1322540635baSths 	 * but we don't have it under Linux.
1323540635baSths 	 */
1324540635baSths 	int		target_st_atime;
1325540635baSths 	unsigned int	target_st_atime_nsec;	/* Reserved for st_atime expansion  */
1326540635baSths 
1327540635baSths 	int		target_st_mtime;
1328540635baSths 	unsigned int	target_st_mtime_nsec;	/* Reserved for st_mtime expansion  */
1329540635baSths 
1330540635baSths 	int		target_st_ctime;
1331540635baSths 	unsigned int	target_st_ctime_nsec;	/* Reserved for st_ctime expansion  */
1332540635baSths 
1333540635baSths 	unsigned int	st_blksize;
1334540635baSths 	unsigned int	st_pad2;
1335540635baSths 
1336540635baSths 	int		st_blocks;
1337540635baSths };
1338540635baSths 
1339d26bc211Sths #elif defined(TARGET_ABI_MIPSO32)
1340048f6b4dSbellard 
1341048f6b4dSbellard struct target_stat {
1342048f6b4dSbellard 	unsigned	st_dev;
1343992f48a0Sblueswir1 	abi_long	st_pad1[3];		/* Reserved for network id */
1344992f48a0Sblueswir1 	abi_ulong	st_ino;
1345048f6b4dSbellard 	unsigned int	st_mode;
1346048f6b4dSbellard 	unsigned int	st_nlink;
1347048f6b4dSbellard 	int		st_uid;
1348048f6b4dSbellard 	int		st_gid;
1349048f6b4dSbellard 	unsigned 	st_rdev;
1350992f48a0Sblueswir1 	abi_long	st_pad2[2];
1351992f48a0Sblueswir1 	abi_long	st_size;
1352992f48a0Sblueswir1 	abi_long	st_pad3;
1353048f6b4dSbellard 	/*
1354048f6b4dSbellard 	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1355048f6b4dSbellard 	 * but we don't have it under Linux.
1356048f6b4dSbellard 	 */
1357992f48a0Sblueswir1 	abi_long		target_st_atime;
1358992f48a0Sblueswir1 	abi_long		target_st_atime_nsec;
1359992f48a0Sblueswir1 	abi_long		target_st_mtime;
1360992f48a0Sblueswir1 	abi_long		target_st_mtime_nsec;
1361992f48a0Sblueswir1 	abi_long		target_st_ctime;
1362992f48a0Sblueswir1 	abi_long		target_st_ctime_nsec;
1363992f48a0Sblueswir1 	abi_long		st_blksize;
1364992f48a0Sblueswir1 	abi_long		st_blocks;
1365992f48a0Sblueswir1 	abi_long		st_pad4[14];
1366048f6b4dSbellard };
1367048f6b4dSbellard 
1368048f6b4dSbellard /*
1369048f6b4dSbellard  * This matches struct stat64 in glibc2.1, hence the absolutely insane
1370048f6b4dSbellard  * amounts of padding around dev_t's.  The memory layout is the same as of
1371048f6b4dSbellard  * struct stat of the 64-bit kernel.
1372048f6b4dSbellard  */
1373048f6b4dSbellard 
1374048f6b4dSbellard struct target_stat64 {
1375992f48a0Sblueswir1 	abi_ulong	st_dev;
1376992f48a0Sblueswir1 	abi_ulong	st_pad0[3];	/* Reserved for st_dev expansion  */
1377048f6b4dSbellard 
1378048f6b4dSbellard 	uint64_t	st_ino;
1379048f6b4dSbellard 
1380048f6b4dSbellard         unsigned int	st_mode;
1381048f6b4dSbellard         unsigned int	st_nlink;
1382048f6b4dSbellard 
1383048f6b4dSbellard 	int		st_uid;
1384048f6b4dSbellard 	int		st_gid;
1385048f6b4dSbellard 
1386992f48a0Sblueswir1 	abi_ulong	st_rdev;
1387992f48a0Sblueswir1 	abi_ulong	st_pad1[3];	/* Reserved for st_rdev expansion  */
1388048f6b4dSbellard 
1389048f6b4dSbellard 	int64_t 	st_size;
1390048f6b4dSbellard 
1391048f6b4dSbellard 	/*
1392048f6b4dSbellard 	 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
1393048f6b4dSbellard 	 * but we don't have it under Linux.
1394048f6b4dSbellard 	 */
1395992f48a0Sblueswir1 	abi_long	target_st_atime;
1396992f48a0Sblueswir1 	abi_ulong	target_st_atime_nsec;	/* Reserved for st_atime expansion  */
1397048f6b4dSbellard 
1398992f48a0Sblueswir1 	abi_long	target_st_mtime;
1399992f48a0Sblueswir1 	abi_ulong	target_st_mtime_nsec;	/* Reserved for st_mtime expansion  */
1400048f6b4dSbellard 
1401992f48a0Sblueswir1 	abi_long	target_st_ctime;
1402992f48a0Sblueswir1 	abi_ulong	target_st_ctime_nsec;	/* Reserved for st_ctime expansion  */
1403048f6b4dSbellard 
1404992f48a0Sblueswir1 	abi_ulong	st_blksize;
1405992f48a0Sblueswir1 	abi_ulong	st_pad2;
1406048f6b4dSbellard 
1407048f6b4dSbellard 	int64_t  	st_blocks;
1408048f6b4dSbellard };
14097a3148a9Sj_mayer 
14107a3148a9Sj_mayer #elif defined(TARGET_ALPHA)
14117a3148a9Sj_mayer 
14127a3148a9Sj_mayer struct target_stat {
14137a3148a9Sj_mayer        unsigned int    st_dev;
14147a3148a9Sj_mayer        unsigned int    st_ino;
14157a3148a9Sj_mayer        unsigned int    st_mode;
14167a3148a9Sj_mayer        unsigned int    st_nlink;
14177a3148a9Sj_mayer        unsigned int    st_uid;
14187a3148a9Sj_mayer        unsigned int    st_gid;
14197a3148a9Sj_mayer        unsigned int    st_rdev;
1420992f48a0Sblueswir1        abi_long     st_size;
1421992f48a0Sblueswir1        abi_ulong    target_st_atime;
1422992f48a0Sblueswir1        abi_ulong    target_st_mtime;
1423992f48a0Sblueswir1        abi_ulong    target_st_ctime;
14247a3148a9Sj_mayer        unsigned int    st_blksize;
14257a3148a9Sj_mayer        unsigned int    st_blocks;
14267a3148a9Sj_mayer        unsigned int    st_flags;
14277a3148a9Sj_mayer        unsigned int    st_gen;
14287a3148a9Sj_mayer };
14297a3148a9Sj_mayer 
14307a3148a9Sj_mayer struct target_stat64 {
1431992f48a0Sblueswir1        abi_ulong    st_dev;
1432992f48a0Sblueswir1        abi_ulong    st_ino;
1433992f48a0Sblueswir1        abi_ulong    st_rdev;
1434992f48a0Sblueswir1        abi_long     st_size;
1435992f48a0Sblueswir1        abi_ulong    st_blocks;
14367a3148a9Sj_mayer 
14377a3148a9Sj_mayer        unsigned int    st_mode;
14387a3148a9Sj_mayer        unsigned int    st_uid;
14397a3148a9Sj_mayer        unsigned int    st_gid;
14407a3148a9Sj_mayer        unsigned int    st_blksize;
14417a3148a9Sj_mayer        unsigned int    st_nlink;
14427a3148a9Sj_mayer        unsigned int    __pad0;
14437a3148a9Sj_mayer 
1444992f48a0Sblueswir1        abi_ulong    target_st_atime;
1445992f48a0Sblueswir1        abi_ulong    target_st_atime_nsec;
1446992f48a0Sblueswir1        abi_ulong    target_st_mtime;
1447992f48a0Sblueswir1        abi_ulong    target_st_mtime_nsec;
1448992f48a0Sblueswir1        abi_ulong    target_st_ctime;
1449992f48a0Sblueswir1        abi_ulong    target_st_ctime_nsec;
1450992f48a0Sblueswir1        abi_long     __unused[3];
14517a3148a9Sj_mayer };
14527a3148a9Sj_mayer 
14536db45e65Sths #elif defined(TARGET_SH4)
14546db45e65Sths 
14556db45e65Sths struct target_stat {
1456992f48a0Sblueswir1 	abi_ulong  st_dev;
1457992f48a0Sblueswir1 	abi_ulong  st_ino;
14586db45e65Sths 	unsigned short st_mode;
14596db45e65Sths 	unsigned short st_nlink;
14606db45e65Sths 	unsigned short st_uid;
14616db45e65Sths 	unsigned short st_gid;
1462992f48a0Sblueswir1 	abi_ulong  st_rdev;
1463992f48a0Sblueswir1 	abi_ulong  st_size;
1464992f48a0Sblueswir1 	abi_ulong  st_blksize;
1465992f48a0Sblueswir1 	abi_ulong  st_blocks;
1466992f48a0Sblueswir1 	abi_ulong  target_st_atime;
1467992f48a0Sblueswir1 	abi_ulong  target_st_atime_nsec;
1468992f48a0Sblueswir1 	abi_ulong  target_st_mtime;
1469992f48a0Sblueswir1 	abi_ulong  target_st_mtime_nsec;
1470992f48a0Sblueswir1 	abi_ulong  target_st_ctime;
1471992f48a0Sblueswir1 	abi_ulong  target_st_ctime_nsec;
1472992f48a0Sblueswir1 	abi_ulong  __unused4;
1473992f48a0Sblueswir1 	abi_ulong  __unused5;
14746db45e65Sths };
14756db45e65Sths 
14766db45e65Sths /* This matches struct stat64 in glibc2.1, hence the absolutely
14776db45e65Sths  * insane amounts of padding around dev_t's.
14786db45e65Sths  */
147991bd8ce9Saurel32 struct __attribute__((__packed__)) target_stat64 {
14806db45e65Sths 	unsigned long long	st_dev;
14816db45e65Sths 	unsigned char	__pad0[4];
14826db45e65Sths 
14836db45e65Sths #define TARGET_STAT64_HAS_BROKEN_ST_INO	1
1484992f48a0Sblueswir1 	abi_ulong	__st_ino;
14856db45e65Sths 
14866db45e65Sths 	unsigned int	st_mode;
14876db45e65Sths 	unsigned int	st_nlink;
14886db45e65Sths 
1489992f48a0Sblueswir1 	abi_ulong	st_uid;
1490992f48a0Sblueswir1 	abi_ulong	st_gid;
14916db45e65Sths 
14926db45e65Sths 	unsigned long long	st_rdev;
14936db45e65Sths 	unsigned char	__pad3[4];
14946db45e65Sths 
14956db45e65Sths 	long long	st_size;
1496992f48a0Sblueswir1 	abi_ulong	st_blksize;
14976db45e65Sths 
14986db45e65Sths 	unsigned long long	st_blocks;	/* Number 512-byte blocks allocated. */
14996db45e65Sths 
1500992f48a0Sblueswir1 	abi_ulong	target_st_atime;
1501992f48a0Sblueswir1 	abi_ulong	target_st_atime_nsec;
15026db45e65Sths 
1503992f48a0Sblueswir1 	abi_ulong	target_st_mtime;
1504992f48a0Sblueswir1 	abi_ulong	target_st_mtime_nsec;
15056db45e65Sths 
1506992f48a0Sblueswir1 	abi_ulong	target_st_ctime;
1507992f48a0Sblueswir1 	abi_ulong	target_st_ctime_nsec;
15086db45e65Sths 
15096db45e65Sths 	unsigned long long	st_ino;
15106db45e65Sths };
15116db45e65Sths 
1512d2fd1af7Sbellard #elif defined(TARGET_I386) && !defined(TARGET_ABI32)
1513d2fd1af7Sbellard struct target_stat {
1514d2fd1af7Sbellard 	abi_ulong	st_dev;
1515d2fd1af7Sbellard 	abi_ulong	st_ino;
1516d2fd1af7Sbellard 	abi_ulong	st_nlink;
1517d2fd1af7Sbellard 
1518d2fd1af7Sbellard 	unsigned int	st_mode;
1519d2fd1af7Sbellard 	unsigned int	st_uid;
1520d2fd1af7Sbellard 	unsigned int	st_gid;
1521d2fd1af7Sbellard 	unsigned int	__pad0;
1522d2fd1af7Sbellard 	abi_ulong	st_rdev;
1523d2fd1af7Sbellard 	abi_long	st_size;
1524d2fd1af7Sbellard 	abi_long	st_blksize;
1525d2fd1af7Sbellard     	abi_long	st_blocks;	/* Number 512-byte blocks allocated. */
1526d2fd1af7Sbellard 
1527d2fd1af7Sbellard 	abi_ulong	target_st_atime;
1528d2fd1af7Sbellard 	abi_ulong 	target_st_atime_nsec;
1529d2fd1af7Sbellard 	abi_ulong	target_st_mtime;
1530d2fd1af7Sbellard 	abi_ulong	target_st_mtime_nsec;
1531d2fd1af7Sbellard 	abi_ulong	target_st_ctime;
1532d2fd1af7Sbellard 	abi_ulong       target_st_ctime_nsec;
1533d2fd1af7Sbellard 
1534d2fd1af7Sbellard   	abi_long	__unused[3];
1535d2fd1af7Sbellard };
1536048f6b4dSbellard #else
1537048f6b4dSbellard #error unsupported CPU
1538048f6b4dSbellard #endif
15392521d698Sbellard 
15404ce6f8deSths typedef struct {
15414ce6f8deSths         int     val[2];
15424ce6f8deSths } target_fsid_t;
15434ce6f8deSths 
154456c8f68fSbellard #ifdef TARGET_MIPS
1545d26bc211Sths #ifdef TARGET_ABI_MIPSN32
1546540635baSths struct target_statfs {
1547540635baSths 	int32_t			f_type;
1548540635baSths 	int32_t			f_bsize;
1549540635baSths 	int32_t			f_frsize;	/* Fragment size - unsupported */
1550540635baSths 	int32_t			f_blocks;
1551540635baSths 	int32_t			f_bfree;
1552540635baSths 	int32_t			f_files;
1553540635baSths 	int32_t			f_ffree;
1554540635baSths 	int32_t			f_bavail;
1555540635baSths 
1556540635baSths 	/* Linux specials */
1557540635baSths 	target_fsid_t		f_fsid;
1558540635baSths 	int32_t			f_namelen;
1559540635baSths 	int32_t			f_spare[6];
1560540635baSths };
1561540635baSths #else
156256c8f68fSbellard struct target_statfs {
1563992f48a0Sblueswir1 	abi_long		f_type;
1564992f48a0Sblueswir1 	abi_long		f_bsize;
1565992f48a0Sblueswir1 	abi_long		f_frsize;	/* Fragment size - unsupported */
1566992f48a0Sblueswir1 	abi_long		f_blocks;
1567992f48a0Sblueswir1 	abi_long		f_bfree;
1568992f48a0Sblueswir1 	abi_long		f_files;
1569992f48a0Sblueswir1 	abi_long		f_ffree;
1570992f48a0Sblueswir1 	abi_long		f_bavail;
157156c8f68fSbellard 
157256c8f68fSbellard 	/* Linux specials */
15734ce6f8deSths 	target_fsid_t		f_fsid;
1574992f48a0Sblueswir1 	abi_long		f_namelen;
1575992f48a0Sblueswir1 	abi_long		f_spare[6];
157656c8f68fSbellard };
1577540635baSths #endif
157856c8f68fSbellard 
157956c8f68fSbellard struct target_statfs64 {
158056c8f68fSbellard 	uint32_t	f_type;
158156c8f68fSbellard 	uint32_t	f_bsize;
158256c8f68fSbellard 	uint32_t	f_frsize;	/* Fragment size - unsupported */
158356c8f68fSbellard 	uint32_t	__pad;
158456c8f68fSbellard 	uint64_t	f_blocks;
158556c8f68fSbellard 	uint64_t	f_bfree;
158656c8f68fSbellard 	uint64_t	f_files;
158756c8f68fSbellard 	uint64_t	f_ffree;
158856c8f68fSbellard 	uint64_t	f_bavail;
15894ce6f8deSths 	target_fsid_t	f_fsid;
159056c8f68fSbellard 	uint32_t	f_namelen;
159156c8f68fSbellard 	uint32_t	f_spare[6];
159256c8f68fSbellard };
1593c4d10628Sbalrog #elif (defined(TARGET_PPC64) || defined(TARGET_X86_64) || \
1594c4d10628Sbalrog        defined(TARGET_SPARC64)) && !defined(TARGET_ABI32)
1595325e651fSj_mayer struct target_statfs {
1596325e651fSj_mayer 	abi_long f_type;
1597325e651fSj_mayer 	abi_long f_bsize;
1598325e651fSj_mayer 	abi_long f_blocks;
1599325e651fSj_mayer 	abi_long f_bfree;
1600325e651fSj_mayer 	abi_long f_bavail;
1601325e651fSj_mayer 	abi_long f_files;
1602325e651fSj_mayer 	abi_long f_ffree;
1603325e651fSj_mayer 	target_fsid_t f_fsid;
1604325e651fSj_mayer 	abi_long f_namelen;
1605325e651fSj_mayer 	abi_long f_frsize;
1606325e651fSj_mayer 	abi_long f_spare[5];
1607325e651fSj_mayer };
1608325e651fSj_mayer 
1609325e651fSj_mayer struct target_statfs64 {
1610325e651fSj_mayer 	abi_long f_type;
1611325e651fSj_mayer 	abi_long f_bsize;
1612325e651fSj_mayer 	abi_long f_blocks;
1613325e651fSj_mayer 	abi_long f_bfree;
1614325e651fSj_mayer 	abi_long f_bavail;
1615325e651fSj_mayer 	abi_long f_files;
1616325e651fSj_mayer 	abi_long f_ffree;
1617325e651fSj_mayer 	target_fsid_t f_fsid;
1618325e651fSj_mayer 	abi_long f_namelen;
1619325e651fSj_mayer 	abi_long f_frsize;
1620325e651fSj_mayer 	abi_long f_spare[5];
1621325e651fSj_mayer };
162256c8f68fSbellard #else
162356c8f68fSbellard struct target_statfs {
162456c8f68fSbellard 	uint32_t f_type;
162556c8f68fSbellard 	uint32_t f_bsize;
162656c8f68fSbellard 	uint32_t f_blocks;
162756c8f68fSbellard 	uint32_t f_bfree;
162856c8f68fSbellard 	uint32_t f_bavail;
162956c8f68fSbellard 	uint32_t f_files;
163056c8f68fSbellard 	uint32_t f_ffree;
16314ce6f8deSths 	target_fsid_t f_fsid;
163256c8f68fSbellard 	uint32_t f_namelen;
163356c8f68fSbellard 	uint32_t f_frsize;
163456c8f68fSbellard 	uint32_t f_spare[5];
163556c8f68fSbellard };
163656c8f68fSbellard 
163756c8f68fSbellard struct target_statfs64 {
163856c8f68fSbellard 	uint32_t f_type;
163956c8f68fSbellard 	uint32_t f_bsize;
164056c8f68fSbellard 	uint64_t f_blocks;
164156c8f68fSbellard 	uint64_t f_bfree;
164256c8f68fSbellard 	uint64_t f_bavail;
164356c8f68fSbellard 	uint64_t f_files;
164456c8f68fSbellard 	uint64_t f_ffree;
16454ce6f8deSths 	target_fsid_t f_fsid;
164656c8f68fSbellard         uint32_t f_namelen;
164756c8f68fSbellard 	uint32_t f_frsize;
164856c8f68fSbellard 	uint32_t f_spare[5];
164956c8f68fSbellard };
165056c8f68fSbellard #endif
165156c8f68fSbellard 
165256c8f68fSbellard 
16532521d698Sbellard #define TARGET_F_DUPFD         0       /* dup */
16542521d698Sbellard #define TARGET_F_GETFD         1       /* get close_on_exec */
16552521d698Sbellard #define TARGET_F_SETFD         2       /* set/clear close_on_exec */
16562521d698Sbellard #define TARGET_F_GETFL         3       /* get file->f_flags */
16572521d698Sbellard #define TARGET_F_SETFL         4       /* set file->f_flags */
16582521d698Sbellard 
16592521d698Sbellard #if defined(TARGET_ALPHA)
16602521d698Sbellard #define TARGET_F_GETLK         7
16612521d698Sbellard #define TARGET_F_SETLK         8
16622521d698Sbellard #define TARGET_F_SETLKW        9
16632521d698Sbellard #define TARGET_F_SETOWN        5       /*  for sockets. */
16642521d698Sbellard #define TARGET_F_GETOWN        6       /*  for sockets. */
16652521d698Sbellard #else
16662521d698Sbellard #define TARGET_F_GETLK         5
16672521d698Sbellard #define TARGET_F_SETLK         6
16682521d698Sbellard #define TARGET_F_SETLKW        7
16692521d698Sbellard #define TARGET_F_SETOWN        8       /*  for sockets. */
16702521d698Sbellard #define TARGET_F_GETOWN        9       /*  for sockets. */
16712521d698Sbellard #endif
16722521d698Sbellard 
16732521d698Sbellard #define TARGET_F_SETSIG        10      /*  for sockets. */
16742521d698Sbellard #define TARGET_F_GETSIG        11      /*  for sockets. */
16752521d698Sbellard 
16762521d698Sbellard #define TARGET_F_GETLK64       12      /*  using 'struct flock64' */
16772521d698Sbellard #define TARGET_F_SETLK64       13
16782521d698Sbellard #define TARGET_F_SETLKW64      14
16792521d698Sbellard 
1680f09936acSbellard #if defined (TARGET_ARM)
1681f09936acSbellard #define TARGET_O_ACCMODE          0003
1682f09936acSbellard #define TARGET_O_RDONLY             00
1683f09936acSbellard #define TARGET_O_WRONLY             01
1684f09936acSbellard #define TARGET_O_RDWR               02
1685f09936acSbellard #define TARGET_O_CREAT            0100 /* not fcntl */
1686f09936acSbellard #define TARGET_O_EXCL             0200 /* not fcntl */
1687f09936acSbellard #define TARGET_O_NOCTTY           0400 /* not fcntl */
1688f09936acSbellard #define TARGET_O_TRUNC           01000 /* not fcntl */
1689f09936acSbellard #define TARGET_O_APPEND          02000
1690f09936acSbellard #define TARGET_O_NONBLOCK        04000
1691048f6b4dSbellard #define TARGET_O_NDELAY        TARGET_O_NONBLOCK
1692f09936acSbellard #define TARGET_O_SYNC           010000
1693f09936acSbellard #define TARGET_FASYNC           020000 /* fcntl, for BSD compatibility */
1694f09936acSbellard #define TARGET_O_DIRECTORY      040000 /* must be a directory */
1695f09936acSbellard #define TARGET_O_NOFOLLOW      0100000 /* don't follow links */
1696f09936acSbellard #define TARGET_O_DIRECT        0200000 /* direct disk access hint */
1697f09936acSbellard #define TARGET_O_LARGEFILE     0400000
1698f09936acSbellard #elif defined (TARGET_PPC)
1699ffa65c3bSbellard #define TARGET_O_ACCMODE          0003
1700ffa65c3bSbellard #define TARGET_O_RDONLY             00
1701ffa65c3bSbellard #define TARGET_O_WRONLY             01
1702ffa65c3bSbellard #define TARGET_O_RDWR               02
1703ffa65c3bSbellard #define TARGET_O_CREAT            0100 /* not fcntl */
1704ffa65c3bSbellard #define TARGET_O_EXCL             0200 /* not fcntl */
1705ffa65c3bSbellard #define TARGET_O_NOCTTY           0400 /* not fcntl */
1706ffa65c3bSbellard #define TARGET_O_TRUNC           01000 /* not fcntl */
1707ffa65c3bSbellard #define TARGET_O_APPEND          02000
1708ffa65c3bSbellard #define TARGET_O_NONBLOCK        04000
1709048f6b4dSbellard #define TARGET_O_NDELAY        TARGET_O_NONBLOCK
1710ffa65c3bSbellard #define TARGET_O_SYNC           010000
1711ffa65c3bSbellard #define TARGET_FASYNC           020000 /* fcntl, for BSD compatibility */
1712ffa65c3bSbellard #define TARGET_O_DIRECTORY      040000 /* must be a directory */
1713ffa65c3bSbellard #define TARGET_O_NOFOLLOW      0100000 /* don't follow links */
1714ffa65c3bSbellard #define TARGET_O_LARGEFILE     0200000
1715ffa65c3bSbellard #define TARGET_O_DIRECT        0400000 /* direct disk access hint */
17166d5e216dSbellard #elif defined (TARGET_SPARC)
17176d5e216dSbellard #define TARGET_O_RDONLY        0x0000
17186d5e216dSbellard #define TARGET_O_WRONLY        0x0001
17196d5e216dSbellard #define TARGET_O_RDWR          0x0002
17206d5e216dSbellard #define TARGET_O_ACCMODE       0x0003
17216d5e216dSbellard #define TARGET_O_APPEND        0x0008
17226d5e216dSbellard #define TARGET_FASYNC          0x0040  /* fcntl, for BSD compatibility */
17236d5e216dSbellard #define TARGET_O_CREAT         0x0200  /* not fcntl */
17246d5e216dSbellard #define TARGET_O_TRUNC         0x0400  /* not fcntl */
17256d5e216dSbellard #define TARGET_O_EXCL          0x0800  /* not fcntl */
17266d5e216dSbellard #define TARGET_O_SYNC          0x2000
17276d5e216dSbellard #define TARGET_O_NONBLOCK      0x4000
1728048f6b4dSbellard #define TARGET_O_NDELAY        (0x0004 | TARGET_O_NONBLOCK)
17296d5e216dSbellard #define TARGET_O_NOCTTY        0x8000  /* not fcntl */
17306d5e216dSbellard #define TARGET_O_DIRECTORY     0x10000 /* must be a directory */
17316d5e216dSbellard #define TARGET_O_NOFOLLOW      0x20000 /* don't follow links */
17326d5e216dSbellard #define TARGET_O_LARGEFILE     0x40000
17336d5e216dSbellard #define TARGET_O_DIRECT        0x100000 /* direct disk access hint */
1734048f6b4dSbellard #elif defined(TARGET_MIPS)
1735048f6b4dSbellard #define TARGET_O_ACCMODE	0x0003
1736048f6b4dSbellard #define TARGET_O_RDONLY	0x0000
1737048f6b4dSbellard #define TARGET_O_WRONLY	0x0001
1738048f6b4dSbellard #define TARGET_O_RDWR		0x0002
1739048f6b4dSbellard #define TARGET_O_APPEND	0x0008
1740048f6b4dSbellard #define TARGET_O_SYNC		0x0010
1741048f6b4dSbellard #define TARGET_O_NONBLOCK	0x0080
1742048f6b4dSbellard #define TARGET_O_CREAT         0x0100	/* not fcntl */
1743048f6b4dSbellard #define TARGET_O_TRUNC		0x0200	/* not fcntl */
1744048f6b4dSbellard #define TARGET_O_EXCL		0x0400	/* not fcntl */
1745048f6b4dSbellard #define TARGET_O_NOCTTY	0x0800	/* not fcntl */
1746048f6b4dSbellard #define TARGET_FASYNC		0x1000	/* fcntl, for BSD compatibility */
1747048f6b4dSbellard #define TARGET_O_LARGEFILE	0x2000	/* allow large file opens */
1748048f6b4dSbellard #define TARGET_O_DIRECT	0x8000	/* direct disk access hint */
1749048f6b4dSbellard #define TARGET_O_DIRECTORY	0x10000	/* must be a directory */
1750048f6b4dSbellard #define TARGET_O_NOFOLLOW	0x20000	/* don't follow links */
1751048f6b4dSbellard #define TARGET_O_NOATIME	0x40000
1752048f6b4dSbellard #define TARGET_O_NDELAY	TARGET_O_NONBLOCK
17531f961124Saurel32 #elif defined(TARGET_ALPHA)
17541f961124Saurel32 #define TARGET_O_ACCMODE	0x0003
17551f961124Saurel32 #define TARGET_O_RDONLY	0x0000
17561f961124Saurel32 #define TARGET_O_WRONLY	0x0001
17571f961124Saurel32 #define TARGET_O_RDWR		0x0002
17581f961124Saurel32 #define TARGET_O_APPEND	0x0008
17591f961124Saurel32 #define TARGET_O_SYNC		0x4000
17601f961124Saurel32 #define TARGET_O_NONBLOCK	0x0004
17611f961124Saurel32 #define TARGET_O_CREAT         0x0200	/* not fcntl */
17621f961124Saurel32 #define TARGET_O_TRUNC		0x0400	/* not fcntl */
17631f961124Saurel32 #define TARGET_O_EXCL		0x0800	/* not fcntl */
17641f961124Saurel32 #define TARGET_O_NOCTTY	0x1000	/* not fcntl */
17651f961124Saurel32 #define TARGET_FASYNC		0x2000	/* fcntl, for BSD compatibility */
17661f961124Saurel32 #define TARGET_O_LARGEFILE	0x0000	/* not necessary, always 64-bit */
17671f961124Saurel32 #define TARGET_O_DIRECT	0x80000	/* direct disk access hint */
17681f961124Saurel32 #define TARGET_O_DIRECTORY	0x8000	/* must be a directory */
17691f961124Saurel32 #define TARGET_O_NOFOLLOW	0x10000	/* don't follow links */
17701f961124Saurel32 #define TARGET_O_NOATIME	0x100000
17711f961124Saurel32 #define TARGET_O_NDELAY	TARGET_O_NONBLOCK
1772ffa65c3bSbellard #else
1773ffa65c3bSbellard #define TARGET_O_ACCMODE          0003
1774ffa65c3bSbellard #define TARGET_O_RDONLY             00
1775ffa65c3bSbellard #define TARGET_O_WRONLY             01
1776ffa65c3bSbellard #define TARGET_O_RDWR               02
1777ffa65c3bSbellard #define TARGET_O_CREAT            0100 /* not fcntl */
1778ffa65c3bSbellard #define TARGET_O_EXCL             0200 /* not fcntl */
1779ffa65c3bSbellard #define TARGET_O_NOCTTY           0400 /* not fcntl */
1780ffa65c3bSbellard #define TARGET_O_TRUNC           01000 /* not fcntl */
1781ffa65c3bSbellard #define TARGET_O_APPEND          02000
1782ffa65c3bSbellard #define TARGET_O_NONBLOCK        04000
1783048f6b4dSbellard #define TARGET_O_NDELAY        TARGET_O_NONBLOCK
1784ffa65c3bSbellard #define TARGET_O_SYNC           010000
1785ffa65c3bSbellard #define TARGET_FASYNC           020000 /* fcntl, for BSD compatibility */
1786ffa65c3bSbellard #define TARGET_O_DIRECT         040000 /* direct disk access hint */
1787ffa65c3bSbellard #define TARGET_O_LARGEFILE     0100000
1788ffa65c3bSbellard #define TARGET_O_DIRECTORY     0200000 /* must be a directory */
1789ffa65c3bSbellard #define TARGET_O_NOFOLLOW      0400000 /* don't follow links */
1790ffa65c3bSbellard #endif
1791ffa65c3bSbellard 
17922521d698Sbellard struct target_flock {
17932521d698Sbellard 	short l_type;
17942521d698Sbellard 	short l_whence;
1795992f48a0Sblueswir1 	abi_ulong l_start;
1796992f48a0Sblueswir1 	abi_ulong l_len;
17972521d698Sbellard 	int l_pid;
17982521d698Sbellard };
17992521d698Sbellard 
18002521d698Sbellard struct target_flock64 {
18012521d698Sbellard 	short  l_type;
18022521d698Sbellard 	short  l_whence;
1803ce3f0e2fSaurel32 #if defined(TARGET_PPC) || defined(TARGET_X86_64) || defined(TARGET_MIPS) || defined(TARGET_SPARC) || defined(TARGET_HPPA)
1804ce3f0e2fSaurel32         int __pad;
1805ce3f0e2fSaurel32 #endif
18062521d698Sbellard 	unsigned long long l_start;
18072521d698Sbellard 	unsigned long long l_len;
18082521d698Sbellard 	int  l_pid;
1809ce4defa0Spbrook }__attribute__((packed));
18102521d698Sbellard 
1811ce4defa0Spbrook #ifdef TARGET_ARM
1812ce4defa0Spbrook struct target_eabi_flock64 {
1813ce4defa0Spbrook 	short  l_type;
1814ce4defa0Spbrook 	short  l_whence;
1815ce4defa0Spbrook         int __pad;
1816ce4defa0Spbrook 	unsigned long long l_start;
1817ce4defa0Spbrook 	unsigned long long l_len;
1818ce4defa0Spbrook 	int  l_pid;
1819ce4defa0Spbrook }__attribute__((packed));
1820ce4defa0Spbrook #endif
18212521d698Sbellard 
18222521d698Sbellard /* soundcard defines */
18232521d698Sbellard /* XXX: convert them all to arch indepedent entries */
18242521d698Sbellard #define TARGET_SNDCTL_COPR_HALT           TARGET_IOWR('C',  7, int);
18252521d698Sbellard #define TARGET_SNDCTL_COPR_LOAD           0xcfb04301
18262521d698Sbellard #define TARGET_SNDCTL_COPR_RCODE          0xc0144303
18272521d698Sbellard #define TARGET_SNDCTL_COPR_RCVMSG         0x8fa44309
18282521d698Sbellard #define TARGET_SNDCTL_COPR_RDATA          0xc0144302
18292521d698Sbellard #define TARGET_SNDCTL_COPR_RESET          0x00004300
18302521d698Sbellard #define TARGET_SNDCTL_COPR_RUN            0xc0144306
18312521d698Sbellard #define TARGET_SNDCTL_COPR_SENDMSG        0xcfa44308
18322521d698Sbellard #define TARGET_SNDCTL_COPR_WCODE          0x40144305
18332521d698Sbellard #define TARGET_SNDCTL_COPR_WDATA          0x40144304
18342521d698Sbellard #define TARGET_SNDCTL_DSP_RESET           TARGET_IO('P', 0)
18352521d698Sbellard #define TARGET_SNDCTL_DSP_SYNC            TARGET_IO('P', 1)
18362521d698Sbellard #define TARGET_SNDCTL_DSP_SPEED           TARGET_IOWR('P', 2, int)
18372521d698Sbellard #define TARGET_SNDCTL_DSP_STEREO          TARGET_IOWR('P', 3, int)
18382521d698Sbellard #define TARGET_SNDCTL_DSP_GETBLKSIZE      TARGET_IOWR('P', 4, int)
18392521d698Sbellard #define TARGET_SNDCTL_DSP_SETFMT          TARGET_IOWR('P', 5, int)
18402521d698Sbellard #define TARGET_SNDCTL_DSP_CHANNELS        TARGET_IOWR('P', 6, int)
18412521d698Sbellard #define TARGET_SOUND_PCM_WRITE_FILTER     TARGET_IOWR('P', 7, int)
18422521d698Sbellard #define TARGET_SNDCTL_DSP_POST            TARGET_IO('P', 8)
18432521d698Sbellard #define TARGET_SNDCTL_DSP_SUBDIVIDE       TARGET_IOWR('P', 9, int)
18442521d698Sbellard #define TARGET_SNDCTL_DSP_SETFRAGMENT     TARGET_IOWR('P',10, int)
18452521d698Sbellard #define TARGET_SNDCTL_DSP_GETFMTS         TARGET_IOR('P', 11, int)
18462521d698Sbellard #define TARGET_SNDCTL_DSP_GETOSPACE       TARGET_IORU('P',12)
18472521d698Sbellard #define TARGET_SNDCTL_DSP_GETISPACE       TARGET_IORU('P',13)
18482521d698Sbellard #define TARGET_SNDCTL_DSP_GETCAPS         TARGET_IOR('P', 15, int)
18492521d698Sbellard #define TARGET_SNDCTL_DSP_GETTRIGGER      TARGET_IOR('P',16, int)
18502521d698Sbellard #define TARGET_SNDCTL_DSP_GETIPTR         TARGET_IORU('P',17)
18512521d698Sbellard #define TARGET_SNDCTL_DSP_GETOPTR         TARGET_IORU('P',18)
18522521d698Sbellard #define TARGET_SNDCTL_DSP_MAPINBUF        0x80085013
18532521d698Sbellard #define TARGET_SNDCTL_DSP_MAPOUTBUF       0x80085014
18542521d698Sbellard #define TARGET_SNDCTL_DSP_NONBLOCK        0x0000500e
18552521d698Sbellard #define TARGET_SNDCTL_DSP_SAMPLESIZE      0xc0045005
18562521d698Sbellard #define TARGET_SNDCTL_DSP_SETDUPLEX       0x00005016
18572521d698Sbellard #define TARGET_SNDCTL_DSP_SETSYNCRO       0x00005015
18582521d698Sbellard #define TARGET_SNDCTL_DSP_SETTRIGGER      0x40045010
18592521d698Sbellard #define TARGET_SNDCTL_FM_4OP_ENABLE       0x4004510f
18602521d698Sbellard #define TARGET_SNDCTL_FM_LOAD_INSTR       0x40285107
18612521d698Sbellard #define TARGET_SNDCTL_MIDI_INFO           0xc074510c
18622521d698Sbellard #define TARGET_SNDCTL_MIDI_MPUCMD         0xc0216d02
18632521d698Sbellard #define TARGET_SNDCTL_MIDI_MPUMODE        0xc0046d01
18642521d698Sbellard #define TARGET_SNDCTL_MIDI_PRETIME        0xc0046d00
18652521d698Sbellard #define TARGET_SNDCTL_PMGR_ACCESS         0xcfb85110
18662521d698Sbellard #define TARGET_SNDCTL_PMGR_IFACE          0xcfb85001
18672521d698Sbellard #define TARGET_SNDCTL_SEQ_CTRLRATE        0xc0045103
18682521d698Sbellard #define TARGET_SNDCTL_SEQ_GETINCOUNT      0x80045105
18692521d698Sbellard #define TARGET_SNDCTL_SEQ_GETOUTCOUNT     0x80045104
18702521d698Sbellard #define TARGET_SNDCTL_SEQ_NRMIDIS         0x8004510b
18712521d698Sbellard #define TARGET_SNDCTL_SEQ_NRSYNTHS        0x8004510a
18722521d698Sbellard #define TARGET_SNDCTL_SEQ_OUTOFBAND       0x40085112
18732521d698Sbellard #define TARGET_SNDCTL_SEQ_PANIC           0x00005111
18742521d698Sbellard #define TARGET_SNDCTL_SEQ_PERCMODE        0x40045106
18752521d698Sbellard #define TARGET_SNDCTL_SEQ_RESET           0x00005100
18762521d698Sbellard #define TARGET_SNDCTL_SEQ_RESETSAMPLES    0x40045109
18772521d698Sbellard #define TARGET_SNDCTL_SEQ_SYNC            0x00005101
18782521d698Sbellard #define TARGET_SNDCTL_SEQ_TESTMIDI        0x40045108
18792521d698Sbellard #define TARGET_SNDCTL_SEQ_THRESHOLD       0x4004510d
18802521d698Sbellard #define TARGET_SNDCTL_SEQ_TRESHOLD        0x4004510d
18812521d698Sbellard #define TARGET_SNDCTL_SYNTH_INFO          0xc08c5102
18822521d698Sbellard #define TARGET_SNDCTL_SYNTH_MEMAVL        0xc004510e
18832521d698Sbellard #define TARGET_SNDCTL_TMR_CONTINUE        0x00005404
18842521d698Sbellard #define TARGET_SNDCTL_TMR_METRONOME       0x40045407
18852521d698Sbellard #define TARGET_SNDCTL_TMR_SELECT          0x40045408
18862521d698Sbellard #define TARGET_SNDCTL_TMR_SOURCE          0xc0045406
18872521d698Sbellard #define TARGET_SNDCTL_TMR_START           0x00005402
18882521d698Sbellard #define TARGET_SNDCTL_TMR_STOP            0x00005403
18892521d698Sbellard #define TARGET_SNDCTL_TMR_TEMPO           0xc0045405
18902521d698Sbellard #define TARGET_SNDCTL_TMR_TIMEBASE        0xc0045401
18912521d698Sbellard #define TARGET_SOUND_PCM_READ_RATE        0x80045002
18922521d698Sbellard #define TARGET_SOUND_PCM_READ_CHANNELS    0x80045006
18932521d698Sbellard #define TARGET_SOUND_PCM_READ_BITS        0x80045005
18942521d698Sbellard #define TARGET_SOUND_PCM_READ_FILTER      0x80045007
18952521d698Sbellard #define TARGET_SOUND_MIXER_INFO           TARGET_IOR ('M', 101, mixer_info)
18962521d698Sbellard #define TARGET_SOUND_MIXER_ACCESS         0xc0804d66
18972521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE1       TARGET_IOWR('M', 111, int)
18982521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE2       TARGET_IOWR('M', 112, int)
18992521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE3       TARGET_IOWR('M', 113, int)
19002521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE4       TARGET_IOWR('M', 114, int)
19012521d698Sbellard #define TARGET_SOUND_MIXER_PRIVATE5       TARGET_IOWR('M', 115, int)
19022521d698Sbellard 
19032521d698Sbellard #define TARGET_MIXER_READ(dev)	TARGET_IOR('M', dev, int)
19042521d698Sbellard 
19052521d698Sbellard #define TARGET_SOUND_MIXER_READ_VOLUME		TARGET_MIXER_READ(SOUND_MIXER_VOLUME)
19062521d698Sbellard #define TARGET_SOUND_MIXER_READ_BASS		TARGET_MIXER_READ(SOUND_MIXER_BASS)
19072521d698Sbellard #define TARGET_SOUND_MIXER_READ_TREBLE		TARGET_MIXER_READ(SOUND_MIXER_TREBLE)
19082521d698Sbellard #define TARGET_SOUND_MIXER_READ_SYNTH		TARGET_MIXER_READ(SOUND_MIXER_SYNTH)
19092521d698Sbellard #define TARGET_SOUND_MIXER_READ_PCM		TARGET_MIXER_READ(SOUND_MIXER_PCM)
19102521d698Sbellard #define TARGET_SOUND_MIXER_READ_SPEAKER	        TARGET_MIXER_READ(SOUND_MIXER_SPEAKER)
19112521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE		TARGET_MIXER_READ(SOUND_MIXER_LINE)
19122521d698Sbellard #define TARGET_SOUND_MIXER_READ_MIC		TARGET_MIXER_READ(SOUND_MIXER_MIC)
19132521d698Sbellard #define TARGET_SOUND_MIXER_READ_CD		TARGET_MIXER_READ(SOUND_MIXER_CD)
19142521d698Sbellard #define TARGET_SOUND_MIXER_READ_IMIX		TARGET_MIXER_READ(SOUND_MIXER_IMIX)
19152521d698Sbellard #define TARGET_SOUND_MIXER_READ_ALTPCM		TARGET_MIXER_READ(SOUND_MIXER_ALTPCM)
19162521d698Sbellard #define TARGET_SOUND_MIXER_READ_RECLEV		TARGET_MIXER_READ(SOUND_MIXER_RECLEV)
19172521d698Sbellard #define TARGET_SOUND_MIXER_READ_IGAIN		TARGET_MIXER_READ(SOUND_MIXER_IGAIN)
19182521d698Sbellard #define TARGET_SOUND_MIXER_READ_OGAIN		TARGET_MIXER_READ(SOUND_MIXER_OGAIN)
19192521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE1		TARGET_MIXER_READ(SOUND_MIXER_LINE1)
19202521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE2		TARGET_MIXER_READ(SOUND_MIXER_LINE2)
19212521d698Sbellard #define TARGET_SOUND_MIXER_READ_LINE3		TARGET_MIXER_READ(SOUND_MIXER_LINE3)
19222521d698Sbellard 
19232521d698Sbellard /* Obsolete macros */
19242521d698Sbellard #define TARGET_SOUND_MIXER_READ_MUTE		TARGET_MIXER_READ(SOUND_MIXER_MUTE)
19252521d698Sbellard #define TARGET_SOUND_MIXER_READ_ENHANCE	        TARGET_MIXER_READ(SOUND_MIXER_ENHANCE)
19262521d698Sbellard #define TARGET_SOUND_MIXER_READ_LOUD		TARGET_MIXER_READ(SOUND_MIXER_LOUD)
19272521d698Sbellard 
19282521d698Sbellard #define TARGET_SOUND_MIXER_READ_RECSRC		TARGET_MIXER_READ(SOUND_MIXER_RECSRC)
19292521d698Sbellard #define TARGET_SOUND_MIXER_READ_DEVMASK	        TARGET_MIXER_READ(SOUND_MIXER_DEVMASK)
19302521d698Sbellard #define TARGET_SOUND_MIXER_READ_RECMASK	        TARGET_MIXER_READ(SOUND_MIXER_RECMASK)
19312521d698Sbellard #define TARGET_SOUND_MIXER_READ_STEREODEVS	TARGET_MIXER_READ(SOUND_MIXER_STEREODEVS)
19322521d698Sbellard #define TARGET_SOUND_MIXER_READ_CAPS		TARGET_MIXER_READ(SOUND_MIXER_CAPS)
19332521d698Sbellard 
19342521d698Sbellard #define TARGET_MIXER_WRITE(dev)		TARGET_IOWR('M', dev, int)
19352521d698Sbellard 
19362521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_VOLUME	TARGET_MIXER_WRITE(SOUND_MIXER_VOLUME)
19372521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_BASS		TARGET_MIXER_WRITE(SOUND_MIXER_BASS)
19382521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_TREBLE	TARGET_MIXER_WRITE(SOUND_MIXER_TREBLE)
19392521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_SYNTH		TARGET_MIXER_WRITE(SOUND_MIXER_SYNTH)
19402521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_PCM		TARGET_MIXER_WRITE(SOUND_MIXER_PCM)
19412521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_SPEAKER	TARGET_MIXER_WRITE(SOUND_MIXER_SPEAKER)
19422521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE		TARGET_MIXER_WRITE(SOUND_MIXER_LINE)
19432521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_MIC		TARGET_MIXER_WRITE(SOUND_MIXER_MIC)
19442521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_CD		TARGET_MIXER_WRITE(SOUND_MIXER_CD)
19452521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_IMIX		TARGET_MIXER_WRITE(SOUND_MIXER_IMIX)
19462521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_ALTPCM	TARGET_MIXER_WRITE(SOUND_MIXER_ALTPCM)
19472521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_RECLEV	TARGET_MIXER_WRITE(SOUND_MIXER_RECLEV)
19482521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_IGAIN		TARGET_MIXER_WRITE(SOUND_MIXER_IGAIN)
19492521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_OGAIN		TARGET_MIXER_WRITE(SOUND_MIXER_OGAIN)
19502521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE1		TARGET_MIXER_WRITE(SOUND_MIXER_LINE1)
19512521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE2		TARGET_MIXER_WRITE(SOUND_MIXER_LINE2)
19522521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LINE3		TARGET_MIXER_WRITE(SOUND_MIXER_LINE3)
19532521d698Sbellard 
19542521d698Sbellard /* Obsolete macros */
19552521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_MUTE		TARGET_MIXER_WRITE(SOUND_MIXER_MUTE)
19562521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_ENHANCE	TARGET_MIXER_WRITE(SOUND_MIXER_ENHANCE)
19572521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_LOUD		TARGET_MIXER_WRITE(SOUND_MIXER_LOUD)
19582521d698Sbellard 
19592521d698Sbellard #define TARGET_SOUND_MIXER_WRITE_RECSRC	TARGET_MIXER_WRITE(SOUND_MIXER_RECSRC)
19602521d698Sbellard 
19612521d698Sbellard /* vfat ioctls */
19622521d698Sbellard #define TARGET_VFAT_IOCTL_READDIR_BOTH    TARGET_IORU('r', 1)
19632521d698Sbellard #define TARGET_VFAT_IOCTL_READDIR_SHORT   TARGET_IORU('r', 2)
1964a5448a7dSbellard 
19658fbd6b52Sbalrog #define TARGET_MTIOCTOP        TARGET_IOW('m', 1, struct mtop)
19668fbd6b52Sbalrog #define TARGET_MTIOCGET        TARGET_IOR('m', 2, struct mtget)
19678fbd6b52Sbalrog #define TARGET_MTIOCPOS        TARGET_IOR('m', 3, struct mtpos)
19688fbd6b52Sbalrog 
1969a5448a7dSbellard struct target_sysinfo {
1970992f48a0Sblueswir1     abi_long uptime;                /* Seconds since boot */
1971992f48a0Sblueswir1     abi_ulong loads[3];             /* 1, 5, and 15 minute load averages */
1972992f48a0Sblueswir1     abi_ulong totalram;             /* Total usable main memory size */
1973992f48a0Sblueswir1     abi_ulong freeram;              /* Available memory size */
1974992f48a0Sblueswir1     abi_ulong sharedram;            /* Amount of shared memory */
1975992f48a0Sblueswir1     abi_ulong bufferram;            /* Memory used by buffers */
1976992f48a0Sblueswir1     abi_ulong totalswap;            /* Total swap space size */
1977992f48a0Sblueswir1     abi_ulong freeswap;             /* swap space still available */
1978a5448a7dSbellard     unsigned short procs;           /* Number of current processes */
1979a5448a7dSbellard     unsigned short pad;             /* explicit padding for m68k */
1980992f48a0Sblueswir1     abi_ulong totalhigh;            /* Total high memory size */
1981992f48a0Sblueswir1     abi_ulong freehigh;             /* Available high memory size */
1982a5448a7dSbellard     unsigned int mem_unit;          /* Memory unit size in bytes */
1983992f48a0Sblueswir1     char _f[20-2*sizeof(abi_long)-sizeof(int)]; /* Padding: libc5 uses this.. */
1984a5448a7dSbellard };
19853532fa74Sbellard 
19866556a833Saurel32 struct linux_dirent {
19876556a833Saurel32     long            d_ino;
19886556a833Saurel32     unsigned long   d_off;
19896556a833Saurel32     unsigned short  d_reclen;
19906556a833Saurel32     char            d_name[256]; /* We must not include limits.h! */
19916556a833Saurel32 };
19926556a833Saurel32 
19936556a833Saurel32 struct linux_dirent64 {
19946556a833Saurel32     uint64_t        d_ino;
19956556a833Saurel32     int64_t         d_off;
19966556a833Saurel32     unsigned short  d_reclen;
19976556a833Saurel32     unsigned char   d_type;
19986556a833Saurel32     char            d_name[256];
19996556a833Saurel32 };
20006556a833Saurel32 
2001*24e1003aSaurel32 struct target_mq_attr {
2002*24e1003aSaurel32     abi_long mq_flags;
2003*24e1003aSaurel32     abi_long mq_maxmsg;
2004*24e1003aSaurel32     abi_long mq_msgsize;
2005*24e1003aSaurel32     abi_long mq_curmsgs;
2006*24e1003aSaurel32 };
2007*24e1003aSaurel32 
20083532fa74Sbellard #include "socket.h"
2009637947f1Sths 
2010637947f1Sths #include "errno_defs.h"
2011