2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 /* process.c - manage lwp context switches be means of setjmp/longjmp. */
17 extern int PRE_Block; /* used in lwp.c and process.s */
19 extern char PRE_Block; /* used in lwp.c and process.s */
25 #if defined(AFS_SGI64_ENV)
31 #elif defined(AFS_HPUX_ENV)
33 #elif defined(AFS_LINUX20_ENV)
36 Need offset to SP in jmp_buf for this platform.
40 * On SGIs the type of the elements of the array passed to setjmp
41 * differs based on the ISA chosen. It is int for mips1 and mips2 and
42 * __uint64_t for mips3 and mips4
46 #if (_MIPS_ISA == _MIPS_ISA_MIPS3 || _MIPS_ISA == _MIPS_ISA_MIPS4)
47 typedef __uint64_t jmp_buf_type;
50 typedef int jmp_buf_type;
53 static jmp_buf jmp_tmp;
56 static jmp_buf_type *jmpBuffer;
59 savecontext(ep, savearea, sp)
61 struct lwp_context *savearea;
69 code = setjmp(savearea->setjmp_buffer);
70 jmpBuffer = (jmp_buf_type *)savearea->setjmp_buffer;
71 savearea->topstack = (char*)jmpBuffer[LWP_SP];
75 int i, *ptr = (int*)savearea->setjmp_buffer;
76 printf("savecontext\n");
77 for ( i=0; i < 5; i++)
78 printf("(%d) 0x%x ",i, ptr[i]);
80 for ( i=5; i < 10; i++)
81 printf("(%d) 0x%x ",i, ptr[i]);
94 case 0: jmpBuffer = (jmp_buf_type *)jmp_tmp;
95 jmpBuffer[LWP_SP] = (jmp_buf_type)sp;
99 assert(0); /* never returns */
102 perror("Error in setjmp1\n");
107 case 2: /* restoring frame */
111 perror("Error in setjmp2 : restoring\n");
117 struct lwp_context *savearea;
120 int i, *ptr = savearea->setjmp_buffer;
122 printf("Returning to \n");
123 for ( i=0; i < 5; i++)
124 printf("(%d) 0x%x ",i, ptr[i]);
126 for ( i=5; i < 10; i++)
127 printf("(%d) 0x%x ",i, ptr[i]);
131 longjmp(savearea->setjmp_buffer, 2);