]> git.pond.sub.org Git - empserver/blob - src/lib/lwp/lwpint.h
Import of Empire 4.2.12
[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 hpux
33 int     lwpSave _PROTO((jmp_buf));
34 void    lwpRestore _PROTO((jmp_buf));
35 #endif
36
37 #if defined(MIPS) || defined(AIX32) || defined(ALPHA) || defined(__vax)
38 int     lwpSave _PROTO((jmp_buf));
39 void    lwpRestore _PROTO((jmp_buf));
40 #elif defined(SUN4)
41 #define lwpSave(x)      _setjmp(x)
42 #define lwpRestore(x)   _longjmp(x, 1)
43 #elif defined (UCONTEXT)
44 #define lwpSave(x)    getcontext(&(x))
45 #define lwpRestore(x) setcontext(&(x))
46 #else
47 #ifdef hpc
48 #define lwpSave(x)      setjmp(x)
49 #define lwpRestore(x)   longjmp(x, 1)
50 #else
51 #ifndef hpux
52 #define lwpSave(x)      setjmp(x)
53 #define lwpRestore(x)   longjmp(x, 1)
54 #endif /* hpux */
55 #endif /* hpc */
56 #endif
57
58 #ifdef AIX32
59 /* AIX needs 12 extra bytes above the stack; we add it here */
60 #define LWP_EXTRASTACK  3*sizeof(long)
61 #else
62 #define LWP_EXTRASTACK  0
63 #endif
64
65 #define LWP_REDZONE     1024    /* make this a multiple of 1024 */
66
67 /* XXX Note that this assumes sizeof(long) == 4 */
68 #define LWP_CHECKMARK   0x5a5a5a5aL
69
70 #define SIGNALS sigmask(SIGALRM)
71
72 #ifndef hpux
73 typedef double stkalign_t;
74 #else
75 typedef struct {
76     char x[64];
77 } stkalign_t;
78 #endif
79
80 /* internal routines */
81 void            lwpAddTail _PROTO((struct lwpQueue *, struct lwpProc *));
82 struct lwpProc  *lwpGetFirst _PROTO((struct lwpQueue *));
83 void            lwpReschedule _PROTO((void));
84 void            lwpReady _PROTO((struct lwpProc *));
85 void            lwpOnalarm _PROTO((void));
86
87 #ifdef UCONTEXT
88 void          lwpInitContext _PROTO((struct lwpProc *, stack_t *));
89 #else /* GETCONTEXT */
90 #ifdef hpc
91 void          lwpInitContext _PROTO((struct lwpProc *, void *));
92 #else
93 #ifdef hpux
94 void          lwpInitContext _PROTO((volatile struct lwpProc *volatile, void *));
95 #else
96 void          lwpInitContext _PROTO((struct lwpProc *, void *));
97 #endif /* hpux */
98 #endif /* hpc */
99 #endif /* GETCONTEXT */
100 void            lwpEntryPoint _PROTO((void));
101 void            lwpInitSelect _PROTO((struct lwpProc *self));
102 void            lwpDestroy _PROTO((struct lwpProc *proc));
103
104 #endif  /* _LWP_H */
105