linux.h revision 293548
1132499Stjr/*-
2132499Stjr * Copyright (c) 2013 Dmitry Chagin
3132499Stjr * Copyright (c) 1994-1996 S��ren Schmidt
4132499Stjr * All rights reserved.
5132499Stjr *
6132499Stjr * Redistribution and use in source and binary forms, with or without
7132499Stjr * modification, are permitted provided that the following conditions
8132499Stjr * are met:
9132499Stjr * 1. Redistributions of source code must retain the above copyright
10132499Stjr *    notice, this list of conditions and the following disclaimer
11132499Stjr *    in this position and unchanged.
12132499Stjr * 2. Redistributions in binary form must reproduce the above copyright
13132499Stjr *    notice, this list of conditions and the following disclaimer in the
14132499Stjr *    documentation and/or other materials provided with the distribution.
15132499Stjr * 3. The name of the author may not be used to endorse or promote products
16132499Stjr *    derived from this software without specific prior written permission
17132499Stjr *
18132499Stjr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19132499Stjr * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20132499Stjr * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21132499Stjr * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22132499Stjr * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23132499Stjr * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24132499Stjr * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25132499Stjr * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26132499Stjr * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27132499Stjr * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28132499Stjr *
29132499Stjr * $FreeBSD: stable/10/sys/amd64/linux/linux.h 293548 2016-01-09 16:47:36Z dchagin $
30132499Stjr */
31132499Stjr
32132499Stjr#ifndef _AMD64_LINUX_H_
33132499Stjr#define	_AMD64_LINUX_H_
34132499Stjr
35132499Stjr#include <amd64/linux/linux_syscall.h>
36132499Stjr
37132499Stjr/*
38132499Stjr * debugging support
39132499Stjr */
40132499Stjrextern u_char linux_debug_map[];
41132499Stjr#define	ldebug(name)	isclr(linux_debug_map, LINUX_SYS_linux_ ## name)
42132499Stjr#define	ARGS(nm, fmt)	"linux(%ld/%ld): "#nm"("fmt")\n",			\
43132499Stjr			(long)td->td_proc->p_pid, (long)td->td_tid
44132499Stjr#define	LMSG(fmt)	"linux(%ld/%ld): "fmt"\n",				\
45132499Stjr			(long)td->td_proc->p_pid, (long)td->td_tid
46132499Stjr#define	LINUX_DTRACE	linuxulator
47132499Stjr
48132499Stjr#define	PTRIN(v)	(void *)(v)
49132499Stjr#define	PTROUT(v)	(uintptr_t)(v)
50132499Stjr
51132499Stjr#define	CP(src,dst,fld) do { (dst).fld = (src).fld; } while (0)
52132499Stjr#define	CP2(src,dst,sfld,dfld) do { (dst).dfld = (src).sfld; } while (0)
53132499Stjr#define	PTRIN_CP(src,dst,fld) \
54132499Stjr	do { (dst).fld = PTRIN((src).fld); } while (0)
55132499Stjr
56132499Stjr/*
57132499Stjr * Provide a separate set of types for the Linux types.
58137587Snik */
59137587Sniktypedef int32_t		l_int;
60132499Stjrtypedef int64_t		l_long;
61132499Stjrtypedef int16_t		l_short;
62132499Stjrtypedef uint32_t	l_uint;
63132499Stjrtypedef uint64_t	l_ulong;
64132499Stjrtypedef uint16_t	l_ushort;
65132499Stjr
66132499Stjrtypedef l_ulong		l_uintptr_t;
67132499Stjrtypedef l_long		l_clock_t;
68132499Stjrtypedef l_int		l_daddr_t;
69132499Stjrtypedef l_ulong		l_dev_t;
70132499Stjrtypedef l_uint		l_gid_t;
71132499Stjrtypedef l_uint		l_uid_t;
72132499Stjrtypedef l_ulong		l_ino_t;
73132499Stjrtypedef l_int		l_key_t;
74132499Stjrtypedef l_long		l_loff_t;
75132499Stjrtypedef l_uint		l_mode_t;
76132499Stjrtypedef l_long		l_off_t;
77132499Stjrtypedef l_int		l_pid_t;
78132499Stjrtypedef l_ulong		l_size_t;
79132499Stjrtypedef l_long		l_ssize_t;
80132499Stjrtypedef l_long		l_suseconds_t;
81132499Stjrtypedef l_long		l_time_t;
82132499Stjrtypedef l_int		l_timer_t;
83132499Stjrtypedef l_int		l_mqd_t;
84132499Stjrtypedef l_size_t	l_socklen_t;
85132499Stjrtypedef	l_ulong		l_fd_mask;
86132499Stjr
87132499Stjrtypedef struct {
88132499Stjr	l_int		val[2];
89132499Stjr} l_fsid_t;
90132499Stjr
91132499Stjrtypedef struct {
92132499Stjr	l_time_t	tv_sec;
93132499Stjr	l_suseconds_t	tv_usec;
94132499Stjr} l_timeval;
95132499Stjr
96132499Stjr#define	l_fd_set	fd_set
97132499Stjr
98132499Stjr/*
99132499Stjr * Miscellaneous
100132499Stjr */
101132499Stjr#define	LINUX_NAME_MAX		255
102132499Stjr#define	LINUX_CTL_MAXNAME	10
103132499Stjr
104132499Stjr#define LINUX_AT_COUNT		19	/* Count of used aux entry types. */
105132499Stjr
106132499Stjrstruct l___sysctl_args
107132499Stjr{
108132499Stjr	l_uintptr_t	name;
109132499Stjr	l_int		nlen;
110132499Stjr	l_uintptr_t	oldval;
111132499Stjr	l_uintptr_t	oldlenp;
112132499Stjr	l_uintptr_t	newval;
113132499Stjr	l_size_t	newlen;
114132499Stjr	l_ulong		__spare[4];
115132499Stjr};
116132499Stjr
117132499Stjr/* Scheduling policies */
118132499Stjr#define	LINUX_SCHED_OTHER	0
119132499Stjr#define	LINUX_SCHED_FIFO	1
120132499Stjr#define	LINUX_SCHED_RR		2
121132499Stjr
122132499Stjr/* Resource limits */
123132499Stjr#define	LINUX_RLIMIT_CPU	0
124132499Stjr#define	LINUX_RLIMIT_FSIZE	1
125132499Stjr#define	LINUX_RLIMIT_DATA	2
126132499Stjr#define	LINUX_RLIMIT_STACK	3
127132499Stjr#define	LINUX_RLIMIT_CORE	4
128132499Stjr#define	LINUX_RLIMIT_RSS	5
129132499Stjr#define	LINUX_RLIMIT_NPROC	6
130132499Stjr#define	LINUX_RLIMIT_NOFILE	7
131132499Stjr#define	LINUX_RLIMIT_MEMLOCK	8
132132499Stjr#define	LINUX_RLIMIT_AS		9	/* Address space limit */
133132499Stjr
134132499Stjr#define	LINUX_RLIM_NLIMITS	10
135132499Stjr
136132499Stjrstruct l_rlimit {
137132499Stjr	l_ulong		rlim_cur;
138132499Stjr	l_ulong		rlim_max;
139132499Stjr};
140132499Stjr
141132499Stjr/* mmap options */
142132499Stjr#define	LINUX_MAP_SHARED	0x0001
143132499Stjr#define	LINUX_MAP_PRIVATE	0x0002
144132499Stjr#define	LINUX_MAP_FIXED		0x0010
145132499Stjr#define	LINUX_MAP_ANON		0x0020
146132499Stjr#define	LINUX_MAP_GROWSDOWN	0x0100
147132499Stjr
148132499Stjr/*
149132499Stjr * stat family of syscalls
150132499Stjr */
151132499Stjrstruct l_timespec {
152132499Stjr	l_time_t	tv_sec;
153132499Stjr	l_long		tv_nsec;
154132499Stjr};
155132499Stjr
156132499Stjrstruct l_newstat {
157132499Stjr	l_dev_t		st_dev;
158132499Stjr	l_ino_t		st_ino;
159132499Stjr	l_ulong		st_nlink;
160132499Stjr	l_uint		st_mode;
161132499Stjr	l_uid_t		st_uid;
162132499Stjr	l_gid_t		st_gid;
163132499Stjr	l_uint		__st_pad1;
164132499Stjr	l_dev_t		st_rdev;
165132499Stjr	l_off_t		st_size;
166132499Stjr	l_long		st_blksize;
167132499Stjr	l_long		st_blocks;
168132499Stjr	struct l_timespec	st_atim;
169132499Stjr	struct l_timespec	st_mtim;
170132499Stjr	struct l_timespec	st_ctim;
171132499Stjr	l_long		__unused1;
172132499Stjr	l_long		__unused2;
173132499Stjr	l_long		__unused3;
174132499Stjr};
175132499Stjr
176132499Stjr/*
177132499Stjr * Signalling
178132499Stjr */
179132499Stjr#define	LINUX_SIGHUP		1
180132499Stjr#define	LINUX_SIGINT		2
181132499Stjr#define	LINUX_SIGQUIT		3
182132499Stjr#define	LINUX_SIGILL		4
183132499Stjr#define	LINUX_SIGTRAP		5
184132499Stjr#define	LINUX_SIGABRT		6
185132499Stjr#define	LINUX_SIGIOT		LINUX_SIGABRT
186132499Stjr#define	LINUX_SIGBUS		7
187132499Stjr#define	LINUX_SIGFPE		8
188132499Stjr#define	LINUX_SIGKILL		9
189132499Stjr#define	LINUX_SIGUSR1		10
190132499Stjr#define	LINUX_SIGSEGV		11
191137587Snik#define	LINUX_SIGUSR2		12
192132499Stjr#define	LINUX_SIGPIPE		13
193132499Stjr#define	LINUX_SIGALRM		14
194132499Stjr#define	LINUX_SIGTERM		15
195#define	LINUX_SIGSTKFLT		16
196#define	LINUX_SIGCHLD		17
197#define	LINUX_SIGCONT		18
198#define	LINUX_SIGSTOP		19
199#define	LINUX_SIGTSTP		20
200#define	LINUX_SIGTTIN		21
201#define	LINUX_SIGTTOU		22
202#define	LINUX_SIGURG		23
203#define	LINUX_SIGXCPU		24
204#define	LINUX_SIGXFSZ		25
205#define	LINUX_SIGVTALRM		26
206#define	LINUX_SIGPROF		27
207#define	LINUX_SIGWINCH		28
208#define	LINUX_SIGIO		29
209#define	LINUX_SIGPOLL		LINUX_SIGIO
210#define	LINUX_SIGPWR		30
211#define	LINUX_SIGSYS		31
212#define	LINUX_SIGRTMIN		32
213
214#define	LINUX_SIGTBLSZ		31
215#define	LINUX_NSIG		64
216#define	LINUX_NBPW		64
217#define	LINUX_NSIG_WORDS	(LINUX_NSIG / LINUX_NBPW)
218
219/* sigaction flags */
220#define	LINUX_SA_NOCLDSTOP	0x00000001
221#define	LINUX_SA_NOCLDWAIT	0x00000002
222#define	LINUX_SA_SIGINFO	0x00000004
223#define	LINUX_SA_RESTORER	0x04000000
224#define	LINUX_SA_ONSTACK	0x08000000
225#define	LINUX_SA_RESTART	0x10000000
226#define	LINUX_SA_INTERRUPT	0x20000000
227#define	LINUX_SA_NOMASK		0x40000000
228#define	LINUX_SA_ONESHOT	0x80000000
229
230/* sigprocmask actions */
231#define	LINUX_SIG_BLOCK		0
232#define	LINUX_SIG_UNBLOCK	1
233#define	LINUX_SIG_SETMASK	2
234
235/* primitives to manipulate sigset_t */
236
237#define	LINUX_SIGEMPTYSET(set)					\
238	do {							\
239		(set).__bits[0] = 0;				\
240	} while(0)
241
242#define	LINUX_SIGISMEMBER(set, sig)				\
243	(1UL & ((set).__bits[0] >> _SIG_IDX(sig)))
244
245#define	LINUX_SIGADDSET(set, sig)				\
246	(set).__bits[0] |= 1UL << _SIG_IDX(sig)
247
248/* sigaltstack */
249#define	LINUX_MINSIGSTKSZ	2048
250#define	LINUX_SS_ONSTACK	1
251#define	LINUX_SS_DISABLE	2
252
253int linux_to_bsd_sigaltstack(int lsa);
254int bsd_to_linux_sigaltstack(int bsa);
255
256typedef void	(*l_handler_t)(l_int);
257
258typedef struct {
259	l_ulong __bits[LINUX_NSIG_WORDS];
260} l_sigset_t;
261
262typedef struct {
263	l_handler_t	lsa_handler;
264	l_ulong		lsa_flags;
265	l_uintptr_t	lsa_restorer;
266	l_sigset_t	lsa_mask;
267} l_sigaction_t;
268
269typedef struct {
270	l_uintptr_t	ss_sp;
271	l_int		ss_flags;
272	l_size_t	ss_size;
273} l_stack_t;
274
275struct l_fpstate {
276	u_int16_t cwd;
277	u_int16_t swd;
278	u_int16_t twd;
279	u_int16_t fop;
280	u_int64_t rip;
281	u_int64_t rdp;
282	u_int32_t mxcsr;
283	u_int32_t mxcsr_mask;
284	u_int32_t st_space[32];
285	u_int32_t xmm_space[64];
286	u_int32_t reserved2[24];
287};
288
289struct l_sigcontext {
290	l_ulong		sc_r8;
291	l_ulong		sc_r9;
292	l_ulong		sc_r10;
293	l_ulong		sc_r11;
294	l_ulong		sc_r12;
295	l_ulong		sc_r13;
296	l_ulong		sc_r14;
297	l_ulong		sc_r15;
298	l_ulong		sc_rdi;
299	l_ulong		sc_rsi;
300	l_ulong		sc_rbp;
301	l_ulong		sc_rbx;
302	l_ulong		sc_rdx;
303	l_ulong		sc_rax;
304	l_ulong		sc_rcx;
305	l_ulong		sc_rsp;
306	l_ulong		sc_rip;
307	l_ulong		sc_rflags;
308	l_ushort	sc_cs;
309	l_ushort	sc_gs;
310	l_ushort	sc_fs;
311	l_ushort	sc___pad0;
312	l_ulong		sc_err;
313	l_ulong		sc_trapno;
314	l_sigset_t	sc_mask;
315	l_ulong		sc_cr2;
316	struct l_fpstate *sc_fpstate;
317	l_ulong		sc_reserved1[8];
318};
319
320struct l_ucontext {
321	l_ulong		uc_flags;
322	l_uintptr_t	uc_link;
323	l_stack_t	uc_stack;
324	struct l_sigcontext	uc_mcontext;
325	l_sigset_t	uc_sigmask;
326};
327
328#define LINUX_SI_PREAMBLE_SIZE	(4 * sizeof(int))
329#define	LINUX_SI_MAX_SIZE	128
330#define	LINUX_SI_PAD_SIZE	((LINUX_SI_MAX_SIZE - \
331				    LINUX_SI_PREAMBLE_SIZE) / sizeof(l_int))
332typedef union l_sigval {
333	l_int		sival_int;
334	l_uintptr_t	sival_ptr;
335} l_sigval_t;
336
337typedef struct l_siginfo {
338	l_int		lsi_signo;
339	l_int		lsi_errno;
340	l_int		lsi_code;
341	union {
342		l_int	_pad[LINUX_SI_PAD_SIZE];
343
344		struct {
345			l_pid_t		_pid;
346			l_uid_t		_uid;
347		} _kill;
348
349		struct {
350			l_timer_t	_tid;
351			l_int		_overrun;
352			char		_pad[sizeof(l_uid_t) - sizeof(int)];
353			union l_sigval	_sigval;
354			l_uint		_sys_private;
355		} _timer;
356
357		struct {
358			l_pid_t		_pid;		/* sender's pid */
359			l_uid_t		_uid;		/* sender's uid */
360			union l_sigval	_sigval;
361		} _rt;
362
363		struct {
364			l_pid_t		_pid;		/* which child */
365			l_uid_t		_uid;		/* sender's uid */
366			l_int		_status;	/* exit code */
367			l_clock_t	_utime;
368			l_clock_t	_stime;
369		} _sigchld;
370
371		struct {
372			l_uintptr_t	_addr;	/* Faulting insn/memory ref. */
373		} _sigfault;
374
375		struct {
376			l_long		_band;	/* POLL_IN,POLL_OUT,POLL_MSG */
377			l_int		_fd;
378		} _sigpoll;
379	} _sifields;
380} l_siginfo_t;
381
382#define	lsi_pid		_sifields._kill._pid
383#define	lsi_uid		_sifields._kill._uid
384#define	lsi_tid		_sifields._timer._tid
385#define	lsi_overrun	_sifields._timer._overrun
386#define	lsi_sys_private	_sifields._timer._sys_private
387#define	lsi_status	_sifields._sigchld._status
388#define	lsi_utime	_sifields._sigchld._utime
389#define	lsi_stime	_sifields._sigchld._stime
390#define	lsi_value	_sifields._rt._sigval
391#define	lsi_int		_sifields._rt._sigval.sival_int
392#define	lsi_ptr		_sifields._rt._sigval.sival_ptr
393#define	lsi_addr	_sifields._sigfault._addr
394#define	lsi_band	_sifields._sigpoll._band
395#define	lsi_fd		_sifields._sigpoll._fd
396
397/*
398 * We make the stack look like Linux expects it when calling a signal
399 * handler, but use the BSD way of calling the handler and sigreturn().
400 * This means that we need to pass the pointer to the handler too.
401 * It is appended to the frame to not interfere with the rest of it.
402 */
403
404struct l_rt_sigframe {
405	struct l_ucontext	sf_sc;
406	struct l_siginfo	sf_si;
407	l_handler_t		sf_handler;
408};
409
410/*
411 * mount flags
412 */
413#define	LINUX_MS_RDONLY		0x0001
414#define	LINUX_MS_NOSUID		0x0002
415#define	LINUX_MS_NODEV		0x0004
416#define	LINUX_MS_NOEXEC		0x0008
417#define	LINUX_MS_REMOUNT	0x0020
418
419/*
420 * SystemV IPC defines
421 */
422#define	LINUX_IPC_RMID		0
423#define	LINUX_IPC_SET		1
424#define	LINUX_IPC_STAT		2
425#define	LINUX_IPC_INFO		3
426
427#define	LINUX_SHM_LOCK		11
428#define	LINUX_SHM_UNLOCK	12
429#define	LINUX_SHM_STAT		13
430#define	LINUX_SHM_INFO		14
431
432#define	LINUX_SHM_RDONLY	0x1000
433#define	LINUX_SHM_RND		0x2000
434#define	LINUX_SHM_REMAP		0x4000
435
436/* semctl commands */
437#define	LINUX_GETPID		11
438#define	LINUX_GETVAL		12
439#define	LINUX_GETALL		13
440#define	LINUX_GETNCNT		14
441#define	LINUX_GETZCNT		15
442#define	LINUX_SETVAL		16
443#define	LINUX_SETALL		17
444#define	LINUX_SEM_STAT		18
445#define	LINUX_SEM_INFO		19
446
447union l_semun {
448	l_int		val;
449	l_uintptr_t	buf;
450	l_uintptr_t	array;
451	l_uintptr_t	__buf;
452	l_uintptr_t	__pad;
453};
454
455struct l_ipc_perm {
456	l_key_t		key;
457	l_uid_t		uid;
458	l_gid_t		gid;
459	l_uid_t		cuid;
460	l_gid_t		cgid;
461	l_ushort	mode;
462	l_ushort	seq;
463};
464
465/*
466 * Socket defines
467 */
468
469#define	LINUX_SOL_SOCKET	1
470#define	LINUX_SOL_IP		0
471#define	LINUX_SOL_IPX		256
472#define	LINUX_SOL_AX25		257
473#define	LINUX_SOL_TCP		6
474#define	LINUX_SOL_UDP		17
475
476#define	LINUX_SO_DEBUG		1
477#define	LINUX_SO_REUSEADDR	2
478#define	LINUX_SO_TYPE		3
479#define	LINUX_SO_ERROR		4
480#define	LINUX_SO_DONTROUTE	5
481#define	LINUX_SO_BROADCAST	6
482#define	LINUX_SO_SNDBUF		7
483#define	LINUX_SO_RCVBUF		8
484#define	LINUX_SO_KEEPALIVE	9
485#define	LINUX_SO_OOBINLINE	10
486#define	LINUX_SO_NO_CHECK	11
487#define	LINUX_SO_PRIORITY	12
488#define	LINUX_SO_LINGER		13
489#define	LINUX_SO_PASSCRED	16
490#define	LINUX_SO_PEERCRED	17
491#define	LINUX_SO_RCVLOWAT	18
492#define	LINUX_SO_SNDLOWAT	19
493#define	LINUX_SO_RCVTIMEO	20
494#define	LINUX_SO_SNDTIMEO	21
495#define	LINUX_SO_TIMESTAMP	29
496#define	LINUX_SO_ACCEPTCONN	30
497
498#define	LINUX_IP_TOS		1
499#define	LINUX_IP_TTL		2
500#define	LINUX_IP_HDRINCL	3
501#define	LINUX_IP_OPTIONS	4
502
503#define	LINUX_IP_MULTICAST_IF		32
504#define	LINUX_IP_MULTICAST_TTL		33
505#define	LINUX_IP_MULTICAST_LOOP		34
506#define	LINUX_IP_ADD_MEMBERSHIP		35
507#define	LINUX_IP_DROP_MEMBERSHIP	36
508
509struct l_sockaddr {
510	l_ushort	sa_family;
511	char		sa_data[14];
512};
513
514struct l_msghdr {
515	l_uintptr_t	msg_name;
516	l_int		msg_namelen;
517	l_uintptr_t	msg_iov;
518	l_size_t	msg_iovlen;
519	l_uintptr_t	msg_control;
520	l_size_t	msg_controllen;
521	l_uint		msg_flags;
522};
523
524struct l_cmsghdr {
525	l_size_t	cmsg_len;
526	l_int		cmsg_level;
527	l_int		cmsg_type;
528};
529
530struct l_ifmap {
531	l_ulong		mem_start;
532	l_ulong		mem_end;
533	l_ushort	base_addr;
534	u_char		irq;
535	u_char		dma;
536	u_char		port;
537} __packed;
538
539#define	LINUX_IFHWADDRLEN	6
540#define	LINUX_IFNAMSIZ		16
541
542struct l_ifreq {
543	union {
544		char	ifrn_name[LINUX_IFNAMSIZ];
545	} ifr_ifrn;
546
547	union {
548		struct l_sockaddr	ifru_addr;
549		struct l_sockaddr	ifru_dstaddr;
550		struct l_sockaddr	ifru_broadaddr;
551		struct l_sockaddr	ifru_netmask;
552		struct l_sockaddr	ifru_hwaddr;
553		l_short		ifru_flags[1];
554		l_int		ifru_metric;
555		l_int		ifru_mtu;
556		struct l_ifmap	ifru_map;
557		char		ifru_slave[LINUX_IFNAMSIZ];
558		l_uintptr_t	ifru_data;
559	} ifr_ifru;
560} __packed;
561
562#define	ifr_name	ifr_ifrn.ifrn_name	/* Interface name */
563#define	ifr_hwaddr	ifr_ifru.ifru_hwaddr	/* MAC address */
564
565struct l_ifconf {
566	int	ifc_len;
567	union {
568		l_uintptr_t	ifcu_buf;
569		l_uintptr_t	ifcu_req;
570	} ifc_ifcu;
571};
572
573#define	ifc_buf		ifc_ifcu.ifcu_buf
574#define	ifc_req		ifc_ifcu.ifcu_req
575
576/*
577 * poll()
578 */
579#define	LINUX_POLLIN		0x0001
580#define	LINUX_POLLPRI		0x0002
581#define	LINUX_POLLOUT		0x0004
582#define	LINUX_POLLERR		0x0008
583#define	LINUX_POLLHUP		0x0010
584#define	LINUX_POLLNVAL		0x0020
585#define	LINUX_POLLRDNORM	0x0040
586#define	LINUX_POLLRDBAND	0x0080
587#define	LINUX_POLLWRNORM	0x0100
588#define	LINUX_POLLWRBAND	0x0200
589#define	LINUX_POLLMSG		0x0400
590
591struct l_pollfd {
592	l_int		fd;
593	l_short		events;
594	l_short		revents;
595};
596
597
598#define	LINUX_CLONE_VM			0x00000100
599#define	LINUX_CLONE_FS			0x00000200
600#define	LINUX_CLONE_FILES		0x00000400
601#define	LINUX_CLONE_SIGHAND		0x00000800
602#define	LINUX_CLONE_PID			0x00001000	/* No longer exist in Linux */
603#define	LINUX_CLONE_VFORK		0x00004000
604#define	LINUX_CLONE_PARENT		0x00008000
605#define	LINUX_CLONE_THREAD		0x00010000
606#define	LINUX_CLONE_SETTLS		0x00080000
607#define	LINUX_CLONE_PARENT_SETTID	0x00100000
608#define	LINUX_CLONE_CHILD_CLEARTID	0x00200000
609#define	LINUX_CLONE_CHILD_SETTID	0x01000000
610
611#define LINUX_ARCH_SET_GS		0x1001
612#define LINUX_ARCH_SET_FS		0x1002
613#define LINUX_ARCH_GET_GS		0x1003
614#define LINUX_ARCH_GET_FS		0x1004
615
616#define	linux_copyout_rusage(r, u)	copyout(r, u, sizeof(*r))
617
618/* robust futexes */
619struct linux_robust_list {
620	l_uintptr_t			next;
621};
622
623struct linux_robust_list_head {
624	struct linux_robust_list	list;
625	l_long				futex_offset;
626	l_uintptr_t			pending_list;
627};
628
629#endif /* !_AMD64_LINUX_H_ */
630