(chown_cmd): reorder command arguments to match code. Based on patch
[arla.git] / lwp / lwp_asm.h
blob3906f53653e8a90973c833ee0e8cb255752e25c8
2 /*
3 ****************************************************************************
4 * Copyright IBM Corporation 1988, 1989 - All Rights Reserved *
5 * *
6 * Permission to use, copy, modify, and distribute this software and its *
7 * documentation for any purpose and without fee is hereby granted, *
8 * provided that the above copyright notice appear in all copies and *
9 * that both that copyright notice and this permission notice appear in *
10 * supporting documentation, and that the name of IBM not be used in *
11 * advertising or publicity pertaining to distribution of the software *
12 * without specific, written prior permission. *
13 * *
14 * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL *
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL IBM *
16 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY *
17 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER *
18 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING *
19 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *
20 ****************************************************************************
23 /*******************************************************************\
24 * *
25 * Information Technology Center *
26 * Carnegie-Mellon University *
27 * *
28 * *
29 \*******************************************************************/
31 /* $Id$ */
33 #ifndef __LWP_INCLUDE_
34 #define __LWP_INCLUDE_ 1
35 #ifdef HAVE_CONFIG_H
36 #include <config.h>
37 #endif
39 #ifdef HAVE_SYS_TYPES_H
40 #include <sys/types.h>
41 #endif
42 #ifdef HAVE_SYS_SELECT_H
43 #include <sys/select.h>
44 #endif
46 #ifdef HAVE_POSIX_SIGNALS
47 #define AFS_POSIX_SIGNALS 1
48 #endif
50 #define LWP_SUCCESS 0
51 #define LWP_EBADPID -1
52 #define LWP_EBLOCKED -2
53 #define LWP_EINIT -3
54 #define LWP_EMAXPROC -4
55 #define LWP_ENOBLOCK -5
56 #define LWP_ENOMEM -6
57 #define LWP_ENOPROCESS -7
58 #define LWP_ENOWAIT -8
59 #define LWP_EBADCOUNT -9
60 #define LWP_EBADEVENT -10
61 #define LWP_EBADPRI -11
62 #define LWP_NO_STACK -12
63 /* These two are for the signal mechanism. */
64 #define LWP_EBADSIG -13 /* bad signal number */
65 #define LWP_ESYSTEM -14 /* system call failed */
66 /* These are for the rock mechanism */
67 #define LWP_ENOROCKS -15 /* all rocks are in use */
68 #define LWP_EBADROCK -16 /* the specified rock does not exist */
71 /* Maximum priority permissible (minimum is always 0) */
72 #define LWP_MAX_PRIORITY 4 /* changed from 1 by Satya, 22 Nov. 85 */
74 /* Usual priority used by user LWPs */
75 #define LWP_NORMAL_PRIORITY (LWP_MAX_PRIORITY-2)
77 /* Initial size of eventlist in a PCB; grows dynamically */
78 #define EVINITSIZE 5
80 typedef struct lwp_pcb *PROCESS;
82 struct lwp_context { /* saved context for dispatcher */
83 char *topstack; /* ptr to top of process stack */
84 #ifdef sparc
85 #ifdef save_allregs
86 #ifdef __sparcv9
87 #define nregs (7+1+62+2)
88 #else
89 #define nregs (7+1+32+2+32+2) /* g1-g7, y reg, f0-f31, fsr, fq, c0-c31, csr, cq. */
90 #endif
91 long globals[nregs];
92 #undef nregs
93 #else
94 long globals[8]; /* g1-g7 and y registers. */
95 #endif
96 #endif
97 #if defined(powerpc) || defined(ppc) || defined(powerc) || defined(__POWERPC__)
98 char *linkRegister; /* the contents of the link register */
99 long conditionRegister; /* the contents of the condition register */
100 #endif /* defined(powerpc) || defined(ppc) || defined(powerc) || defined(__POWERPC__) */
103 struct rock
104 {/* to hide things associated with this LWP under */
105 int tag; /* unique identifier for this rock */
106 char *value; /* pointer to some arbitrary data structure */
109 #define MAXROCKS 4 /* max no. of rocks per LWP */
111 struct lwp_pcb { /* process control block */
112 char name[32]; /* ASCII name */
113 int rc; /* most recent return code */
114 char status; /* status flags */
115 char blockflag; /* if (blockflag), process blocked */
116 char eventlistsize; /* size of eventlist array */
117 char padding; /* force 32-bit alignment */
118 char **eventlist; /* ptr to array of eventids */
119 int eventcnt; /* no. of events currently in eventlist array*/
120 int wakevent; /* index of eventid causing wakeup */
121 int waitcnt; /* min number of events awaited */
122 int priority; /* dispatching priority */
123 struct lwp_pcb *misc; /* for LWP internal use only */
124 char *stack; /* ptr to process stack */
125 int stacksize; /* size of stack */
126 long stackcheck; /* first word of stack for overflow checking */
127 void (*ep)(); /* initial entry point */
128 char *parm; /* initial parm for process */
129 struct lwp_context
130 context; /* saved context for next dispatch */
131 int rused; /* no of rocks presently in use */
132 struct rock rlist[MAXROCKS]; /* set of rocks to hide things under */
133 struct lwp_pcb *next, *prev; /* ptrs to next and previous pcb */
134 int level; /* nesting level of critical sections */
135 struct IoRequest *iomgrRequest; /* request we're waiting for */
136 int index; /* LWP index: should be small index; actually is
137 incremented on each lwp_create_process */
140 extern int lwp_nextindex; /* Next lwp index to assign */
143 #ifndef LWP_KERNEL
144 #define LWP_INVALIDTHREADID (-1)
145 #define LWP_ActiveProcess (lwp_cpptr+0)
146 #define LWP_Index() (LWP_ActiveProcess->index)
147 #define LWP_HighestIndex() (lwp_nextindex - 1)
148 #define LWP_SignalProcess(event) LWP_INTERNALSIGNAL(event, 1)
149 #define LWP_NoYieldSignal(event) LWP_INTERNALSIGNAL(event, 0)
151 extern
152 #endif
153 PROCESS lwp_cpptr; /* pointer to current process pcb */
155 struct lwp_ctl { /* LWP control structure */
156 int processcnt; /* number of lightweight processes */
157 char *outersp; /* outermost stack pointer */
158 struct lwp_pcb *outerpid; /* process carved by Initialize */
159 struct lwp_pcb *first, last; /* ptrs to first and last pcbs */
160 #ifdef __hp9000s800
161 double dsptchstack[100]; /* stack for dispatcher use only */
162 /* force 8 byte alignment */
163 #else
164 char dsptchstack[800]; /* stack for dispatcher use only */
165 #endif
168 #ifndef LWP_KERNEL
169 extern
170 #endif
171 int lwp_debug; /* ON = show LWP debugging trace */
173 #if defined(AFS_SUN5_ENV) || defined(AFS_LINUX_ENV)
174 #define AFS_POSIX_SIGNALS
175 #endif
178 * Under some unices any stack size smaller than 16K seems prone to
179 * overflow problems. Set it to a somewhat larger value.
182 #define AFS_LWP_MINSTACKSIZE (100 * 1024)
184 /* Action to take on stack overflow. */
185 #define LWP_SOQUIET 1 /* do nothing */
186 #define LWP_SOABORT 2 /* abort the program */
187 #define LWP_SOMESSAGE 3 /* print a message and be quiet */
188 extern int lwp_overflowAction;
190 /* Tells if stack size counting is enabled. */
191 extern int lwp_stackUseEnabled;
192 extern int lwp_MaxStackSeen;
194 struct timeval;
196 int LWP_QSignal(PROCESS);
197 int LWP_DispatchProcess(void);
198 int LWP_InitializeProcessSupport(int, PROCESS *);
199 int LWP_DestroyProcess(PROCESS);
200 int LWP_QWait(void);
202 /* exported interface */
203 int LWP_CreateProcess(void (*)(), int, int, char *, const char *, PROCESS *);
204 int LWP_CurrentProcess(PROCESS *);
205 int LWP_WaitProcess(void *);
206 int LWP_INTERNALSIGNAL(void *, int);
207 int LWP_DispatchProcess(void);
208 int LWP_GetProcessPriority(PROCESS pid, int *priority);
209 int LWP_TerminateProcessSupport(void);
210 int LWP_MwaitProcess(int wcount, char *evlist[]);
211 int LWP_StackUsed(PROCESS pid, int *max, int *used);
213 void IOMGR_Sleep(unsigned int);
214 int IOMGR_Select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
215 long IOMGR_Poll(void);
216 int IOMGR_Cancel(PROCESS);
217 int IOMGR_Initialize(void);
218 int IOMGR_SoftSig(void (*aproc)(), char *arock);
219 int IOMGR_Finalize(void);
220 int IOMGR_Signal (int signo, char *event);
221 int IOMGR_CancelSignal (int signo);
223 int LWP_NewRock(int Tag, char *Value);
224 int LWP_GetRock(int Tag, char **Value);
227 #endif /* __LWP_INCLUDE_ */