Clean up the incomprehensible #ifdef jungle a bit. Didn't compile if
both UCONTEXT and one of the other recognized preprocessor symbols was defined; fix to prefer UCONTEXT.
This commit is contained in:
parent
5d79a0cf6e
commit
081e60d86e
2 changed files with 38 additions and 62 deletions
|
@ -36,13 +36,27 @@
|
|||
|
||||
#if defined(_EMPTH_LWP)
|
||||
|
||||
#if (!defined(AIX32))
|
||||
|
||||
#include "lwp.h"
|
||||
|
||||
#include "lwpint.h"
|
||||
|
||||
#if defined(hpc)
|
||||
#if defined UCONTEXT
|
||||
/*
|
||||
* Alternate aproach using setcontext and getcontext instead of setjmp and
|
||||
* longjump. This should work on any SVr4 machine independant of
|
||||
* architecture. Unfortunately some changes are still nessesary in lwp.c.
|
||||
* Tested on IRIX 5.3
|
||||
*/
|
||||
|
||||
void
|
||||
lwpInitContext(struct lwpProc *newp, stack_t *spp)
|
||||
{
|
||||
getcontext(&newp->context);
|
||||
newp->context.uc_stack.ss_sp = spp->ss_sp;
|
||||
newp->context.uc_stack.ss_size = spp->ss_size;
|
||||
makecontext(&newp->context, lwpEntryPoint, 0);
|
||||
}
|
||||
|
||||
#elif defined(hpc)
|
||||
|
||||
static struct lwpProc *tempcontext;
|
||||
struct lwpProc *initcontext = NULL;
|
||||
|
@ -362,24 +376,6 @@ lwpInitContext(struct lwpProc *newp, void *sp)
|
|||
newp->context[5] = (int)lwpEntryPoint;
|
||||
}
|
||||
|
||||
#elif defined UCONTEXT
|
||||
|
||||
/*
|
||||
* Alternate aproach using setcontext en getcontext in stead of setjmp and
|
||||
* longjump. This should work on any SVr4 machine independant of
|
||||
* architecture. Unfortunaltely some changes are still nessesary in lwp.c.
|
||||
* Tested on IRIX 5.3
|
||||
*/
|
||||
|
||||
void
|
||||
lwpInitContext(struct lwpProc *newp, stack_t *spp)
|
||||
{
|
||||
getcontext(&newp->context);
|
||||
newp->context.uc_stack.ss_sp = spp->ss_sp;
|
||||
newp->context.uc_stack.ss_size = spp->ss_size;
|
||||
makecontext(&newp->context, lwpEntryPoint, 0);
|
||||
}
|
||||
|
||||
#elif defined(ALPHA)
|
||||
|
||||
#include <c_asm.h>
|
||||
|
@ -416,5 +412,3 @@ lwpRestore(jmp_buf jb)
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -29,35 +29,31 @@
|
|||
/* more inefficient the context switch time */
|
||||
#define LCOUNT -1
|
||||
|
||||
#ifdef hpc
|
||||
extern struct lwpProc *initcontext;
|
||||
extern int startpoint;
|
||||
#ifdef UCONTEXT
|
||||
void lwpInitContext(struct lwpProc *, stack_t *);
|
||||
#define lwpSave(x) getcontext(&(x))
|
||||
#define lwpRestore(x) setcontext(&(x))
|
||||
#else /* !UCONTEXT */
|
||||
#if defined(hpux) && !defined(hpc)
|
||||
void lwpInitContext(volatile struct lwpProc * volatile, void *);
|
||||
#else
|
||||
void lwpInitContext(struct lwpProc *, void *);
|
||||
#endif
|
||||
|
||||
#ifdef hpux
|
||||
int lwpSave(jmp_buf);
|
||||
void lwpRestore(jmp_buf);
|
||||
#endif
|
||||
|
||||
#if defined(MIPS) || defined(AIX32) || defined(ALPHA) || defined(__vax)
|
||||
#if (defined(hpux) && !defined(hpc)) || defined(MIPS) || defined(AIX32) || defined(ALPHA) || defined(__vax)
|
||||
int lwpSave(jmp_buf);
|
||||
void lwpRestore(jmp_buf);
|
||||
#elif defined(SUN4)
|
||||
#define lwpSave(x) _setjmp(x)
|
||||
#define lwpRestore(x) _longjmp(x, 1)
|
||||
#elif defined (UCONTEXT)
|
||||
#define lwpSave(x) getcontext(&(x))
|
||||
#define lwpRestore(x) setcontext(&(x))
|
||||
#else
|
||||
#define lwpSave(x) setjmp(x)
|
||||
#define lwpRestore(x) longjmp(x, 1)
|
||||
#endif
|
||||
#endif /* !UCONTEXT */
|
||||
|
||||
#ifdef hpc
|
||||
#define lwpSave(x) setjmp(x)
|
||||
#define lwpRestore(x) longjmp(x, 1)
|
||||
#else
|
||||
#ifndef hpux
|
||||
#define lwpSave(x) setjmp(x)
|
||||
#define lwpRestore(x) longjmp(x, 1)
|
||||
#endif /* hpux */
|
||||
#endif /* hpc */
|
||||
extern struct lwpProc *initcontext;
|
||||
extern int startpoint;
|
||||
#endif
|
||||
|
||||
#ifdef AIX32
|
||||
|
@ -72,12 +68,12 @@ void lwpRestore(jmp_buf);
|
|||
/* XXX Note that this assumes sizeof(long) == 4 */
|
||||
#define LWP_CHECKMARK 0x5a5a5a5aL
|
||||
|
||||
#ifndef hpux
|
||||
typedef double stkalign_t;
|
||||
#else
|
||||
#ifdef hpux
|
||||
typedef struct {
|
||||
char x[64];
|
||||
} stkalign_t;
|
||||
#else
|
||||
typedef double stkalign_t;
|
||||
#endif
|
||||
|
||||
/* internal routines */
|
||||
|
@ -85,20 +81,6 @@ void lwpAddTail(struct lwpQueue *, struct lwpProc *);
|
|||
struct lwpProc *lwpGetFirst(struct lwpQueue *);
|
||||
void lwpReady(struct lwpProc *);
|
||||
void lwpReschedule(void);
|
||||
|
||||
#ifdef UCONTEXT
|
||||
void lwpInitContext(struct lwpProc *, stack_t *);
|
||||
#else /* GETCONTEXT */
|
||||
#ifdef hpc
|
||||
void lwpInitContext(struct lwpProc *, void *);
|
||||
#else
|
||||
#ifdef hpux
|
||||
void lwpInitContext(volatile struct lwpProc * volatile, void *);
|
||||
#else
|
||||
void lwpInitContext(struct lwpProc *, void *);
|
||||
#endif /* hpux */
|
||||
#endif /* hpc */
|
||||
#endif /* GETCONTEXT */
|
||||
void lwpEntryPoint(void);
|
||||
void lwpInitSelect(struct lwpProc * self);
|
||||
void lwpDestroy(struct lwpProc * proc);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue