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(_EMPTH_LWP)
|
||||||
|
|
||||||
#if (!defined(AIX32))
|
|
||||||
|
|
||||||
#include "lwp.h"
|
#include "lwp.h"
|
||||||
|
|
||||||
#include "lwpint.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;
|
static struct lwpProc *tempcontext;
|
||||||
struct lwpProc *initcontext = NULL;
|
struct lwpProc *initcontext = NULL;
|
||||||
|
@ -362,24 +376,6 @@ lwpInitContext(struct lwpProc *newp, void *sp)
|
||||||
newp->context[5] = (int)lwpEntryPoint;
|
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)
|
#elif defined(ALPHA)
|
||||||
|
|
||||||
#include <c_asm.h>
|
#include <c_asm.h>
|
||||||
|
@ -416,5 +412,3 @@ lwpRestore(jmp_buf jb)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -29,35 +29,31 @@
|
||||||
/* more inefficient the context switch time */
|
/* more inefficient the context switch time */
|
||||||
#define LCOUNT -1
|
#define LCOUNT -1
|
||||||
|
|
||||||
#ifdef hpc
|
#ifdef UCONTEXT
|
||||||
extern struct lwpProc *initcontext;
|
void lwpInitContext(struct lwpProc *, stack_t *);
|
||||||
extern int startpoint;
|
#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
|
#endif
|
||||||
|
#if (defined(hpux) && !defined(hpc)) || defined(MIPS) || defined(AIX32) || defined(ALPHA) || defined(__vax)
|
||||||
#ifdef hpux
|
|
||||||
int lwpSave(jmp_buf);
|
|
||||||
void lwpRestore(jmp_buf);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(MIPS) || defined(AIX32) || defined(ALPHA) || defined(__vax)
|
|
||||||
int lwpSave(jmp_buf);
|
int lwpSave(jmp_buf);
|
||||||
void lwpRestore(jmp_buf);
|
void lwpRestore(jmp_buf);
|
||||||
#elif defined(SUN4)
|
#elif defined(SUN4)
|
||||||
#define lwpSave(x) _setjmp(x)
|
#define lwpSave(x) _setjmp(x)
|
||||||
#define lwpRestore(x) _longjmp(x, 1)
|
#define lwpRestore(x) _longjmp(x, 1)
|
||||||
#elif defined (UCONTEXT)
|
|
||||||
#define lwpSave(x) getcontext(&(x))
|
|
||||||
#define lwpRestore(x) setcontext(&(x))
|
|
||||||
#else
|
#else
|
||||||
|
#define lwpSave(x) setjmp(x)
|
||||||
|
#define lwpRestore(x) longjmp(x, 1)
|
||||||
|
#endif
|
||||||
|
#endif /* !UCONTEXT */
|
||||||
|
|
||||||
#ifdef hpc
|
#ifdef hpc
|
||||||
#define lwpSave(x) setjmp(x)
|
extern struct lwpProc *initcontext;
|
||||||
#define lwpRestore(x) longjmp(x, 1)
|
extern int startpoint;
|
||||||
#else
|
|
||||||
#ifndef hpux
|
|
||||||
#define lwpSave(x) setjmp(x)
|
|
||||||
#define lwpRestore(x) longjmp(x, 1)
|
|
||||||
#endif /* hpux */
|
|
||||||
#endif /* hpc */
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef AIX32
|
#ifdef AIX32
|
||||||
|
@ -72,12 +68,12 @@ void lwpRestore(jmp_buf);
|
||||||
/* XXX Note that this assumes sizeof(long) == 4 */
|
/* XXX Note that this assumes sizeof(long) == 4 */
|
||||||
#define LWP_CHECKMARK 0x5a5a5a5aL
|
#define LWP_CHECKMARK 0x5a5a5a5aL
|
||||||
|
|
||||||
#ifndef hpux
|
#ifdef hpux
|
||||||
typedef double stkalign_t;
|
|
||||||
#else
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char x[64];
|
char x[64];
|
||||||
} stkalign_t;
|
} stkalign_t;
|
||||||
|
#else
|
||||||
|
typedef double stkalign_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* internal routines */
|
/* internal routines */
|
||||||
|
@ -85,20 +81,6 @@ void lwpAddTail(struct lwpQueue *, struct lwpProc *);
|
||||||
struct lwpProc *lwpGetFirst(struct lwpQueue *);
|
struct lwpProc *lwpGetFirst(struct lwpQueue *);
|
||||||
void lwpReady(struct lwpProc *);
|
void lwpReady(struct lwpProc *);
|
||||||
void lwpReschedule(void);
|
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 lwpEntryPoint(void);
|
||||||
void lwpInitSelect(struct lwpProc * self);
|
void lwpInitSelect(struct lwpProc * self);
|
||||||
void lwpDestroy(struct lwpProc * proc);
|
void lwpDestroy(struct lwpProc * proc);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue