1 // Copyright (c) Microsoft. All rights reserved. 2 // Licensed under the MIT license. See LICENSE file in the project root for 3 // full license information. 4 5 #include <windows.h> 6 7 #if defined(_M_MRX000) || defined(_M_PPC) || defined(_ALPHA) 8 #include <setjmpex.h> 9 #else 10 #include <setjmp.h> 11 #endif 12 13 #define faill() 14 #define startest() 15 #define finish() 16 17 #include "seh.h" 18 19 char test[] = "SEH0024.c"; 20 int perfect; 21 22 int main() { 23 jmp_buf JumpBuffer; 24 LONG Counter; 25 26 Counter = 0; 27 28 #if defined(_M_MRX000) || defined(_M_PPC) || defined(_ALPHA) 29 if (setjmp(JumpBuffer) == 0) 30 #else 31 if (_setjmp(JumpBuffer) == 0) 32 #endif 33 34 { 35 try { 36 try { 37 try { 38 try { 39 /* set counter = 1 */ 40 //(volatile LONG) Counter += 1; 41 *(volatile LONG*)&Counter += 1; 42 RaiseException(EXCEPTION_INT_OVERFLOW, 0, /*no flags*/ 0, 0); 43 } 44 finally { 45 /* set counter = 2 */ 46 //(volatile LONG) Counter += 1; 47 *(volatile LONG*)&Counter += 1; 48 } 49 endtry 50 } 51 finally { 52 /* set counter = 3 */ 53 //(volatile LONG) Counter += 1; 54 *(volatile LONG*)&Counter += 1; 55 /* end unwinding wiht long jump */ 56 longjmp(JumpBuffer, 1); 57 } 58 endtry 59 } 60 finally { 61 /* never gets here due to longjump ending unwinding */ 62 //(volatile LONG) Counter += 1; 63 *(volatile LONG*)&Counter += 1; 64 } 65 endtry 66 } 67 except(1) 68 /* handle exception after unwinding */ 69 { 70 /* sets counter = 4 */ 71 //(volatile LONG) Counter += 1; 72 *(volatile LONG*)&Counter += 1; 73 } 74 endtry 75 } else { 76 /* sets counter = 5 */ 77 //(volatile LONG) Counter += 1; 78 *(volatile LONG*)&Counter += 1; 79 } 80 81 if (Counter != 5) { 82 printf("TEST 24 FAILED. Counter = %d\n\r", Counter); 83 return -1; 84 } 85 86 return 0; 87 } 88