1 /* Copyright Transarc Corporation 1998 - All Rights Reserved */
3 /* process.c - manage lwp context switches be means of setjmp/longjmp. */
10 extern int PRE_Block; /* used in lwp.c and process.s */
12 extern char PRE_Block; /* used in lwp.c and process.s */
18 #if defined(AFS_SGI64_ENV)
24 #elif defined(AFS_HPUX_ENV)
26 #elif defined(AFS_LINUX20_ENV)
29 Need offset to SP in jmp_buf for this platform.
33 * On SGIs the type of the elements of the array passed to setjmp
34 * differs based on the ISA chosen. It is int for mips1 and mips2 and
35 * __uint64_t for mips3 and mips4
39 #if (_MIPS_ISA == _MIPS_ISA_MIPS3 || _MIPS_ISA == _MIPS_ISA_MIPS4)
40 typedef __uint64_t jmp_buf_type;
43 typedef int jmp_buf_type;
46 static jmp_buf jmp_tmp;
49 static jmp_buf_type *jmpBuffer;
52 savecontext(ep, savearea, sp)
54 struct lwp_context *savearea;
62 code = setjmp(savearea->setjmp_buffer);
63 jmpBuffer = (jmp_buf_type *)savearea->setjmp_buffer;
64 savearea->topstack = (char*)jmpBuffer[LWP_SP];
68 int i, *ptr = (int*)savearea->setjmp_buffer;
69 printf("savecontext\n");
70 for ( i=0; i < 5; i++)
71 printf("(%d) 0x%x ",i, ptr[i]);
73 for ( i=5; i < 10; i++)
74 printf("(%d) 0x%x ",i, ptr[i]);
87 case 0: jmpBuffer = (jmp_buf_type *)jmp_tmp;
88 jmpBuffer[LWP_SP] = (jmp_buf_type)sp;
92 assert(0); /* never returns */
95 perror("Error in setjmp1\n");
100 case 2: /* restoring frame */
104 perror("Error in setjmp2 : restoring\n");
110 struct lwp_context *savearea;
113 int i, *ptr = savearea->setjmp_buffer;
115 printf("Returning to \n");
116 for ( i=0; i < 5; i++)
117 printf("(%d) 0x%x ",i, ptr[i]);
119 for ( i=5; i < 10; i++)
120 printf("(%d) 0x%x ",i, ptr[i]);
124 longjmp(savearea->setjmp_buffer, 2);