home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / gnu / ixemul-39.47-env-bin.lha / include / user.h < prev    next >
C/C++ Source or Header  |  1994-07-08  |  8KB  |  251 lines

  1. /*
  2.  *  This file is part of ixemul.library for the Amiga.
  3.  *  Copyright (C) 1991, 1992  Markus M. Wild
  4.  *  Portions Copyright (C) 1994 Rafael W. Luebbert
  5.  *
  6.  *  This library is free software; you can redistribute it and/or
  7.  *  modify it under the terms of the GNU Library General Public
  8.  *  License as published by the Free Software Foundation; either
  9.  *  version 2 of the License, or (at your option) any later version.
  10.  *
  11.  *  This library is distributed in the hope that it will be useful,
  12.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.  *  Library General Public License for more details.
  15.  *
  16.  *  You should have received a copy of the GNU Library General Public
  17.  *  License along with this library; if not, write to the Free
  18.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  */
  20.  
  21.  
  22. #include <sys/time.h>
  23. #include <sys/resource.h>
  24. #include <setjmp.h>
  25.  
  26. /* internal structure used by malloc(), kmalloc() and friends */
  27. #if 0
  28. struct malloc_data {
  29.   struct Remember    *md_key;
  30.   unsigned int        md_malloc_sbrk_used;
  31.   struct mhead        *md_nextf[30];
  32.   char            md_busy[30];
  33.   int            md_gotpool;
  34. };
  35. #else
  36. struct malloc_data {
  37.   struct MinList    md_list;
  38.   unsigned int        md_malloc_sbrk_used;
  39. };
  40. #endif
  41.  
  42. /*
  43.  * One structure allocated per session.
  44.  */
  45. struct    session {
  46.     int    s_count;        /* ref cnt; pgrps in session */
  47.     struct    proc *s_leader;        /* session leader */
  48.     struct    vnode *s_ttyvp;        /* vnode of controlling terminal */
  49.     struct    tty *s_ttyp;        /* controlling terminal */
  50.     char    s_login[MAXLOGNAME];    /* setlogin() name */
  51. };
  52.  
  53. /*
  54.  * One structure allocated per process group.
  55.  */
  56. struct    pgrp {
  57.     struct    pgrp *pg_hforw;        /* forward link in hash bucket */
  58.     struct    proc *pg_mem;        /* pointer to pgrp members */
  59.     struct    session *pg_session;    /* pointer to session */
  60.     pid_t    pg_id;            /* pgrp id */
  61.     int    pg_jobc;    /* # procs qualifying pgrp for job control */
  62. };
  63.  
  64. /*
  65.  * Per process structure
  66.  */
  67.  
  68. struct user {
  69.     /* both a magic cookie and a way to get at the library base thru u */
  70.     struct  ixemul_base *u_ixbase;
  71.  
  72. /* 1.3 - signal management */
  73.     sig_t    u_signal[NSIG];        /* disposition of signals */
  74.     int    u_sigmask[NSIG];    /* signals to be blocked */
  75.     sigset_t    u_sigonstack;        /* signals to take on sigstack */
  76.     sigset_t    u_sigintr;        /* signals that interrupt syscalls */
  77.     sigset_t    u_oldmask;        /* saved mask from before sigpause */
  78.     struct    sigstack u_sigstack;    /* sp & on stack state variable */
  79. #define    u_onstack    u_sigstack.ss_onstack
  80. #define    u_sigsp        u_sigstack.ss_sp
  81.     int    u_sig;            /* for core dump/debugger XXX */
  82.     int    u_code;            /* for core dump/debugger XXX */
  83.     
  84.     int    p_flag;            /* process flags, as necessary.. */
  85.     char    p_stat;
  86.     char    p_xstat;        /* what does this do... ? */
  87.     char    p_cursig;
  88.     sigset_t    p_sig;            /* signals pending to this process */
  89.     sigset_t    p_sigmask;        /* current signal mask */
  90.     sigset_t    p_sigignore;        /* signals being ignored */
  91.     sigset_t    p_sigcatch;        /* signals being caught by user */
  92.  
  93.     caddr_t p_wchan;        /* event process is awaiting */
  94.  
  95.  
  96. /* 1.4 - descriptor management (for shared library version) */
  97.     struct    file *u_ofile[NOFILE];    /* file structures for open files */
  98.     char    u_pofile[NOFILE];    /* per-process flags of open files */
  99.     int    u_lastfile;        /* high-water mark of u_ofile */
  100. #define    UF_EXCLOSE     0x1        /* auto-close on exec */
  101.     short    u_cmask;        /* mask for file creation */
  102.  
  103. /* 1.5 - timing and statistics */
  104.     struct    rusage u_ru;        /* stats for this proc */
  105.     struct    rusage u_cru;        /* sum of stats for reaped children */
  106.     struct    itimerval u_timer[3];
  107.     struct    timeval u_start;
  108.     short    u_acflag;
  109.  
  110.     struct uprof {            /* profile arguments */
  111.         short    *pr_base;    /* buffer base */
  112.         unsigned pr_size;    /* buffer size */
  113.         unsigned pr_off;    /* pc offset */
  114.         unsigned pr_scale;    /* pc scaling */
  115.     } u_prof;
  116.  
  117. /* 1.6 - resource controls */
  118.     struct    rlimit u_rlimit[RLIM_NLIMITS];
  119.  
  120. /* amiga specific stuff */
  121.     struct malloc_data    u_md;
  122.     
  123.     struct MsgPort        *u_sync_mp;    /* PA_SIGNAL message port */
  124.     struct timerequest     *u_time_req;
  125.     int            *u_errno;
  126.     BPTR            u_startup_cd;
  127.     
  128.     int            u_ringring;    /* used in sleep.c and usleep.c */
  129.  
  130.     char            ***u_environ;
  131.  
  132.     /* used to handle amigados signals. see SIGMSG  */
  133.         u_int            u_lastrcvsig;
  134.         char            u_sleep_sig;
  135.         
  136.         /* c-startup stuff */
  137.         jmp_buf            u_jmp_buf;
  138.         char             *u_argline;
  139.         u_int            u_arglinelen;
  140.         int            u_expand_cmd_line;
  141.  
  142.     struct atexit        *u_atexit;
  143.     
  144.     char            u_getenv_buf[255];
  145.     
  146.     UBYTE            u_otask_flags;
  147.     void            (*u_olaunch)();
  148.     APTR            u_otrap_code;
  149.     APTR            u_otrap_data;
  150.     struct Interrupt    u_itimerint;    /* 1 interrupt / task */
  151.  
  152.     int            p_pgrp;        /* process group */
  153.  
  154.     char            *u_strtok_last;    /* moved with 37.8 */
  155.     
  156.     /* vfork() support */
  157.     struct MinList        p_zombies;    /* list of death messages */
  158.     int            p_zombie_sig;    /* signal to set when a child died */
  159.     struct Process        *p_pptr;    /* parent */
  160.     struct Process        *p_cptr;    /* last recently created child */
  161.     struct Process        *p_osptr;    /* older sybling */
  162.     struct Process        *p_ysptr;    /* younger sybling */
  163.     struct vfork_msg    *p_vfork_msg;
  164.  
  165. #if 0
  166.     /* moved to global space (ix_async_mp) */
  167.     struct MsgPort        *u_async_mp;    /* PA_SOFTINT message port */
  168. #else
  169.     long            u_rese0;
  170. #endif
  171.     void            (*u_oswitch)();
  172.     
  173.     /* stdio support comes here */
  174.     char            u_tmpnam_buf[MAXPATHLEN]; /* quite large.. */
  175. #include <stdio_2/glue.h>
  176.     struct glue        u_sglue;
  177.     /* the 3 `standard' FILE pointers (!) are here */
  178.     void            *u_sF[3];
  179.  
  180.     /* vfork() support #2 */
  181.     void            *u_save_sp;    /* when vfork'd, this is the `real' sp */
  182.     jmp_buf            u_vfork_frame;    /* for the parent in vfork () */
  183.     u_int            u_mini_stack[1000]; /* 4K stack while in vfork () */
  184.  
  185.     /* stack watcher. When usp < u_red_zone && ix.ix_watch_stack -> SIGSEGV */
  186.     void            *u_red_zone;
  187.  
  188.     /* base relative support. This even works for pure programs ! */
  189.     u_int            u_a4;
  190.     
  191.     /* currently there's just 1, meaning don't trace me */
  192.     u_int            u_trace_flags;
  193.     
  194.     /* this is for getmntinfo() */
  195.     struct statfs        *u_mntbuf;
  196.     int            u_mntsize;
  197.     long            u_bufsize;
  198.     
  199.     /* this is for SIGWINCH support. */
  200.     struct IOStdReq        *u_idev_req;
  201.     struct Window        *u_window;    /* the watched window */
  202.     struct Interrupt    u_idev_int;
  203.  
  204.     /* for `ps' (or dump as it's called for now.. ) */
  205.     char            *p_wmesg;
  206.     
  207.     /* new support for `real' process groups, control ttys etc.. */
  208.     struct user        *p_pgrpnxt;
  209.     struct pgrp        *p_pgrpptr;
  210.     struct Process        *p_exec_proc;    /* to get back to struct Process */
  211.     
  212.     /* to be able to switch memory lists on the fly, as required when vfork'd
  213.        processes are supposed to allocate memory from their parents pool until
  214.        they detach. */
  215.     struct malloc_data    *u_mdp;
  216. };
  217.  
  218. /* flag codes */
  219. #define    SLOAD    0x0000001    /* in core */
  220. #define    SSYS    0x0000002    /* swapper or pager process */
  221. #define    SLOCK    0x0000004    /* process being swapped out */
  222. #define    SSWAP    0x0000008    /* save area flag */
  223. #define    STRC    0x0000010    /* process is being traced */
  224. #define    SWTED    0x0000020    /* parent has been told that this process stopped */
  225. #define    SULOCK    0x0000040    /* user settable lock in core */
  226. #define    SNOCLDSTOP    0x0000080    /* tc_Launch has to take a signal next time */
  227. #define    SFREEA4    0x0000100    /* we allocated memory for a4, free it */
  228. #define    SOMASK    0x0000200    /* restore old mask after taking signal */
  229. #define    SWEXIT    0x0000400    /* working on exiting */
  230. #define    SPHYSIO    0x0000800    /* doing physical i/o (bio.c) */
  231. #define    SVFORK    0x0001000    /* process resulted from vfork() */
  232. #define    SVFDONE    0x0002000    /* another vfork flag */
  233. #define    SNOVM    0x0004000    /* no vm, parent in a vfork() */
  234. #define    SPAGI    0x0008000    /* init data space on demand, from inode */
  235. #define    SSEQL    0x0010000    /* user warned of sequential vm behavior */
  236. #define    SUANOM    0x0020000    /* user warned of random vm behavior */
  237. #define    STIMO    0x0040000    /* timing out during sleep */
  238. #define    SORPHAN    0x0080000    /* process is orphaned (can't be ^Z'ed) */
  239. #define    STRACNG    0x0100000    /* process is tracing another process */
  240. #define    SOWEUPC    0x0200000    /* owe process an addupc() call at next ast */
  241. #define    SSEL    0x0400000    /* selecting; wakeup/waiting danger */
  242. #define    SLOGIN    0x0800000    /* a login process (legit child of init) */
  243.  
  244. /* stat codes */
  245. #define    SSLEEP    1        /* awaiting an event */
  246. #define    SWAIT    2        /* (abandoned sta