]> git.pond.sub.org Git - empserver/blob - src/lib/lwp/lwpint.h
(lwpSave, lwpReschedule) [hpc]: Move machine-dependent code to arch.c,
[empserver] / src / lib / lwp / lwpint.h
1 /*
2  * lwpint.h -- lwp internal structures
3  *
4  * Copyright (C) 1991-3 Stephen Crane.
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  * author: Stephen Crane, (jsc@doc.ic.ac.uk), Department of Computing,
21  * Imperial College of Science, Technology and Medicine, 180 Queen's
22  * Gate, London SW7 2BZ, England.
23  */
24 #ifndef _LWPINT_H
25 #define _LWPINT_H
26
27 /* `liveness' counter: check signals every `n' visits to the scheduler */
28 /* note: the lower this value, the more responsive the system but the */
29 /* more inefficient the context switch time */
30 #define LCOUNT  -1
31
32 #ifdef UCONTEXT
33 void lwpInitContext(struct lwpProc *, stack_t *);
34 #define lwpSave(x)    getcontext(&(x))
35 #define lwpRestore(x) setcontext(&(x))
36 #else  /* !UCONTEXT */
37 #if defined(hpux) && !defined(hpc)
38 void lwpInitContext(volatile struct lwpProc * volatile, void *);
39 #else
40 void lwpInitContext(struct lwpProc *, void *);
41 #endif
42 #if defined(hpc)
43 int lwpSave(jmp_buf);
44 #define lwpRestore(x)   longjmp(x, 1)
45 #elif defined(hpux) || defined(AIX32) || defined(ALPHA)
46 int lwpSave(jmp_buf);
47 void lwpRestore(jmp_buf);
48 #elif defined(SUN4)
49 #define lwpSave(x)      _setjmp(x)
50 #define lwpRestore(x)   _longjmp(x, 1)
51 #else
52 #define lwpSave(x)      setjmp(x)
53 #define lwpRestore(x)   longjmp(x, 1)
54 #endif
55 #endif /* !UCONTEXT */
56
57 #ifdef AIX32
58 /* AIX needs 12 extra bytes above the stack; we add it here */
59 #define LWP_EXTRASTACK  3*sizeof(long)
60 #else
61 #define LWP_EXTRASTACK  0
62 #endif
63
64 #define LWP_REDZONE     1024    /* make this a multiple of 1024 */
65
66 /* XXX Note that this assumes sizeof(long) == 4 */
67 #define LWP_CHECKMARK   0x5a5a5a5aL
68
69 #ifdef hpux
70 typedef struct {
71     char x[64];
72 } stkalign_t;
73 #else
74 typedef double stkalign_t;
75 #endif
76
77 /* internal routines */
78 void lwpAddTail(struct lwpQueue *, struct lwpProc *);
79 struct lwpProc *lwpGetFirst(struct lwpQueue *);
80 void lwpReady(struct lwpProc *);
81 void lwpReschedule(void);
82 void lwpEntryPoint(void);
83 void lwpInitSelect(struct lwpProc * self);
84 void lwpDestroy(struct lwpProc * proc);
85
86 #endif /* _LWP_H */