Indented with src/scripts/indent-emp.
This commit is contained in:
parent
5f263a7753
commit
9b7adfbecc
437 changed files with 52211 additions and 51052 deletions
|
@ -45,198 +45,211 @@
|
|||
#if defined(hpc)
|
||||
|
||||
static struct lwpProc *tempcontext;
|
||||
struct lwpProc *initcontext=NULL;
|
||||
struct lwpProc *initcontext = NULL;
|
||||
int startpoint;
|
||||
|
||||
startcontext()
|
||||
{
|
||||
int space[10000];
|
||||
int x;
|
||||
int space[10000];
|
||||
int x;
|
||||
|
||||
startpoint = (void *) &x;
|
||||
if (!setjmp(initcontext->context)) longjmp(tempcontext->context,1);
|
||||
startpoint = (void *)&x;
|
||||
if (!setjmp(initcontext->context))
|
||||
longjmp(tempcontext->context, 1);
|
||||
|
||||
if (!setjmp(tempcontext->context)) longjmp(LwpCurrent->context,1);
|
||||
if (!setjmp(tempcontext->context))
|
||||
longjmp(LwpCurrent->context, 1);
|
||||
|
||||
lwpEntryPoint();
|
||||
lwpEntryPoint();
|
||||
}
|
||||
|
||||
void lwpInitContext(newp, sp)
|
||||
struct lwpProc *newp;
|
||||
void *sp;
|
||||
void
|
||||
lwpInitContext(newp, sp)
|
||||
struct lwpProc *newp;
|
||||
void *sp;
|
||||
{
|
||||
struct lwpProc holder;
|
||||
int endpoint;
|
||||
struct lwpProc holder;
|
||||
int endpoint;
|
||||
|
||||
if (initcontext == NULL) {
|
||||
initcontext = (struct lwpProc *) malloc (sizeof(struct lwpProc));
|
||||
tempcontext = &holder;
|
||||
if (!setjmp(tempcontext->context)) startcontext();
|
||||
}
|
||||
if (initcontext == NULL) {
|
||||
initcontext = (struct lwpProc *)malloc(sizeof(struct lwpProc));
|
||||
tempcontext = &holder;
|
||||
if (!setjmp(tempcontext->context))
|
||||
startcontext();
|
||||
}
|
||||
|
||||
tempcontext = newp;
|
||||
endpoint = &endpoint;
|
||||
if (endpoint < startpoint) {
|
||||
if (!setjmp(LwpCurrent->context)) longjmp(initcontext->context,1);
|
||||
} else {
|
||||
LwpCurrent->size = endpoint - startpoint;
|
||||
LwpCurrent->sbtm = realloc(LwpCurrent->sbtm, LwpCurrent->size);
|
||||
memcpy(LwpCurrent->sbtm, startpoint, LwpCurrent->size);
|
||||
if (!setjmp(LwpCurrent->context)) longjmp(initcontext->context,1);
|
||||
memcpy(startpoint, LwpCurrent->sbtm, LwpCurrent->size);
|
||||
}
|
||||
tempcontext = newp;
|
||||
endpoint = &endpoint;
|
||||
if (endpoint < startpoint) {
|
||||
if (!setjmp(LwpCurrent->context))
|
||||
longjmp(initcontext->context, 1);
|
||||
} else {
|
||||
LwpCurrent->size = endpoint - startpoint;
|
||||
LwpCurrent->sbtm = realloc(LwpCurrent->sbtm, LwpCurrent->size);
|
||||
memcpy(LwpCurrent->sbtm, startpoint, LwpCurrent->size);
|
||||
if (!setjmp(LwpCurrent->context))
|
||||
longjmp(initcontext->context, 1);
|
||||
memcpy(startpoint, LwpCurrent->sbtm, LwpCurrent->size);
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(hpux)
|
||||
|
||||
void lwpInitContext(newp, sp)
|
||||
volatile struct lwpProc *volatile newp;
|
||||
void *sp;
|
||||
void
|
||||
lwpInitContext(newp, sp)
|
||||
volatile struct lwpProc *volatile newp;
|
||||
void *sp;
|
||||
{
|
||||
static jmp_buf *cpp;
|
||||
extern struct lwpProc *LwpCurrent;
|
||||
|
||||
if (!lwpSave(LwpCurrent->context)) {
|
||||
cpp = (jmp_buf *)&newp->context;
|
||||
asm volatile ("ldw %0, %%sp": : "o" (sp));
|
||||
cpp = (jmp_buf *) & newp->context;
|
||||
asm volatile ("ldw %0, %%sp"::"o" (sp));
|
||||
if (!lwpSave(*cpp))
|
||||
lwpRestore(LwpCurrent->context);
|
||||
lwpEntryPoint();
|
||||
}
|
||||
}
|
||||
|
||||
int lwpSave(jb)
|
||||
jmp_buf jb;
|
||||
int
|
||||
lwpSave(jb)
|
||||
jmp_buf jb;
|
||||
{
|
||||
/* save stack pointer and return program counter */
|
||||
asm ("stw %sp, 4(%arg0)");
|
||||
asm ("stw %rp, 8(%arg0)");
|
||||
/* save stack pointer and return program counter */
|
||||
asm("stw %sp, 4(%arg0)");
|
||||
asm("stw %rp, 8(%arg0)");
|
||||
|
||||
/* save "callee save" registers */
|
||||
asm ("stw %r3, 12(%arg0)");
|
||||
asm ("stw %r4, 16(%arg0)");
|
||||
asm ("stw %r5, 20(%arg0)");
|
||||
asm ("stw %r6, 24(%arg0)");
|
||||
asm ("stw %r7, 28(%arg0)");
|
||||
asm ("stw %r8, 32(%arg0)");
|
||||
asm ("stw %r9, 36(%arg0)");
|
||||
asm ("stw %r10, 40(%arg0)");
|
||||
asm ("stw %r11, 44(%arg0)");
|
||||
asm ("stw %r12, 48(%arg0)");
|
||||
asm ("stw %r13, 52(%arg0)");
|
||||
asm ("stw %r14, 56(%arg0)");
|
||||
asm ("stw %r15, 60(%arg0)");
|
||||
asm ("stw %r16, 64(%arg0)");
|
||||
asm ("stw %r17, 68(%arg0)");
|
||||
asm ("stw %r18, 72(%arg0)");
|
||||
/* save "callee save" registers */
|
||||
asm("stw %r3, 12(%arg0)");
|
||||
asm("stw %r4, 16(%arg0)");
|
||||
asm("stw %r5, 20(%arg0)");
|
||||
asm("stw %r6, 24(%arg0)");
|
||||
asm("stw %r7, 28(%arg0)");
|
||||
asm("stw %r8, 32(%arg0)");
|
||||
asm("stw %r9, 36(%arg0)");
|
||||
asm("stw %r10, 40(%arg0)");
|
||||
asm("stw %r11, 44(%arg0)");
|
||||
asm("stw %r12, 48(%arg0)");
|
||||
asm("stw %r13, 52(%arg0)");
|
||||
asm("stw %r14, 56(%arg0)");
|
||||
asm("stw %r15, 60(%arg0)");
|
||||
asm("stw %r16, 64(%arg0)");
|
||||
asm("stw %r17, 68(%arg0)");
|
||||
asm("stw %r18, 72(%arg0)");
|
||||
|
||||
/* save "callee save" space register */
|
||||
asm volatile ("mfsp %sr3, %r1");
|
||||
asm ("stw %r1, 0(%arg0)");
|
||||
/* save "callee save" space register */
|
||||
asm volatile ("mfsp %sr3, %r1");
|
||||
asm("stw %r1, 0(%arg0)");
|
||||
|
||||
/* indicate "true return" from saved() */
|
||||
asm ("ldi 0, %ret0");
|
||||
/* indicate "true return" from saved() */
|
||||
asm("ldi 0, %ret0");
|
||||
|
||||
asm (".LABEL _comefrom_");
|
||||
asm(".LABEL _comefrom_");
|
||||
}
|
||||
|
||||
void
|
||||
lwpRestore(jb)
|
||||
jmp_buf jb;
|
||||
jmp_buf jb;
|
||||
{
|
||||
/* restore stack pointer and program counter */
|
||||
asm volatile ("ldw 4(%arg0), %sp");
|
||||
asm volatile ("ldw 8(%arg0), %rp");
|
||||
/* restore stack pointer and program counter */
|
||||
asm volatile ("ldw 4(%arg0), %sp");
|
||||
asm volatile ("ldw 8(%arg0), %rp");
|
||||
|
||||
/* restore "callee save" space register */
|
||||
asm volatile ("ldw 0(%arg0), %r1");
|
||||
asm volatile ("mtsp %r1, %sr3");
|
||||
/* restore "callee save" space register */
|
||||
asm volatile ("ldw 0(%arg0), %r1");
|
||||
asm volatile ("mtsp %r1, %sr3");
|
||||
|
||||
/* restore "callee save" registers */
|
||||
asm volatile ("ldw 12(%arg0), %r3");
|
||||
asm volatile ("ldw 16(%arg0), %r4");
|
||||
asm volatile ("ldw 20(%arg0), %r5");
|
||||
asm volatile ("ldw 24(%arg0), %r6");
|
||||
asm volatile ("ldw 28(%arg0), %r7");
|
||||
asm volatile ("ldw 32(%arg0), %r8");
|
||||
asm volatile ("ldw 36(%arg0), %r9");
|
||||
asm volatile ("ldw 40(%arg0), %r10");
|
||||
asm volatile ("ldw 44(%arg0), %r11");
|
||||
asm volatile ("ldw 48(%arg0), %r12");
|
||||
asm volatile ("ldw 52(%arg0), %r13");
|
||||
asm volatile ("ldw 56(%arg0), %r14");
|
||||
asm volatile ("ldw 60(%arg0), %r15");
|
||||
asm volatile ("ldw 64(%arg0), %r16");
|
||||
asm volatile ("ldw 68(%arg0), %r17");
|
||||
asm volatile ("ldw 72(%arg0), %r18");
|
||||
/* restore "callee save" registers */
|
||||
asm volatile ("ldw 12(%arg0), %r3");
|
||||
asm volatile ("ldw 16(%arg0), %r4");
|
||||
asm volatile ("ldw 20(%arg0), %r5");
|
||||
asm volatile ("ldw 24(%arg0), %r6");
|
||||
asm volatile ("ldw 28(%arg0), %r7");
|
||||
asm volatile ("ldw 32(%arg0), %r8");
|
||||
asm volatile ("ldw 36(%arg0), %r9");
|
||||
asm volatile ("ldw 40(%arg0), %r10");
|
||||
asm volatile ("ldw 44(%arg0), %r11");
|
||||
asm volatile ("ldw 48(%arg0), %r12");
|
||||
asm volatile ("ldw 52(%arg0), %r13");
|
||||
asm volatile ("ldw 56(%arg0), %r14");
|
||||
asm volatile ("ldw 60(%arg0), %r15");
|
||||
asm volatile ("ldw 64(%arg0), %r16");
|
||||
asm volatile ("ldw 68(%arg0), %r17");
|
||||
asm volatile ("ldw 72(%arg0), %r18");
|
||||
|
||||
/* warp to saved() to unwind the frame correctly */
|
||||
asm volatile ("bl _comefrom_, %r0");
|
||||
asm volatile ("ldi 1, %ret0");
|
||||
/* warp to saved() to unwind the frame correctly */
|
||||
asm volatile ("bl _comefrom_, %r0");
|
||||
asm volatile ("ldi 1, %ret0");
|
||||
}
|
||||
|
||||
#elif defined(BSD386)
|
||||
void lwpInitContext(newp, sp)
|
||||
struct lwpProc *newp;
|
||||
void *sp;
|
||||
void
|
||||
lwpInitContext(newp, sp)
|
||||
struct lwpProc *newp;
|
||||
void *sp;
|
||||
{
|
||||
newp->context[2] = (int)sp;
|
||||
newp->context[0] = (int)lwpEntryPoint;
|
||||
newp->context[2] = (int)sp;
|
||||
newp->context[0] = (int)lwpEntryPoint;
|
||||
}
|
||||
|
||||
#elif defined(FBSD)
|
||||
|
||||
void lwpInitContext(newp, sp)
|
||||
struct lwpProc *newp;
|
||||
void *sp;
|
||||
void
|
||||
lwpInitContext(newp, sp)
|
||||
struct lwpProc *newp;
|
||||
void *sp;
|
||||
{
|
||||
setjmp (newp->context);
|
||||
newp->context->_jb[2] = (int)sp;
|
||||
newp->context->_jb[3] = (int)sp;
|
||||
newp->context->_jb[0] = (int)lwpEntryPoint;
|
||||
setjmp(newp->context);
|
||||
newp->context->_jb[2] = (int)sp;
|
||||
newp->context->_jb[3] = (int)sp;
|
||||
newp->context->_jb[0] = (int)lwpEntryPoint;
|
||||
}
|
||||
|
||||
#elif defined(__linux__)
|
||||
|
||||
void lwpInitContext(newp, sp)
|
||||
struct lwpProc *newp;
|
||||
void *sp;
|
||||
void
|
||||
lwpInitContext(newp, sp)
|
||||
struct lwpProc *newp;
|
||||
void *sp;
|
||||
{
|
||||
#if defined(__GLIBC__) && (__GLIBC__ >= 2)
|
||||
#if defined(__PPC__)
|
||||
newp->context->__jmpbuf[JB_GPR1] = (int) sp;
|
||||
newp->context->__jmpbuf[JB_LR] = (int) lwpEntryPoint;
|
||||
newp->context->__jmpbuf[JB_GPR1] = (int)sp;
|
||||
newp->context->__jmpbuf[JB_LR] = (int)lwpEntryPoint;
|
||||
#else
|
||||
newp->context->__jmpbuf[JB_SP] = (int) sp;
|
||||
newp->context->__jmpbuf[JB_BP] = (int) sp;
|
||||
newp->context->__jmpbuf[JB_PC] = (int) lwpEntryPoint;
|
||||
newp->context->__jmpbuf[JB_SP] = (int)sp;
|
||||
newp->context->__jmpbuf[JB_BP] = (int)sp;
|
||||
newp->context->__jmpbuf[JB_PC] = (int)lwpEntryPoint;
|
||||
#endif
|
||||
#else
|
||||
newp->context->__sp = sp;
|
||||
newp->context->__bp = sp;
|
||||
newp->context->__pc = (void *)lwpEntryPoint;
|
||||
newp->context->__sp = sp;
|
||||
newp->context->__bp = sp;
|
||||
newp->context->__pc = (void *)lwpEntryPoint;
|
||||
#endif
|
||||
}
|
||||
|
||||
#elif defined(SUN3)
|
||||
|
||||
void lwpInitContext(newp, sp)
|
||||
struct lwpProc *newp;
|
||||
void *sp;
|
||||
void
|
||||
lwpInitContext(newp, sp)
|
||||
struct lwpProc *newp;
|
||||
void *sp;
|
||||
{
|
||||
newp->context[2] = (int)sp;
|
||||
newp->context[3] = (int)lwpEntryPoint;
|
||||
newp->context[2] = (int)sp;
|
||||
newp->context[3] = (int)lwpEntryPoint;
|
||||
}
|
||||
|
||||
#elif defined(__vax)
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void lwpInitContext(newp, stack)
|
||||
struct lwpProc *newp;
|
||||
void *stack;
|
||||
void
|
||||
lwpInitContext(newp, stack)
|
||||
struct lwpProc *newp;
|
||||
void *stack;
|
||||
{
|
||||
int *sp = (int*)stack;
|
||||
int *sp = (int *)stack;
|
||||
int *fp = 0;
|
||||
|
||||
/* Build root frame on new stack for lwpEntryPoint */
|
||||
|
@ -248,7 +261,7 @@ void lwpInitContext(newp, stack)
|
|||
fp = sp;
|
||||
|
||||
/* Build stack frame to return from. */
|
||||
*--sp = (int)lwpEntryPoint+2;/* pc */
|
||||
*--sp = (int)lwpEntryPoint + 2; /* pc */
|
||||
*--sp = (int)fp; /* fp */
|
||||
*--sp = 0; /* ap */
|
||||
*--sp = 0; /* psw */
|
||||
|
@ -268,8 +281,9 @@ void lwpInitContext(newp, stack)
|
|||
return;
|
||||
}
|
||||
|
||||
int lwpSave(jb)
|
||||
jmp_buf jb;
|
||||
int
|
||||
lwpSave(jb)
|
||||
jmp_buf jb;
|
||||
{
|
||||
asm("movl 4(ap), r0"); /* r0 = &jb */
|
||||
asm("movl r6, (r0)"); /* jb[0] = r6 */
|
||||
|
@ -283,8 +297,9 @@ int lwpSave(jb)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void lwpRestore(jb)
|
||||
jmp_buf jb;
|
||||
void
|
||||
lwpRestore(jb)
|
||||
jmp_buf jb;
|
||||
{
|
||||
asm("movl 4(ap), r0"); /* r0 = &jb */
|
||||
asm("movl (r0), r6"); /* r6 = jb[0] */
|
||||
|
@ -303,31 +318,32 @@ void lwpRestore(jb)
|
|||
|
||||
#elif defined(SUN4)
|
||||
|
||||
void lwpInitContext(newp, sp)
|
||||
struct lwpProc *newp;
|
||||
void *sp;
|
||||
void
|
||||
lwpInitContext(newp, sp)
|
||||
struct lwpProc *newp;
|
||||
void *sp;
|
||||
{
|
||||
static jmp_buf *cpp;
|
||||
extern struct lwpProc *LwpCurrent;
|
||||
static jmp_buf *cpp;
|
||||
extern struct lwpProc *LwpCurrent;
|
||||
|
||||
bzero(newp->context, sizeof(newp->context));
|
||||
newp->context[0] = (int)sp;
|
||||
/* preserve cpp for new context */
|
||||
cpp = (jmp_buf *)&newp->context;
|
||||
if (!_setjmp(LwpCurrent->context)) {
|
||||
/* create new context */
|
||||
/* flush registers */
|
||||
asm ("ta 0x03");
|
||||
/* %o0 <- newp */
|
||||
asm ("ld [%fp+0x44], %o0");
|
||||
/* %o1 <- newp->context[0] */
|
||||
asm ("ld [%o0], %o1");
|
||||
/* create min frame on new stack */
|
||||
asm ("save %o1,-96, %sp");
|
||||
if (!_setjmp(*cpp))
|
||||
_longjmp(LwpCurrent->context, 1);
|
||||
lwpEntryPoint();
|
||||
}
|
||||
bzero(newp->context, sizeof(newp->context));
|
||||
newp->context[0] = (int)sp;
|
||||
/* preserve cpp for new context */
|
||||
cpp = (jmp_buf *) & newp->context;
|
||||
if (!_setjmp(LwpCurrent->context)) {
|
||||
/* create new context */
|
||||
/* flush registers */
|
||||
asm("ta 0x03");
|
||||
/* %o0 <- newp */
|
||||
asm("ld [%fp+0x44], %o0");
|
||||
/* %o1 <- newp->context[0] */
|
||||
asm("ld [%o0], %o1");
|
||||
/* create min frame on new stack */
|
||||
asm("save %o1,-96, %sp");
|
||||
if (!_setjmp(*cpp))
|
||||
_longjmp(LwpCurrent->context, 1);
|
||||
lwpEntryPoint();
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(__USLC__) && defined(i386)
|
||||
|
@ -360,12 +376,13 @@ void lwpInitContext(newp, sp)
|
|||
* context + 0x14 [5] -> jump location for return
|
||||
*/
|
||||
|
||||
void lwpInitContext(newp, sp)
|
||||
struct lwpProc *newp;
|
||||
void *sp;
|
||||
void
|
||||
lwpInitContext(newp, sp)
|
||||
struct lwpProc *newp;
|
||||
void *sp;
|
||||
{
|
||||
newp->context[4] = (int)sp;
|
||||
newp->context[5] = (int)lwpEntryPoint;
|
||||
newp->context[4] = (int)sp;
|
||||
newp->context[5] = (int)lwpEntryPoint;
|
||||
}
|
||||
|
||||
#elif defined UCONTEXT
|
||||
|
@ -375,50 +392,54 @@ void lwpInitContext(newp, sp)
|
|||
* 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(newp, spp)
|
||||
struct lwpProc *newp;
|
||||
stack_t *spp;
|
||||
void
|
||||
lwpInitContext(newp, spp)
|
||||
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);
|
||||
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>
|
||||
|
||||
void lwpInitContext(newp, sp)
|
||||
struct lwpProc *newp;
|
||||
void *sp;
|
||||
void
|
||||
lwpInitContext(newp, sp)
|
||||
struct lwpProc *newp;
|
||||
void *sp;
|
||||
{
|
||||
extern long *_gp;
|
||||
extern long *_gp;
|
||||
|
||||
/* register values obtained from setjmp.h */
|
||||
_setjmp(newp->context);
|
||||
newp->context[2] = (long)lwpEntryPoint; /* program counter */
|
||||
newp->context[30] = (long)lwpEntryPoint; /* return address */
|
||||
newp->context[31] = (long)lwpEntryPoint; /* fake program value (!) */
|
||||
newp->context[34] = (long)sp; /* stack pointer */
|
||||
/* register values obtained from setjmp.h */
|
||||
_setjmp(newp->context);
|
||||
newp->context[2] = (long)lwpEntryPoint; /* program counter */
|
||||
newp->context[30] = (long)lwpEntryPoint; /* return address */
|
||||
newp->context[31] = (long)lwpEntryPoint; /* fake program value (!) */
|
||||
newp->context[34] = (long)sp; /* stack pointer */
|
||||
}
|
||||
|
||||
int lwpSave(jb)
|
||||
jmp_buf jb;
|
||||
int
|
||||
lwpSave(jb)
|
||||
jmp_buf jb;
|
||||
{
|
||||
return _setjmp(jb);
|
||||
return _setjmp(jb);
|
||||
}
|
||||
|
||||
void lwpRestore(jb)
|
||||
jmp_buf jb;
|
||||
void
|
||||
lwpRestore(jb)
|
||||
jmp_buf jb;
|
||||
{
|
||||
/* resume, but get the pv from the jmp_buf */
|
||||
asm("ldq %pv, 248(%a0)");
|
||||
asm("stq %a0, 16(%sp)");
|
||||
/* generates a warning, but functions just fine */
|
||||
asm("bsr %ra, __longjump_resume");
|
||||
/* resume, but get the pv from the jmp_buf */
|
||||
asm("ldq %pv, 248(%a0)");
|
||||
asm("stq %a0, 16(%sp)");
|
||||
/* generates a warning, but functions just fine */
|
||||
asm("bsr %ra, __longjump_resume");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue