linux emulation - Major update
[dragonfly.git] / sys / emulation / linux / i386 / linux.h
blob2e9a238054717afc4890191fadee92e95029269c
1 /*-
2 * Copyright (c) 1994-1996 Søren Schmidt
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer
10 * in this position and unchanged.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * $FreeBSD: src/sys/i386/linux/linux.h,v 1.41.2.4 2003/01/06 09:19:43 fjoe Exp $
29 * $DragonFly: src/sys/emulation/linux/i386/linux.h,v 1.9 2006/10/23 21:50:32 dillon Exp $
32 #ifndef _EMULATION_LINUX_ARCH_LINUX_H_
33 #define _EMULATION_LINUX_ARCH_LINUX_H_
35 #include <sys/signal.h> /* for sigval union */
37 #include "linux_syscall.h"
40 * debugging support
42 extern u_char linux_debug_map[];
43 #define ldebug(name) isclr(linux_debug_map, LINUX_SYS_linux_ ## name)
44 #define ARGS(nm, fmt) "linux(%ld): "#nm"("fmt")\n", (long)(curthread->td_proc ? curthread->td_proc->p_pid : -1)
45 #define LMSG(fmt) "linux(%ld): "fmt"\n", (long)(curthread->td_proc ? curthread->td_proc->p_pid : -1)
47 #if 0
48 #define LINUX_DEBUG 1
49 #endif
51 #ifdef MALLOC_DECLARE
52 MALLOC_DECLARE(M_LINUX);
53 #endif
55 #define PTRIN(v) (void *)(v)
56 #define PTROUT(v) (l_uintptr_t)(v)
59 * Provide a separate set of types for the Linux types.
61 typedef int l_int;
62 typedef int32_t l_long;
63 typedef int64_t l_longlong;
64 typedef short l_short;
65 typedef unsigned int l_uint;
66 typedef uint32_t l_ulong;
67 typedef uint64_t l_ulonglong;
68 typedef unsigned short l_ushort;
70 typedef l_ulong l_uintptr_t;
71 typedef char *l_caddr_t;
72 typedef l_long l_clock_t;
73 typedef l_int l_daddr_t;
74 typedef l_ushort l_dev_t;
75 typedef l_uint l_gid_t;
76 typedef l_ushort l_gid16_t;
77 typedef l_ulong l_ino_t;
78 typedef l_int l_key_t;
79 typedef l_longlong l_loff_t;
80 typedef l_ushort l_mode_t;
81 typedef l_long l_off_t;
82 typedef l_int l_pid_t;
83 typedef l_uint l_size_t;
84 typedef l_long l_suseconds_t;
85 typedef l_long l_time_t;
86 typedef l_uint l_uid_t;
87 typedef l_ushort l_uid16_t;
88 typedef l_int l_timer_t;
89 typedef l_int l_mqd_t;
91 typedef struct {
92 l_int val[2];
93 } l_fsid_t;
95 typedef struct {
96 l_time_t tv_sec;
97 l_suseconds_t tv_usec;
98 } l_timeval;
100 #define l_fd_set fd_set
103 * Miscellaneous
105 #define LINUX_NAME_MAX 255
106 #define LINUX_MAX_UTSNAME 65
108 #define LINUX_CTL_MAXNAME 10
110 struct l___sysctl_args
112 l_int *name;
113 l_int nlen;
114 void *oldval;
115 l_size_t *oldlenp;
116 void *newval;
117 l_size_t newlen;
118 l_ulong __spare[4];
121 /* Scheduling policies */
122 #define LINUX_SCHED_OTHER 0
123 #define LINUX_SCHED_FIFO 1
124 #define LINUX_SCHED_RR 2
126 /* Resource limits */
127 #define LINUX_RLIMIT_CPU 0
128 #define LINUX_RLIMIT_FSIZE 1
129 #define LINUX_RLIMIT_DATA 2
130 #define LINUX_RLIMIT_STACK 3
131 #define LINUX_RLIMIT_CORE 4
132 #define LINUX_RLIMIT_RSS 5
133 #define LINUX_RLIMIT_NPROC 6
134 #define LINUX_RLIMIT_NOFILE 7
135 #define LINUX_RLIMIT_MEMLOCK 8
136 #define LINUX_RLIMIT_AS 9 /* address space limit */
138 #define LINUX_RLIM_NLIMITS 10
140 struct l_rlimit {
141 l_ulong rlim_cur;
142 l_ulong rlim_max;
145 /* mmap options */
146 #define LINUX_MAP_SHARED 0x0001
147 #define LINUX_MAP_PRIVATE 0x0002
148 #define LINUX_MAP_FIXED 0x0010
149 #define LINUX_MAP_ANON 0x0020
150 #define LINUX_MAP_GROWSDOWN 0x0100
153 * stat family of syscalls
155 struct l_timespec {
156 l_time_t tv_sec;
157 l_long tv_nsec;
160 struct l_newstat {
161 l_ushort st_dev;
162 l_ushort __pad1;
163 l_ulong st_ino;
164 l_ushort st_mode;
165 l_ushort st_nlink;
166 l_ushort st_uid;
167 l_ushort st_gid;
168 l_ushort st_rdev;
169 l_ushort __pad2;
170 l_ulong st_size;
171 l_ulong st_blksize;
172 l_ulong st_blocks;
173 struct l_timespec st_atimespec;
174 struct l_timespec st_mtimespec;
175 struct l_timespec st_ctimespec;
176 l_ulong __unused4;
177 l_ulong __unused5;
180 struct l_stat64 {
181 l_ushort st_dev;
182 u_char __pad0[10];
183 l_ulong __st_ino;
184 l_uint st_mode;
185 l_uint st_nlink;
186 l_ulong st_uid;
187 l_ulong st_gid;
188 l_ushort st_rdev;
189 u_char __pad3[10];
190 l_longlong st_size;
191 l_ulong st_blksize;
192 l_ulong st_blocks;
193 l_ulong __pad4;
194 struct l_timespec st_atimespec;
195 struct l_timespec st_mtimespec;
196 struct l_timespec st_ctimespec;
197 l_ulonglong st_ino;
200 struct l_statfs64 {
201 l_int f_type;
202 l_int f_bsize;
203 uint64_t f_blocks;
204 uint64_t f_bfree;
205 uint64_t f_bavail;
206 uint64_t f_files;
207 uint64_t f_ffree;
208 l_fsid_t f_fsid;
209 l_int f_namelen;
210 l_int f_spare[6];
213 struct l_new_utsname {
214 char sysname[LINUX_MAX_UTSNAME];
215 char nodename[LINUX_MAX_UTSNAME];
216 char release[LINUX_MAX_UTSNAME];
217 char version[LINUX_MAX_UTSNAME];
218 char machine[LINUX_MAX_UTSNAME];
219 char domainname[LINUX_MAX_UTSNAME];
223 * Signalling
225 #define LINUX_SIGHUP 1
226 #define LINUX_SIGINT 2
227 #define LINUX_SIGQUIT 3
228 #define LINUX_SIGILL 4
229 #define LINUX_SIGTRAP 5
230 #define LINUX_SIGABRT 6
231 #define LINUX_SIGIOT LINUX_SIGABRT
232 #define LINUX_SIGBUS 7
233 #define LINUX_SIGFPE 8
234 #define LINUX_SIGKILL 9
235 #define LINUX_SIGUSR1 10
236 #define LINUX_SIGSEGV 11
237 #define LINUX_SIGUSR2 12
238 #define LINUX_SIGPIPE 13
239 #define LINUX_SIGALRM 14
240 #define LINUX_SIGTERM 15
241 #define LINUX_SIGSTKFLT 16
242 #define LINUX_SIGCHLD 17
243 #define LINUX_SIGCONT 18
244 #define LINUX_SIGSTOP 19
245 #define LINUX_SIGTSTP 20
246 #define LINUX_SIGTTIN 21
247 #define LINUX_SIGTTOU 22
248 #define LINUX_SIGURG 23
249 #define LINUX_SIGXCPU 24
250 #define LINUX_SIGXFSZ 25
251 #define LINUX_SIGVTALRM 26
252 #define LINUX_SIGPROF 27
253 #define LINUX_SIGWINCH 28
254 #define LINUX_SIGIO 29
255 #define LINUX_SIGPOLL LINUX_SIGIO
256 #define LINUX_SIGPWR 30
257 #define LINUX_SIGSYS 31
259 #define LINUX_SIGTBLSZ 31
260 #define LINUX_NSIG_WORDS 2
261 #define LINUX_NBPW 32
262 #define LINUX_NSIG (LINUX_NBPW * LINUX_NSIG_WORDS)
264 /* sigaction flags */
265 #define LINUX_SA_NOCLDSTOP 0x00000001
266 #define LINUX_SA_NOCLDWAIT 0x00000002
267 #define LINUX_SA_SIGINFO 0x00000004
268 #define LINUX_SA_RESTORER 0x04000000
269 #define LINUX_SA_ONSTACK 0x08000000
270 #define LINUX_SA_RESTART 0x10000000
271 #define LINUX_SA_INTERRUPT 0x20000000
272 #define LINUX_SA_NOMASK 0x40000000
273 #define LINUX_SA_ONESHOT 0x80000000
275 /* sigprocmask actions */
276 #define LINUX_SIG_BLOCK 0
277 #define LINUX_SIG_UNBLOCK 1
278 #define LINUX_SIG_SETMASK 2
280 /* sigset_t macros */
281 #define LINUX_SIGEMPTYSET(set) (set).__bits[0] = (set).__bits[1] = 0
282 #define LINUX_SIGISMEMBER(set, sig) SIGISMEMBER(set, sig)
283 #define LINUX_SIGADDSET(set, sig) SIGADDSET(set, sig)
285 /* sigaltstack */
286 #define LINUX_MINSIGSTKSZ 2048
287 #define LINUX_SS_ONSTACK 1
288 #define LINUX_SS_DISABLE 2
290 int linux_to_bsd_sigaltstack(int lsa);
291 int bsd_to_linux_sigaltstack(int bsa);
293 typedef void (*l_handler_t)(l_int);
294 typedef l_ulong l_osigset_t;
296 typedef struct {
297 l_uint __bits[LINUX_NSIG_WORDS];
298 } l_sigset_t;
300 typedef struct {
301 l_handler_t lsa_handler;
302 l_osigset_t lsa_mask;
303 l_ulong lsa_flags;
304 void (*lsa_restorer)(void);
305 } l_osigaction_t;
307 typedef struct {
308 l_handler_t lsa_handler;
309 l_ulong lsa_flags;
310 void (*lsa_restorer)(void);
311 l_sigset_t lsa_mask;
312 } l_sigaction_t;
314 typedef struct {
315 void *ss_sp;
316 l_int ss_flags;
317 l_size_t ss_size;
318 } l_stack_t;
320 /* The Linux sigcontext, pretty much a standard 386 trapframe. */
321 struct l_sigcontext {
322 l_int sc_gs;
323 l_int sc_fs;
324 l_int sc_es;
325 l_int sc_ds;
326 l_int sc_edi;
327 l_int sc_esi;
328 l_int sc_ebp;
329 l_int sc_esp;
330 l_int sc_ebx;
331 l_int sc_edx;
332 l_int sc_ecx;
333 l_int sc_eax;
334 l_int sc_trapno;
335 l_int sc_err;
336 l_int sc_eip;
337 l_int sc_cs;
338 l_int sc_eflags;
339 l_int sc_esp_at_signal;
340 l_int sc_ss;
341 l_int sc_387;
342 l_int sc_mask;
343 l_int sc_cr2;
346 struct l_ucontext {
347 l_ulong uc_flags;
348 void *uc_link;
349 l_stack_t uc_stack;
350 struct l_sigcontext uc_mcontext;
351 l_sigset_t uc_sigmask;
354 #define LINUX_SI_MAX_SIZE 128
355 #define LINUX_SI_PAD_SIZE ((LINUX_SI_MAX_SIZE/sizeof(l_int)) - 3)
357 typedef struct l_siginfo {
358 l_int lsi_signo;
359 l_int lsi_errno;
360 l_int lsi_code;
361 union {
362 l_int _pad[LINUX_SI_PAD_SIZE];
364 struct {
365 l_pid_t _pid;
366 l_uid16_t _uid;
367 } _kill;
369 struct {
370 l_uint _timer1;
371 l_uint _timer2;
372 } _timer;
374 struct {
375 l_pid_t _pid; /* sender's pid */
376 l_uid16_t _uid; /* sender's uid */
377 union sigval _sigval;
378 } _rt;
380 struct {
381 l_pid_t _pid; /* which child */
382 l_uid16_t _uid; /* sender's uid */
383 l_int _status; /* exit code */
384 l_clock_t _utime;
385 l_clock_t _stime;
386 } _sigchld;
388 struct {
389 void *_addr; /* faulting insn/memory ref. */
390 } _sigfault;
392 struct {
393 l_int _band; /* POLL_IN,POLL_OUT,POLL_MSG */
394 l_int _fd;
395 } _sigpoll;
396 } _sifields;
397 } l_siginfo_t;
399 #define lsi_pid _sifields._kill._pid
400 #define lsi_uid _sifields._kill._uid
401 #define lsi_status _sifields._sigchld._status
402 #define lsi_utime _sifields._sigchld._utime
403 #define lsi_stime _sifields._sigchld._stime
404 #define lsi_value _sifields._rt._sigval
405 #define lsi_int _sifields._rt._sigval.sival_int
406 #define lsi_ptr _sifields._rt._sigval.sival_ptr
407 #define lsi_addr _sifields._sigfault._addr
408 #define lsi_band _sifields._sigpoll._band
409 #define lsi_fd _sifields._sigpoll._fd
411 struct l_fpreg {
412 u_int16_t significand[4];
413 u_int16_t exponent;
416 struct l_fpxreg {
417 u_int16_t significand[4];
418 u_int16_t exponent;
419 u_int16_t padding[3];
422 struct l_xmmreg {
423 u_int32_t element[4];
426 struct l_fpstate {
427 /* Regular FPU environment */
428 u_int32_t cw;
429 u_int32_t sw;
430 u_int32_t tag;
431 u_int32_t ipoff;
432 u_int32_t cssel;
433 u_int32_t dataoff;
434 u_int32_t datasel;
435 struct l_fpreg _st[8];
436 u_int16_t status;
437 u_int16_t magic; /* 0xffff = regular FPU data */
439 /* FXSR FPU environment */
440 u_int32_t _fxsr_env[6]; /* env is ignored */
441 u_int32_t mxcsr;
442 u_int32_t reserved;
443 struct l_fpxreg _fxsr_st[8]; /* reg data is ignored */
444 struct l_xmmreg _xmm[8];
445 u_int32_t padding[56];
449 * We make the stack look like Linux expects it when calling a signal
450 * handler, but use the BSD way of calling the handler and sigreturn().
451 * This means that we need to pass the pointer to the handler too.
452 * It is appended to the frame to not interfere with the rest of it.
454 struct l_sigframe {
455 l_int sf_sig;
456 struct l_sigcontext sf_sc;
457 struct l_fpstate sf_fpstate;
458 l_uint sf_extramask[LINUX_NSIG_WORDS-1];
459 l_handler_t sf_handler;
462 struct l_rt_sigframe {
463 l_int sf_sig;
464 l_siginfo_t *sf_siginfo;
465 struct l_ucontext *sf_ucontext;
466 l_siginfo_t sf_si;
467 struct l_ucontext sf_sc;
468 l_handler_t sf_handler;
471 extern int bsd_to_linux_signal[];
472 extern int linux_to_bsd_signal[];
473 extern struct sysentvec linux_sysvec;
474 extern struct sysentvec elf_linux_sysvec;
477 * Pluggable ioctl handlers
480 extern struct ioctl_map linux_ioctl_map;
483 * open/fcntl flags
485 #define LINUX_O_RDONLY 00
486 #define LINUX_O_WRONLY 01
487 #define LINUX_O_RDWR 02
488 #define LINUX_O_CREAT 0100
489 #define LINUX_O_EXCL 0200
490 #define LINUX_O_NOCTTY 0400
491 #define LINUX_O_TRUNC 01000
492 #define LINUX_O_APPEND 02000
493 #define LINUX_O_NONBLOCK 04000
494 #define LINUX_O_NDELAY LINUX_O_NONBLOCK
495 #define LINUX_O_SYNC 010000
496 #define LINUX_FASYNC 020000
498 #define LINUX_F_DUPFD 0
499 #define LINUX_F_GETFD 1
500 #define LINUX_F_SETFD 2
501 #define LINUX_F_GETFL 3
502 #define LINUX_F_SETFL 4
503 #define LINUX_F_GETLK 5
504 #define LINUX_F_SETLK 6
505 #define LINUX_F_SETLKW 7
506 #define LINUX_F_SETOWN 8
507 #define LINUX_F_GETOWN 9
509 #define LINUX_F_GETLK64 12
510 #define LINUX_F_SETLK64 13
511 #define LINUX_F_SETLKW64 14
513 #define LINUX_F_RDLCK 0
514 #define LINUX_F_WRLCK 1
515 #define LINUX_F_UNLCK 2
518 * mount flags
520 #define LINUX_MS_RDONLY 0x0001
521 #define LINUX_MS_NOSUID 0x0002
522 #define LINUX_MS_NODEV 0x0004
523 #define LINUX_MS_NOEXEC 0x0008
524 #define LINUX_MS_REMOUNT 0x0020
527 * SystemV IPC defines
529 #define LINUX_SEMOP 1
530 #define LINUX_SEMGET 2
531 #define LINUX_SEMCTL 3
532 #define LINUX_MSGSND 11
533 #define LINUX_MSGRCV 12
534 #define LINUX_MSGGET 13
535 #define LINUX_MSGCTL 14
536 #define LINUX_SHMAT 21
537 #define LINUX_SHMDT 22
538 #define LINUX_SHMGET 23
539 #define LINUX_SHMCTL 24
541 #define LINUX_IPC_RMID 0
542 #define LINUX_IPC_SET 1
543 #define LINUX_IPC_STAT 2
544 #define LINUX_IPC_INFO 3
546 #define LINUX_SHM_LOCK 11
547 #define LINUX_SHM_UNLOCK 12
548 #define LINUX_SHM_STAT 13
549 #define LINUX_SHM_INFO 14
551 #define LINUX_SHM_RDONLY 0x1000
552 #define LINUX_SHM_RND 0x2000
553 #define LINUX_SHM_REMAP 0x4000
555 /* semctl commands */
556 #define LINUX_GETPID 11
557 #define LINUX_GETVAL 12
558 #define LINUX_GETALL 13
559 #define LINUX_GETNCNT 14
560 #define LINUX_GETZCNT 15
561 #define LINUX_SETVAL 16
562 #define LINUX_SETALL 17
563 #define LINUX_SEM_STAT 18
564 #define LINUX_SEM_INFO 19
566 union l_semun {
567 l_int val;
568 struct l_semid_ds *buf;
569 l_ushort *array;
570 struct l_seminfo *__buf;
571 void *__pad;
575 * Socket defines
577 #define LINUX_SOCKET 1
578 #define LINUX_BIND 2
579 #define LINUX_CONNECT 3
580 #define LINUX_LISTEN 4
581 #define LINUX_ACCEPT 5
582 #define LINUX_GETSOCKNAME 6
583 #define LINUX_GETPEERNAME 7
584 #define LINUX_SOCKETPAIR 8
585 #define LINUX_SEND 9
586 #define LINUX_RECV 10
587 #define LINUX_SENDTO 11
588 #define LINUX_RECVFROM 12
589 #define LINUX_SHUTDOWN 13
590 #define LINUX_SETSOCKOPT 14
591 #define LINUX_GETSOCKOPT 15
592 #define LINUX_SENDMSG 16
593 #define LINUX_RECVMSG 17
595 #define LINUX_AF_UNSPEC 0
596 #define LINUX_AF_UNIX 1
597 #define LINUX_AF_INET 2
598 #define LINUX_AF_AX25 3
599 #define LINUX_AF_IPX 4
600 #define LINUX_AF_APPLETALK 5
602 #define LINUX_SOL_SOCKET 1
603 #define LINUX_SOL_IP 0
604 #define LINUX_SOL_IPX 256
605 #define LINUX_SOL_AX25 257
606 #define LINUX_SOL_TCP 6
607 #define LINUX_SOL_UDP 17
609 #define LINUX_SO_DEBUG 1
610 #define LINUX_SO_REUSEADDR 2
611 #define LINUX_SO_TYPE 3
612 #define LINUX_SO_ERROR 4
613 #define LINUX_SO_DONTROUTE 5
614 #define LINUX_SO_BROADCAST 6
615 #define LINUX_SO_SNDBUF 7
616 #define LINUX_SO_RCVBUF 8
617 #define LINUX_SO_KEEPALIVE 9
618 #define LINUX_SO_OOBINLINE 10
619 #define LINUX_SO_NO_CHECK 11
620 #define LINUX_SO_PRIORITY 12
621 #define LINUX_SO_LINGER 13
622 #define LINUX_SO_PEERCRED 17
623 #define LINUX_SO_RCVLOWAT 18
624 #define LINUX_SO_SNDLOWAT 19
625 #define LINUX_SO_RCVTIMEO 20
626 #define LINUX_SO_SNDTIMEO 21
627 #define LINUX_SO_TIMESTAMP 29
628 #define LINUX_SO_ACCEPTCONN 30
630 #define LINUX_IP_TOS 1
631 #define LINUX_IP_TTL 2
632 #define LINUX_IP_HDRINCL 3
633 #define LINUX_IP_OPTIONS 4
635 #define LINUX_IP_MULTICAST_IF 32
636 #define LINUX_IP_MULTICAST_TTL 33
637 #define LINUX_IP_MULTICAST_LOOP 34
638 #define LINUX_IP_ADD_MEMBERSHIP 35
639 #define LINUX_IP_DROP_MEMBERSHIP 36
641 struct l_sockaddr {
642 l_ushort sa_family;
643 char sa_data[14];
646 struct l_ifmap {
647 l_ulong mem_start;
648 l_ulong mem_end;
649 l_ushort base_addr;
650 u_char irq;
651 u_char dma;
652 u_char port;
655 #define LINUX_IFHWADDRLEN 6
656 #define LINUX_IFNAMSIZ 16
658 struct l_ifreq {
659 union {
660 char ifrn_name[LINUX_IFNAMSIZ];
661 } ifr_ifrn;
663 union {
664 struct l_sockaddr ifru_addr;
665 struct l_sockaddr ifru_dstaddr;
666 struct l_sockaddr ifru_broadaddr;
667 struct l_sockaddr ifru_netmask;
668 struct l_sockaddr ifru_hwaddr;
669 l_short ifru_flags[1];
670 l_int ifru_metric;
671 l_int ifru_ivalue;
672 l_int ifru_mtu;
673 struct l_ifmap ifru_map;
674 char ifru_slave[LINUX_IFNAMSIZ];
675 l_caddr_t ifru_data;
676 } ifr_ifru;
679 #define ifr_name ifr_ifrn.ifrn_name /* interface name */
680 #define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */
681 #define ifr_ifindex ifr_ifru.ifru_ivalue /* Interface index */
682 #define ifr_ifmetric ifr_ifru.ifru_metric /* Interface index */
685 * poll()
687 #define LINUX_POLLIN 0x0001
688 #define LINUX_POLLPRI 0x0002
689 #define LINUX_POLLOUT 0x0004
690 #define LINUX_POLLERR 0x0008
691 #define LINUX_POLLHUP 0x0010
692 #define LINUX_POLLNVAL 0x0020
693 #define LINUX_POLLRDNORM 0x0040
694 #define LINUX_POLLRDBAND 0x0080
695 #define LINUX_POLLWRNORM 0x0100
696 #define LINUX_POLLWRBAND 0x0200
697 #define LINUX_POLLMSG 0x0400
699 struct l_pollfd {
700 l_int fd;
701 l_short events;
702 l_short revents;
705 struct l_user_desc {
706 l_uint entry_number;
707 l_uint base_addr;
708 l_uint limit;
709 l_uint seg_32bit:1;
710 l_uint contents:2;
711 l_uint read_exec_only:1;
712 l_uint limit_in_pages:1;
713 l_uint seg_not_present:1;
714 l_uint useable:1;
717 struct l_desc_struct {
718 unsigned long a, b;
722 #define LINUX_LOWERWORD 0x0000ffff
725 * Macros which does the same thing as those in Linux include/asm-um/ldt-i386.h.
726 * These convert Linux user space descriptor to machine one.
728 #define LINUX_LDT_entry_a(info) \
729 ((((info)->base_addr & LINUX_LOWERWORD) << 16) | \
730 ((info)->limit & LINUX_LOWERWORD))
732 #define LINUX_ENTRY_B_READ_EXEC_ONLY 9
733 #define LINUX_ENTRY_B_CONTENTS 10
734 #define LINUX_ENTRY_B_SEG_NOT_PRESENT 15
735 #define LINUX_ENTRY_B_BASE_ADDR 16
736 #define LINUX_ENTRY_B_USEABLE 20
737 #define LINUX_ENTRY_B_SEG32BIT 22
738 #define LINUX_ENTRY_B_LIMIT 23
740 #define LINUX_LDT_entry_b(info) \
741 (((info)->base_addr & 0xff000000) | \
742 ((info)->limit & 0xf0000) | \
743 ((info)->contents << LINUX_ENTRY_B_CONTENTS) | \
744 (((info)->seg_not_present == 0) << LINUX_ENTRY_B_SEG_NOT_PRESENT) | \
745 (((info)->base_addr & 0x00ff0000) >> LINUX_ENTRY_B_BASE_ADDR) | \
746 (((info)->read_exec_only == 0) << LINUX_ENTRY_B_READ_EXEC_ONLY) | \
747 ((info)->seg_32bit << LINUX_ENTRY_B_SEG32BIT) | \
748 ((info)->useable << LINUX_ENTRY_B_USEABLE) | \
749 ((info)->limit_in_pages << LINUX_ENTRY_B_LIMIT) | 0x7000)
751 #define LINUX_LDT_empty(info) \
752 ((info)->base_addr == 0 && \
753 (info)->limit == 0 && \
754 (info)->contents == 0 && \
755 (info)->seg_not_present == 1 && \
756 (info)->read_exec_only == 1 && \
757 (info)->seg_32bit == 0 && \
758 (info)->limit_in_pages == 0 && \
759 (info)->useable == 0)
762 * Macros for converting segments.
763 * They do the same as those in arch/i386/kernel/process.c in Linux.
765 #define LINUX_GET_BASE(desc) \
766 ((((desc)->a >> 16) & LINUX_LOWERWORD) | \
767 (((desc)->b << 16) & 0x00ff0000) | \
768 ((desc)->b & 0xff000000))
770 #define LINUX_GET_LIMIT(desc) \
771 (((desc)->a & LINUX_LOWERWORD) | \
772 ((desc)->b & 0xf0000))
774 #define LINUX_GET_32BIT(desc) \
775 (((desc)->b >> LINUX_ENTRY_B_SEG32BIT) & 1)
776 #define LINUX_GET_CONTENTS(desc) \
777 (((desc)->b >> LINUX_ENTRY_B_CONTENTS) & 3)
778 #define LINUX_GET_WRITABLE(desc) \
779 (((desc)->b >> LINUX_ENTRY_B_READ_EXEC_ONLY) & 1)
780 #define LINUX_GET_LIMIT_PAGES(desc) \
781 (((desc)->b >> LINUX_ENTRY_B_LIMIT) & 1)
782 #define LINUX_GET_PRESENT(desc) \
783 (((desc)->b >> LINUX_ENTRY_B_SEG_NOT_PRESENT) & 1)
784 #define LINUX_GET_USEABLE(desc) \
785 (((desc)->b >> LINUX_ENTRY_B_USEABLE) & 1)
787 #define LINUX_CLOCK_REALTIME 0
788 #define LINUX_CLOCK_MONOTONIC 1
789 #define LINUX_CLOCK_PROCESS_CPUTIME_ID 2
790 #define LINUX_CLOCK_THREAD_CPUTIME_ID 3
791 #define LINUX_CLOCK_REALTIME_HR 4
792 #define LINUX_CLOCK_MONOTONIC_HR 5
794 #define LINUX_CLONE_VM 0x00000100
795 #define LINUX_CLONE_FS 0x00000200
796 #define LINUX_CLONE_FILES 0x00000400
797 #define LINUX_CLONE_SIGHAND 0x00000800
798 #define LINUX_CLONE_PID 0x00001000 /* No longer exist in Linux */
799 #define LINUX_CLONE_VFORK 0x00004000
800 #define LINUX_CLONE_PARENT 0x00008000
801 #define LINUX_CLONE_THREAD 0x00010000
802 #define LINUX_CLONE_SETTLS 0x00080000
803 #define LINUX_CLONE_PARENT_SETTID 0x00100000
804 #define LINUX_CLONE_CHILD_CLEARTID 0x00200000
805 #define LINUX_CLONE_CHILD_SETTID 0x01000000
807 #define LINUX_THREADING_FLAGS \
808 (LINUX_CLONE_VM | LINUX_CLONE_FS | LINUX_CLONE_FILES | \
809 LINUX_CLONE_SIGHAND | LINUX_CLONE_THREAD)
811 #define LINUX_AT_FDCWD -100
812 #define LINUX_AT_SYMLINK_NOFOLLOW 0x100
813 #define LINUX_AT_REMOVEDIR 0x200
815 #define LINUX_MREMAP_MAYMOVE 1
816 #define LINUX_MREMAP_FIXED 2
818 #define LINUX_UTIME_NOW (-1)
819 #define LINUX_UTIME_OMIT (-2)
820 #endif /* !_EMULATION_LINUX_ARCH_LINUX_H_ */