(linenum→info "unix/slp.c:2238")

qemu/0.9.1/linux-user/syscall_defs.h

    1: /* common syscall defines for all architectures */
    2: 
    3: /* Note: although the syscall numbers change between architectures,
    4:    most of them stay the same, so we handle it by puting ifdefs if
    5:    necessary */
    6: 
    7: #include "syscall_nr.h"
    8: 
    9: #define SOCKOP_socket           1
   10: #define SOCKOP_bind             2
   11: #define SOCKOP_connect          3
   12: #define SOCKOP_listen           4
   13: #define SOCKOP_accept           5
   14: #define SOCKOP_getsockname      6
   15: #define SOCKOP_getpeername      7
   16: #define SOCKOP_socketpair       8
   17: #define SOCKOP_send             9
   18: #define SOCKOP_recv             10
   19: #define SOCKOP_sendto           11
   20: #define SOCKOP_recvfrom         12
   21: #define SOCKOP_shutdown         13
   22: #define SOCKOP_setsockopt       14
   23: #define SOCKOP_getsockopt       15
   24: #define SOCKOP_sendmsg          16
   25: #define SOCKOP_recvmsg          17
   26: 
   27: #define IPCOP_semop             1
   28: #define IPCOP_semget            2
   29: #define IPCOP_semctl            3
   30: #define IPCOP_semtimedop        4
   31: #define IPCOP_msgsnd            11
   32: #define IPCOP_msgrcv            12
   33: #define IPCOP_msgget            13
   34: #define IPCOP_msgctl            14
   35: #define IPCOP_shmat             21
   36: #define IPCOP_shmdt             22
   37: #define IPCOP_shmget            23
   38: #define IPCOP_shmctl            24
   39: 
   40: /*
   41:  * The following is for compatibility across the various Linux
   42:  * platforms.  The i386 ioctl numbering scheme doesn't really enforce
   43:  * a type field.  De facto, however, the top 8 bits of the lower 16
   44:  * bits are indeed used as a type field, so we might just as well make
   45:  * this explicit here.  Please be sure to use the decoding macros
   46:  * below from now on.
   47:  */
   48: #define TARGET_IOC_NRBITS       8
   49: #define TARGET_IOC_TYPEBITS     8
   50: 
   51: #if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SH4) \
   52:     || defined(TARGET_M68K) || defined(TARGET_ALPHA) || defined(TARGET_CRIS)
   53: 
   54: #define TARGET_IOC_SIZEBITS     14
   55: #define TARGET_IOC_DIRBITS      2
   56: 
   57: #define TARGET_IOC_NONE   0U
   58: #define TARGET_IOC_WRITE  1U
   59: #define TARGET_IOC_READ   2U
   60: 
   61: #elif defined(TARGET_PPC) || defined(TARGET_ALPHA) || \
   62:       defined(TARGET_SPARC) || defined(TARGET_MIPS)
   63: 
   64: #define TARGET_IOC_SIZEBITS     13
   65: #define TARGET_IOC_DIRBITS      3
   66: 
   67: #define TARGET_IOC_NONE   1U
   68: #define TARGET_IOC_READ   2U
   69: #define TARGET_IOC_WRITE  4U
   70: 
   71: #else
   72: #error unsupported CPU
   73: #endif
   74: 
   75: #define TARGET_IOC_NRMASK       ((1 << TARGET_IOC_NRBITS)-1)
   76: #define TARGET_IOC_TYPEMASK     ((1 << TARGET_IOC_TYPEBITS)-1)
   77: #define TARGET_IOC_SIZEMASK     ((1 << TARGET_IOC_SIZEBITS)-1)
   78: #define TARGET_IOC_DIRMASK      ((1 << TARGET_IOC_DIRBITS)-1)
   79: 
   80: #define TARGET_IOC_NRSHIFT      0
   81: #define TARGET_IOC_TYPESHIFT    (TARGET_IOC_NRSHIFT+TARGET_IOC_NRBITS)
   82: #define TARGET_IOC_SIZESHIFT    (TARGET_IOC_TYPESHIFT+TARGET_IOC_TYPEBITS)
   83: #define TARGET_IOC_DIRSHIFT     (TARGET_IOC_SIZESHIFT+TARGET_IOC_SIZEBITS)
   84: 
   85: #define TARGET_IOC(dir,type,nr,size) \
   86:         (((dir)  << TARGET_IOC_DIRSHIFT) | \
   87:          ((type) << TARGET_IOC_TYPESHIFT) | \
   88:          ((nr)   << TARGET_IOC_NRSHIFT) | \
   89:          ((size) << TARGET_IOC_SIZESHIFT))
   90: 
   91: /* used to create numbers */
   92: #define TARGET_IO(type,nr)              TARGET_IOC(TARGET_IOC_NONE,(type),(nr),0)
   93: #define TARGET_IOR(type,nr,size)        TARGET_IOC(TARGET_IOC_READ,(type),(nr),sizeof(size))
   94: #define TARGET_IOW(type,nr,size)        TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),sizeof(size))
   95: #define TARGET_IOWR(type,nr,size)       TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),sizeof(size))
   96: 
   97: /* the size is automatically computed for these defines */
   98: #define TARGET_IORU(type,nr)    TARGET_IOC(TARGET_IOC_READ,(type),(nr),TARGET_IOC_SIZEMASK)
   99: #define TARGET_IOWU(type,nr)    TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
  100: #define TARGET_IOWRU(type,nr)   TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
  101: 
  102: struct target_sockaddr {
  103:     uint16_t sa_family;
  104:     uint8_t sa_data[14];
  105: };
  106: 
  107: struct target_timeval {
  108:     abi_long tv_sec;
  109:     abi_long tv_usec;
  110: };
  111: 
  112: struct target_timespec {
  113:     abi_long tv_sec;
  114:     abi_long tv_nsec;
  115: };
  116: 
  117: struct target_itimerval {
  118:     struct target_timeval it_interval;
  119:     struct target_timeval it_value;
  120: };
  121: 
  122: typedef abi_long target_clock_t;
  123: 
  124: #define TARGET_HZ 100
  125: 
  126: struct target_tms {
  127:     target_clock_t tms_utime;
  128:     target_clock_t tms_stime;
  129:     target_clock_t tms_cutime;
  130:     target_clock_t tms_cstime;
  131: };
  132: 
  133: struct target_utimbuf {
  134:     abi_long actime;
  135:     abi_long modtime;
  136: };
  137: 
  138: struct target_sel_arg_struct {
  139:     abi_long n;
  140:     abi_long inp, outp, exp;
  141:     abi_long tvp;
  142: };
  143: 
  144: struct target_iovec {
  145:     abi_long iov_base;   /* Starting address */
  146:     abi_long iov_len;   /* Number of bytes */
  147: };
  148: 
  149: struct target_msghdr {
  150:     abi_long     msg_name;  /* Socket name                 */
  151:     int          msg_namelen;   /* Length of name               */
  152:     abi_long     msg_iov;   /* Data blocks                  */
  153:     abi_long     msg_iovlen;        /* Number of blocks          */
  154:     abi_long     msg_control;    /* Per protocol magic (eg BSD file descriptor passing) */
  155:     abi_long     msg_controllen; /* Length of cmsg list */
  156:     unsigned int msg_flags;
  157: };
  158: 
  159: struct target_cmsghdr {
  160:     abi_long     cmsg_len;
  161:     int          cmsg_level;
  162:     int          cmsg_type;
  163: };
  164: 
  165: #define TARGET_CMSG_DATA(cmsg) ((unsigned char *) ((struct target_cmsghdr *) (cmsg) + 1))
  166: #define TARGET_CMSG_NXTHDR(mhdr, cmsg) __target_cmsg_nxthdr (mhdr, cmsg)
  167: #define TARGET_CMSG_ALIGN(len) (((len) + sizeof (abi_long) - 1) \
  168:                                & (size_t) ~(sizeof (abi_long) - 1))
  169: #define TARGET_CMSG_SPACE(len) (TARGET_CMSG_ALIGN (len) \
  170:                                + TARGET_CMSG_ALIGN (sizeof (struct target_cmsghdr)))
  171: #define TARGET_CMSG_LEN(len)   (TARGET_CMSG_ALIGN (sizeof (struct target_cmsghdr)) + (len))
  172: 
  173: static __inline__ struct target_cmsghdr *
  174: __target_cmsg_nxthdr (struct target_msghdr *__mhdr, struct target_cmsghdr *__cmsg)
  175: {
  176:   struct target_cmsghdr *__ptr;
  177: 
  178:   __ptr = (struct target_cmsghdr *)((unsigned char *) __cmsg
  179:                                     + TARGET_CMSG_ALIGN (tswapl(__cmsg->cmsg_len)));
  180:   if ((unsigned long)((char *)(__ptr+1) - (char *)(size_t)tswapl(__mhdr->msg_control))
  181:       > tswapl(__mhdr->msg_controllen))
  182:     /* No more entries.  */
  183:     return (struct target_cmsghdr *)0;
  184:   return __cmsg;
  185: }
  186: 
  187: 
  188: struct  target_rusage {
  189:         struct target_timeval ru_utime;        /* user time used */
  190:         struct target_timeval ru_stime;        /* system time used */
  191:         abi_long    ru_maxrss;                 /* maximum resident set size */
  192:         abi_long    ru_ixrss;                  /* integral shared memory size */
  193:         abi_long    ru_idrss;                  /* integral unshared data size */
  194:         abi_long    ru_isrss;                  /* integral unshared stack size */
  195:         abi_long    ru_minflt;                 /* page reclaims */
  196:         abi_long    ru_majflt;                 /* page faults */
  197:         abi_long    ru_nswap;                  /* swaps */
  198:         abi_long    ru_inblock;                /* block input operations */
  199:         abi_long    ru_oublock;                /* block output operations */
  200:         abi_long    ru_msgsnd;                 /* messages sent */
  201:         abi_long    ru_msgrcv;                 /* messages received */
  202:         abi_long    ru_nsignals;               /* signals received */
  203:         abi_long    ru_nvcsw;                  /* voluntary context switches */
  204:         abi_long    ru_nivcsw;                 /* involuntary " */
  205: };
  206: 
  207: typedef struct {
  208:         int     val[2];
  209: } kernel_fsid_t;
  210: 
  211: struct kernel_statfs {
  212:         int f_type;
  213:         int f_bsize;
  214:         int f_blocks;
  215:         int f_bfree;
  216:         int f_bavail;
  217:         int f_files;
  218:         int f_ffree;
  219:         kernel_fsid_t f_fsid;
  220:         int f_namelen;
  221:         int f_spare[6];
  222: };
  223: 
  224: struct target_dirent {
  225:         abi_long       d_ino;
  226:         abi_long       d_off;
  227:         unsigned short d_reclen;
  228:         char           d_name[256]; /* We must not include limits.h! */
  229: };
  230: 
  231: struct target_dirent64 {
  232:         uint64_t       d_ino;
  233:         int64_t                d_off;
  234:         unsigned short d_reclen;
  235:         unsigned char  d_type;
  236:         char           d_name[256];
  237: };
  238: 
  239: 
  240: /* mostly generic signal stuff */
  241: #define TARGET_SIG_DFL  ((abi_long)0)    /* default signal handling */
  242: #define TARGET_SIG_IGN  ((abi_long)1)    /* ignore signal */
  243: #define TARGET_SIG_ERR  ((abi_long)-1)   /* error return from signal */
  244: 
  245: #ifdef TARGET_MIPS
  246: #define TARGET_NSIG        128
  247: #else
  248: #define TARGET_NSIG        64
  249: #endif
  250: #define TARGET_NSIG_BPW    TARGET_ABI_BITS
  251: #define TARGET_NSIG_WORDS  (TARGET_NSIG / TARGET_NSIG_BPW)
  252: 
  253: typedef struct {
  254:     abi_ulong sig[TARGET_NSIG_WORDS];
  255: } target_sigset_t;
  256: 
  257: #ifdef BSWAP_NEEDED
  258: static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
  259: {
  260:     int i;
  261:     for(i = 0;i < TARGET_NSIG_WORDS; i++)
  262:         d->sig[i] = tswapl(s->sig[i]);
  263: }
  264: #else
  265: static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
  266: {
  267:     *d = *s;
  268: }
  269: #endif
  270: 
  271: static inline void target_siginitset(target_sigset_t *d, abi_ulong set)
  272: {
  273:     int i;
  274:     d->sig[0] = set;
  275:     for(i = 1;i < TARGET_NSIG_WORDS; i++)
  276:         d->sig[i] = 0;
  277: }
  278: 
  279: void host_to_target_sigset(target_sigset_t *d, const sigset_t *s);
  280: void target_to_host_sigset(sigset_t *d, const target_sigset_t *s);
  281: void host_to_target_old_sigset(abi_ulong *old_sigset,
  282:                                const sigset_t *sigset);
  283: void target_to_host_old_sigset(sigset_t *sigset,
  284:                                const abi_ulong *old_sigset);
  285: struct target_sigaction;
  286: int do_sigaction(int sig, const struct target_sigaction *act,
  287:                  struct target_sigaction *oact);
  288: 
  289: #if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) || defined(TARGET_PPC) || defined(TARGET_MIPS) || defined (TARGET_SH4) || defined(TARGET_M68K) || defined(TARGET_ALPHA) || defined(TARGET_CRIS)
  290: 
  291: #if defined(TARGET_SPARC)
  292: #define TARGET_SA_NOCLDSTOP    8u
  293: #define TARGET_SA_NOCLDWAIT    0x100u
  294: #define TARGET_SA_SIGINFO      0x200u
  295: #define TARGET_SA_ONSTACK      1u
  296: #define TARGET_SA_RESTART      2u
  297: #define TARGET_SA_NODEFER      0x20u
  298: #define TARGET_SA_RESETHAND    4u
  299: #elif defined(TARGET_MIPS)
  300: #define TARGET_SA_NOCLDSTOP     0x00000001
  301: #define TARGET_SA_NOCLDWAIT     0x00010000
  302: #define TARGET_SA_SIGINFO       0x00000008
  303: #define TARGET_SA_ONSTACK       0x08000000
  304: #define TARGET_SA_NODEFER       0x40000000
  305: #define TARGET_SA_RESTART       0x10000000
  306: #define TARGET_SA_RESETHAND     0x80000000
  307: #if !defined(TARGET_ABI_MIPSN32) && !defined(TARGET_ABI_MIPSN64)
  308: #define TARGET_SA_RESTORER      0x04000000   /* Only for O32 */
  309: #endif
  310: #else
  311: #define TARGET_SA_NOCLDSTOP     0x00000001
  312: #define TARGET_SA_NOCLDWAIT     0x00000002 /* not supported yet */
  313: #define TARGET_SA_SIGINFO       0x00000004
  314: #define TARGET_SA_ONSTACK       0x08000000
  315: #define TARGET_SA_RESTART       0x10000000
  316: #define TARGET_SA_NODEFER       0x40000000
  317: #define TARGET_SA_RESETHAND     0x80000000
  318: #define TARGET_SA_RESTORER      0x04000000
  319: #endif
  320: 
  321: #if defined(TARGET_SPARC)
  322: 
  323: #define TARGET_SIGHUP            1
  324: #define TARGET_SIGINT            2
  325: #define TARGET_SIGQUIT           3
  326: #define TARGET_SIGILL            4
  327: #define TARGET_SIGTRAP           5
  328: #define TARGET_SIGABRT           6
  329: #define TARGET_SIGIOT            6
  330: #define TARGET_SIGSTKFLT         7 /* actually EMT */
  331: #define TARGET_SIGFPE            8
  332: #define TARGET_SIGKILL           9
  333: #define TARGET_SIGBUS           10
  334: #define TARGET_SIGSEGV          11
  335: #define TARGET_SIGSYS           12
  336: #define TARGET_SIGPIPE          13
  337: #define TARGET_SIGALRM          14
  338: #define TARGET_SIGTERM          15
  339: #define TARGET_SIGURG           16
  340: #define TARGET_SIGSTOP          17
  341: #define TARGET_SIGTSTP          18
  342: #define TARGET_SIGCONT          19
  343: #define TARGET_SIGCHLD          20
  344: #define TARGET_SIGTTIN          21
  345: #define TARGET_SIGTTOU          22
  346: #define TARGET_SIGIO            23
  347: #define TARGET_SIGXCPU          24
  348: #define TARGET_SIGXFSZ          25
  349: #define TARGET_SIGVTALRM        26
  350: #define TARGET_SIGPROF          27
  351: #define TARGET_SIGWINCH         28
  352: #define TARGET_SIGPWR           29
  353: #define TARGET_SIGUSR1          30
  354: #define TARGET_SIGUSR2          31
  355: #define TARGET_SIGRTMIN         32
  356: 
  357: #define TARGET_SIG_BLOCK          0x01 /* for blocking signals */
  358: #define TARGET_SIG_UNBLOCK        0x02 /* for unblocking signals */
  359: #define TARGET_SIG_SETMASK        0x04 /* for setting the signal mask */
  360: 
  361: #elif defined(TARGET_MIPS)
  362: 
  363: #define TARGET_SIGHUP            1       /* Hangup (POSIX).  */
  364: #define TARGET_SIGINT            2       /* Interrupt (ANSI).  */
  365: #define TARGET_SIGQUIT           3      /* Quit (POSIX).  */
  366: #define TARGET_SIGILL            4       /* Illegal instruction (ANSI).  */
  367: #define TARGET_SIGTRAP           5      /* Trace trap (POSIX).  */
  368: #define TARGET_SIGIOT            6       /* IOT trap (4.2 BSD).  */
  369: #define TARGET_SIGABRT           TARGET_SIGIOT  /* Abort (ANSI).  */
  370: #define TARGET_SIGEMT            7
  371: #define TARGET_SIGSTKFLT         7 /* XXX: incorrect */
  372: #define TARGET_SIGFPE            8       /* Floating-point exception (ANSI).  */
  373: #define TARGET_SIGKILL           9      /* Kill, unblockable (POSIX).  */
  374: #define TARGET_SIGBUS           10       /* BUS error (4.2 BSD).  */
  375: #define TARGET_SIGSEGV          11      /* Segmentation violation (ANSI).  */
  376: #define TARGET_SIGSYS           12
  377: #define TARGET_SIGPIPE          13      /* Broken pipe (POSIX).  */
  378: #define TARGET_SIGALRM          14      /* Alarm clock (POSIX).  */
  379: #define TARGET_SIGTERM          15      /* Termination (ANSI).  */
  380: #define TARGET_SIGUSR1          16      /* User-defined signal 1 (POSIX).  */
  381: #define TARGET_SIGUSR2          17      /* User-defined signal 2 (POSIX).  */
  382: #define TARGET_SIGCHLD          18      /* Child status has changed (POSIX).  */
  383: #define TARGET_SIGCLD           TARGET_SIGCHLD   /* Same as TARGET_SIGCHLD (System V).  */
  384: #define TARGET_SIGPWR           19       /* Power failure restart (System V).  */
  385: #define TARGET_SIGWINCH 20      /* Window size change (4.3 BSD, Sun).  */
  386: #define TARGET_SIGURG           21       /* Urgent condition on socket (4.2 BSD).  */
  387: #define TARGET_SIGIO            22        /* I/O now possible (4.2 BSD).  */
  388: #define TARGET_SIGPOLL          TARGET_SIGIO    /* Pollable event occurred (System V).  */
  389: #define TARGET_SIGSTOP          23      /* Stop, unblockable (POSIX).  */
  390: #define TARGET_SIGTSTP          24      /* Keyboard stop (POSIX).  */
  391: #define TARGET_SIGCONT          25      /* Continue (POSIX).  */
  392: #define TARGET_SIGTTIN          26      /* Background read from tty (POSIX).  */
  393: #define TARGET_SIGTTOU          27      /* Background write to tty (POSIX).  */
  394: #define TARGET_SIGVTALRM        28     /* Virtual alarm clock (4.2 BSD).  */
  395: #define TARGET_SIGPROF          29      /* Profiling alarm clock (4.2 BSD).  */
  396: #define TARGET_SIGXCPU          30      /* CPU limit exceeded (4.2 BSD).  */
  397: #define TARGET_SIGXFSZ          31      /* File size limit exceeded (4.2 BSD).  */
  398: #define TARGET_SIGRTMIN         32
  399: 
  400: #define TARGET_SIG_BLOCK        1      /* for blocking signals */
  401: #define TARGET_SIG_UNBLOCK      2    /* for unblocking signals */
  402: #define TARGET_SIG_SETMASK      3    /* for setting the signal mask */
  403: 
  404: #else
  405: 
  406: #define TARGET_SIGHUP            1
  407: #define TARGET_SIGINT            2
  408: #define TARGET_SIGQUIT           3
  409: #define TARGET_SIGILL            4
  410: #define TARGET_SIGTRAP           5
  411: #define TARGET_SIGABRT           6
  412: #define TARGET_SIGIOT            6
  413: #define TARGET_SIGBUS            7
  414: #define TARGET_SIGFPE            8
  415: #define TARGET_SIGKILL           9
  416: #define TARGET_SIGUSR1          10
  417: #define TARGET_SIGSEGV          11
  418: #define TARGET_SIGUSR2          12
  419: #define TARGET_SIGPIPE          13
  420: #define TARGET_SIGALRM          14
  421: #define TARGET_SIGTERM          15
  422: #define TARGET_SIGSTKFLT        16
  423: #define TARGET_SIGCHLD          17
  424: #define TARGET_SIGCONT          18
  425: #define TARGET_SIGSTOP          19
  426: #define TARGET_SIGTSTP          20
  427: #define TARGET_SIGTTIN          21
  428: #define TARGET_SIGTTOU          22
  429: #define TARGET_SIGURG           23
  430: #define TARGET_SIGXCPU          24
  431: #define TARGET_SIGXFSZ          25
  432: #define TARGET_SIGVTALRM        26
  433: #define TARGET_SIGPROF          27
  434: #define TARGET_SIGWINCH         28
  435: #define TARGET_SIGIO            29
  436: #define TARGET_SIGPWR           30
  437: #define TARGET_SIGSYS           31
  438: #define TARGET_SIGRTMIN         32
  439: 
  440: #define TARGET_SIG_BLOCK          0    /* for blocking signals */
  441: #define TARGET_SIG_UNBLOCK        1    /* for unblocking signals */
  442: #define TARGET_SIG_SETMASK        2    /* for setting the signal mask */
  443: 
  444: #endif
  445: 
  446: #if defined(TARGET_MIPS)
  447: 
  448: struct target_sigaction {
  449:         uint32_t       sa_flags;