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)
34 #if defined(AFS_PPC_LINUX20_ENV)
36 #elif defined(AFS_I386_LINUX20_ENV)
38 #elif defined(AFS_SPARC_LINUX20_ENV)
41 #elif defined(AFS_SPARC64_LINUX20_ENV) && defined(AFS_32BIT_USR_ENV)
45 #error Unsupported linux LWP system type.
48 Need offset to SP in jmp_buf for this platform.
52 * On SGIs the type of the elements of the array passed to setjmp
53 * differs based on the ISA chosen. It is int for mips1 and mips2 and
54 * __uint64_t for mips3 and mips4
58 #if (_MIPS_ISA == _MIPS_ISA_MIPS3 || _MIPS_ISA == _MIPS_ISA_MIPS4)
59 typedef __uint64_t jmp_buf_type;
62 typedef int jmp_buf_type;
65 static jmp_buf jmp_tmp;
68 static jmp_buf_type *jmpBuffer;
71 savecontext(ep, savearea, sp)
73 struct lwp_context *savearea;
81 code = setjmp(savearea->setjmp_buffer);
82 jmpBuffer = (jmp_buf_type *)savearea->setjmp_buffer;
83 savearea->topstack = (char*)jmpBuffer[LWP_SP];
87 int i, *ptr = (int*)savearea->setjmp_buffer;
88 printf("savecontext\n");
89 for ( i=0; i < 5; i++)
90 printf("(%d) 0x%x ",i, ptr[i]);
92 for ( i=5; i < 10; i++)
93 printf("(%d) 0x%x ",i, ptr[i]);
103 rc = setjmp(jmp_tmp);
106 case 0: jmpBuffer = (jmp_buf_type *)jmp_tmp;
107 jmpBuffer[LWP_SP] = (jmp_buf_type)sp;
108 #if defined(AFS_SPARC_LINUX20_ENV) || (defined(AFS_SPARC64_LINUX20_ENV) && defined(AFS_32BIT_USR_ENV))
109 jmpBuffer[LWP_FP] = (jmp_buf_type)sp;
114 assert(0); /* never returns */
117 perror("Error in setjmp1\n");
122 case 2: /* restoring frame */
126 perror("Error in setjmp2 : restoring\n");
132 struct lwp_context *savearea;
135 int i, *ptr = savearea->setjmp_buffer;
137 printf("Returning to \n");
138 for ( i=0; i < 5; i++)
139 printf("(%d) 0x%x ",i, ptr[i]);
141 for ( i=5; i < 10; i++)
142 printf("(%d) 0x%x ",i, ptr[i]);
146 longjmp(savearea->setjmp_buffer, 2);