Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

xcpt4.c File Reference

#include "stdio.h"
#include "nt.h"
#include "ntrtl.h"
#include "setjmpex.h"
#include "float.h"

Go to the source code of this file.

Defines

#define BLUE   0
#define RED   1

Functions

VOID addtwo (IN LONG First, IN LONG Second, IN PLONG Place)
VOID bar1 (IN NTSTATUS Status, IN PLONG Counter)
VOID bar2 (IN PLONG BlackHole, IN PLONG BadAddress, IN PLONG Counter)
VOID dojump (IN jmp_buf JumpBuffer, IN PLONG Counter)
LONG Echo (IN LONG Value)
VOID eret (IN NTSTATUS Status, IN PLONG Counter)
VOID except1 (IN PLONG Counter)
ULONG except2 (IN PEXCEPTION_POINTERS ExceptionPointers, IN PLONG Counter)
ULONG except3 (IN PEXCEPTION_POINTERS ExceptionPointers, IN PLONG Counter)
VOID foo1 (IN NTSTATUS Status)
VOID foo2 (IN PLONG BlackHole, IN PLONG BadAddress)
VOID fret (IN PLONG Counter)
BOOLEAN Tkm (VOID)
VOID Test61Part2 (IN OUT PULONG Counter)
VOID PerformFpTest (VOID)
double SquareDouble (IN double op)
VOID SquareDouble17E300 (OUT PVOID ans)
VOID __cdecl main (int argc, char *argv[])
VOID PerformFpTest ()
VOID addtwo (long First, long Second, long *Place)


Define Documentation

#define BLUE   0
 

Definition at line 38 of file xcpt4.c.

Referenced by main().

#define RED   1
 

Definition at line 39 of file xcpt4.c.

Referenced by main().


Function Documentation

VOID addtwo long  First,
long  Second,
long *  Place
 

Definition at line 2131 of file xcpt4.c.

References RtlRaiseStatus().

Referenced by main().

02137 { 02138 02139 RtlRaiseStatus(STATUS_INTEGER_OVERFLOW); 02140 *Place = First + Second; 02141 return; 02142 }

VOID addtwo IN LONG  First,
IN LONG  Second,
IN PLONG  Place
 

VOID bar1 IN NTSTATUS  Status,
IN PLONG  Counter
 

Definition at line 2145 of file xcpt4.c.

References FALSE, foo1(), and Status.

Referenced by main().

02149 { 02150 02151 try { 02152 foo1(Status); 02153 02154 } finally { 02155 if (abnormal_termination() != FALSE) { 02156 *Counter = 99; 02157 02158 } else { 02159 *Counter = 100; 02160 } 02161 } 02162 02163 return; 02164 }

VOID bar2 IN PLONG  BlackHole,
IN PLONG  BadAddress,
IN PLONG  Counter
 

Definition at line 2167 of file xcpt4.c.

References FALSE, and foo2().

Referenced by main().

02172 { 02173 02174 try { 02175 foo2(BlackHole, BadAddress); 02176 02177 } finally { 02178 if (abnormal_termination() != FALSE) { 02179 *Counter = 99; 02180 02181 } else { 02182 *Counter = 100; 02183 } 02184 } 02185 02186 return; 02187 }

VOID dojump IN jmp_buf  JumpBuffer,
IN PLONG  Counter
 

Definition at line 2190 of file xcpt4.c.

References longjmp(), and RtlRaiseStatus().

Referenced by main().

02195 { 02196 02197 try { 02198 try { 02199 *Counter += 1; 02200 RtlRaiseStatus(STATUS_INTEGER_OVERFLOW); 02201 02202 } finally { 02203 *Counter += 1; 02204 } 02205 02206 } finally { 02207 *Counter += 1; 02208 longjmp(JumpBuffer, 1); 02209 } 02210 }

LONG Echo IN LONG  Value  ) 
 

Definition at line 2358 of file xcpt4.c.

Referenced by main(), and ReadChars().

02362 { 02363 return Value; 02364 }

VOID eret IN NTSTATUS  Status,
IN PLONG  Counter
 

Definition at line 2213 of file xcpt4.c.

References EXCEPTION_CONTINUE_SEARCH, EXCEPTION_EXECUTE_HANDLER, foo1(), and Status.

02218 { 02219 02220 try { 02221 try { 02222 foo1(Status); 02223 02224 } except ((GetExceptionCode() == Status) ? 02225 EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { 02226 *Counter += 1; 02227 return; 02228 } 02229 02230 } finally { 02231 *Counter += 1; 02232 } 02233 02234 return; 02235 }

VOID except1 IN PLONG  Counter  ) 
 

Definition at line 2238 of file xcpt4.c.

References except3(), and RtlRaiseStatus().

Referenced by main().

02242 { 02243 02244 try { 02245 *Counter += 5; 02246 RtlRaiseStatus(STATUS_INTEGER_OVERFLOW); 02247 02248 } except (except3(GetExceptionInformation(), Counter)) { 02249 *Counter += 7; 02250 } 02251 02252 *Counter += 9; 02253 return; 02254 }

ULONG except2 IN PEXCEPTION_POINTERS  ExceptionPointers,
IN PLONG  Counter
 

Definition at line 2257 of file xcpt4.c.

References EXCEPTION_CONTINUE_SEARCH, EXCEPTION_EXECUTE_HANDLER, and EXCEPTION_NESTED_CALL.

Referenced by main().

02262 { 02263 02264 PEXCEPTION_RECORD ExceptionRecord; 02265 02266 ExceptionRecord = ExceptionPointers->ExceptionRecord; 02267 if ((ExceptionRecord->ExceptionCode == STATUS_UNSUCCESSFUL) && 02268 ((ExceptionRecord->ExceptionFlags & EXCEPTION_NESTED_CALL) == 0)) { 02269 *Counter += 11; 02270 return EXCEPTION_EXECUTE_HANDLER; 02271 02272 } else { 02273 *Counter += 13; 02274 return EXCEPTION_CONTINUE_SEARCH; 02275 } 02276 }

ULONG except3 IN PEXCEPTION_POINTERS  ExceptionPointers,
IN PLONG  Counter
 

Definition at line 2279 of file xcpt4.c.

References EXCEPTION_CONTINUE_SEARCH, EXCEPTION_EXECUTE_HANDLER, EXCEPTION_NESTED_CALL, and RtlRaiseStatus().

Referenced by except1().

02284 { 02285 02286 PEXCEPTION_RECORD ExceptionRecord; 02287 02288 ExceptionRecord = ExceptionPointers->ExceptionRecord; 02289 if ((ExceptionRecord->ExceptionCode == STATUS_INTEGER_OVERFLOW) && 02290 ((ExceptionRecord->ExceptionFlags & EXCEPTION_NESTED_CALL) == 0)) { 02291 *Counter += 17; 02292 RtlRaiseStatus(STATUS_UNSUCCESSFUL); 02293 02294 } else if ((ExceptionRecord->ExceptionCode == STATUS_UNSUCCESSFUL) && 02295 ((ExceptionRecord->ExceptionFlags & EXCEPTION_NESTED_CALL) != 0)) { 02296 *Counter += 19; 02297 return EXCEPTION_CONTINUE_SEARCH; 02298 } 02299 02300 *Counter += 23; 02301 return EXCEPTION_EXECUTE_HANDLER; 02302 }

VOID foo1 IN NTSTATUS  Status  ) 
 

Definition at line 2305 of file xcpt4.c.

References RtlRaiseStatus(), and Status.

Referenced by bar1(), eret(), and main().

02309 { 02310 02311 // 02312 // Raise exception. 02313 // 02314 02315 RtlRaiseStatus(Status); 02316 return; 02317 }

VOID foo2 IN PLONG  BlackHole,
IN PLONG  BadAddress
 

Definition at line 2320 of file xcpt4.c.

Referenced by bar2(), and main().

02325 { 02326 02327 // 02328 // Raise exception. 02329 // 02330 02331 *BlackHole += *BadAddress; 02332 return; 02333 }

VOID fret IN PLONG  Counter  ) 
 

Definition at line 2336 of file xcpt4.c.

Referenced by _GetTextMetricsW().

02340 { 02341 02342 try { 02343 try { 02344 *Counter += 1; 02345 02346 } finally { 02347 *Counter += 1; 02348 return; 02349 } 02350 } finally { 02351 *Counter += 1; 02352 } 02353 02354 return; 02355 }

VOID __cdecl main int  argc,
char *  argv[]
 

Definition at line 143 of file xcpt4.c.

References addtwo(), bar1(), bar2(), BLUE, dojump(), Echo(), eret(), except1(), except2(), EXCEPTION_CONTINUE_SEARCH, EXCEPTION_EXECUTE_HANDLER, FALSE, foo1(), foo2(), fret(), longjmp(), NULL, PerformFpTest(), RED, RtlRaiseException(), RtlRaiseStatus(), setjmp(), SquareDouble(), and Test61Part2().

00148 { 00149 00150 PLONG BadAddress; 00151 PCHAR BadByte; 00152 PLONG BlackHole; 00153 ULONG Index1; 00154 ULONG Index2 = RED; 00155 jmp_buf JumpBuffer; 00156 LONG Counter; 00157 EXCEPTION_RECORD ExceptionRecord; 00158 double doubleresult; 00159 00160 // 00161 // Announce start of exception test. 00162 // 00163 00164 printf("Start of exception test\n"); 00165 00166 // 00167 // Initialize exception record. 00168 // 00169 00170 ExceptionRecord.ExceptionCode = STATUS_INTEGER_OVERFLOW; 00171 ExceptionRecord.ExceptionFlags = 0; 00172 ExceptionRecord.ExceptionRecord = NULL; 00173 ExceptionRecord.NumberParameters = 0; 00174 00175 // 00176 // Initialize pointers. 00177 // 00178 00179 BadAddress = (PLONG)NULL; 00180 BadByte = (PCHAR)NULL; 00181 BadByte += 1; 00182 BlackHole = &Counter; 00183 00184 // 00185 // Simply try statement with a finally clause that is entered sequentially. 00186 // 00187 00188 printf(" test1..."); 00189 Counter = 0; 00190 try { 00191 Counter += 1; 00192 00193 } finally { 00194 if (abnormal_termination() == FALSE) { 00195 Counter += 1; 00196 } 00197 } 00198 00199 if (Counter != 2) { 00200 printf("failed, count = %d\n", Counter); 00201 00202 } else { 00203 printf("succeeded\n"); 00204 } 00205 00206 // 00207 // Simple try statement with an exception clause that is never executed 00208 // because there is no exception raised in the try clause. 00209 // 00210 00211 printf(" test2..."); 00212 Counter = 0; 00213 try { 00214 Counter += 1; 00215 00216 } except (Counter) { 00217 Counter += 1; 00218 } 00219 00220 if (Counter != 1) { 00221 printf("failed, count = %d\n", Counter); 00222 00223 } else { 00224 printf("succeeded\n"); 00225 } 00226 00227 // 00228 // Simple try statement with an exception handler that is never executed 00229 // because the exception expression continues execution. 00230 // 00231 00232 printf(" test3..."); 00233 Counter = 0; 00234 try { 00235 Counter -= 1; 00236 RtlRaiseException(&ExceptionRecord); 00237 00238 } except (Counter) { 00239 Counter -= 1; 00240 } 00241 00242 if (Counter != - 1) { 00243 printf("failed, count = %d\n", Counter); 00244 00245 } else { 00246 printf("succeeded\n"); 00247 } 00248 00249 // 00250 // Simple try statement with an exception clause that is always executed. 00251 // 00252 00253 printf(" test4..."); 00254 Counter = 0; 00255 try { 00256 Counter += 1; 00257 RtlRaiseStatus(STATUS_INTEGER_OVERFLOW); 00258 00259 } except (Counter) { 00260 Counter += 1; 00261 } 00262 00263 if (Counter != 2) { 00264 printf("failed, count = %d\n", Counter); 00265 00266 } else { 00267 printf("succeeded\n"); 00268 } 00269 00270 // 00271 // Simple try statement with an exception clause that is always executed. 00272 // 00273 00274 printf(" test5..."); 00275 Counter = 0; 00276 try { 00277 Counter += 1; 00278 *BlackHole += *BadAddress; 00279 00280 } except (Counter) { 00281 Counter += 1; 00282 } 00283 00284 if (Counter != 2) { 00285 printf("failed, count = %d\n", Counter); 00286 00287 } else { 00288 printf("succeeded\n"); 00289 } 00290 00291 // 00292 // Simply try statement with a finally clause that is entered as the 00293 // result of an exception. 00294 // 00295 00296 printf(" test6..."); 00297 Counter = 0; 00298 try { 00299 try { 00300 Counter += 1; 00301 RtlRaiseException(&ExceptionRecord); 00302 00303 } finally { 00304 if (abnormal_termination() != FALSE) { 00305 Counter += 1; 00306 } 00307 } 00308 00309 } except (Counter) { 00310 if (Counter == 2) { 00311 Counter += 1; 00312 } 00313 } 00314 00315 if (Counter != 3) { 00316 printf("failed, count = %d\n", Counter); 00317 00318 } else { 00319 printf("succeeded\n"); 00320 } 00321 00322 // 00323 // Simply try statement with a finally clause that is entered as the 00324 // result of an exception. 00325 // 00326 00327 printf(" test7..."); 00328 Counter = 0; 00329 try { 00330 try { 00331 Counter += 1; 00332 *BlackHole += *BadAddress; 00333 00334 } finally { 00335 if (abnormal_termination() != FALSE) { 00336 Counter += 1; 00337 } 00338 } 00339 00340 } except (Counter) { 00341 if (Counter == 2) { 00342 Counter += 1; 00343 } 00344 } 00345 00346 if (Counter != 3) { 00347 printf("failed, count = %d\n", Counter); 00348 00349 } else { 00350 printf("succeeded\n"); 00351 } 00352 00353 // 00354 // Simple try that calls a function which raises an exception. 00355 // 00356 00357 printf(" test8..."); 00358 Counter = 0; 00359 try { 00360 Counter += 1; 00361 foo1(STATUS_ACCESS_VIOLATION); 00362 00363 } except ((GetExceptionCode() == STATUS_ACCESS_VIOLATION) ? 00364 EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { 00365 Counter += 1; 00366 } 00367 00368 if (Counter != 2) { 00369 printf("failed, count = %d\n", Counter); 00370 00371 } else { 00372 printf("succeeded\n"); 00373 } 00374 00375 // 00376 // Simple try that calls a function which raises an exception. 00377 // 00378 00379 printf(" test9..."); 00380 Counter = 0; 00381 try { 00382 Counter += 1; 00383 foo2(BlackHole, BadAddress); 00384 00385 } except ((GetExceptionCode() == STATUS_ACCESS_VIOLATION) ? 00386 EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { 00387 Counter += 1; 00388 } 00389 00390 if (Counter != 2) { 00391 printf("failed, count = %d\n", Counter); 00392 00393 } else { 00394 printf("succeeded\n"); 00395 } 00396 00397 // 00398 // Simple try that calls a function which calls a function that 00399 // raises an exception. The first function has a finally clause 00400 // that must be executed for this test to work. 00401 // 00402 00403 printf(" test10..."); 00404 Counter = 0; 00405 try { 00406 bar1(STATUS_ACCESS_VIOLATION, &Counter); 00407 00408 } except ((GetExceptionCode() == STATUS_ACCESS_VIOLATION) ? 00409 EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { 00410 Counter -= 1; 00411 } 00412 00413 if (Counter != 98) { 00414 printf("failed, count = %d\n", Counter); 00415 00416 } else { 00417 printf("succeeded\n"); 00418 } 00419 00420 // 00421 // Simple try that calls a function which calls a function that 00422 // raises an exception. The first function has a finally clause 00423 // that must be executed for this test to work. 00424 // 00425 00426 printf(" test11..."); 00427 Counter = 0; 00428 try { 00429 bar2(BlackHole, BadAddress, &Counter); 00430 00431 } except ((GetExceptionCode() == STATUS_ACCESS_VIOLATION) ? 00432 EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { 00433 Counter -= 1; 00434 } 00435 00436 if (Counter != 98) { 00437 printf("failed, count = %d\n", Counter); 00438 00439 } else { 00440 printf("succeeded\n"); 00441 } 00442 00443 // 00444 // A try within an except 00445 // 00446 00447 printf(" test12..."); 00448 Counter = 0; 00449 try { 00450 foo1(STATUS_ACCESS_VIOLATION); 00451 00452 } except ((GetExceptionCode() == STATUS_ACCESS_VIOLATION) ? 00453 EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { 00454 Counter += 1; 00455 try { 00456 foo1(STATUS_SUCCESS); 00457 00458 } except ((GetExceptionCode() == STATUS_SUCCESS) ? 00459 EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { 00460 if (Counter != 1) { 00461 printf("failed, count = %d\n", Counter); 00462 00463 } else { 00464 printf("succeeded..."); 00465 } 00466 00467 Counter += 1; 00468 } 00469 } 00470 00471 if (Counter != 2) { 00472 printf("failed, count = %d\n", Counter); 00473 00474 } else { 00475 printf("succeeded\n"); 00476 } 00477 00478 // 00479 // A try within an except 00480 // 00481 00482 printf(" test13..."); 00483 Counter = 0; 00484 try { 00485 foo2(BlackHole, BadAddress); 00486 00487 } except ((GetExceptionCode() == STATUS_ACCESS_VIOLATION) ? 00488 EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { 00489 Counter += 1; 00490 try { 00491 foo1(STATUS_SUCCESS); 00492 00493 } except ((GetExceptionCode() == STATUS_SUCCESS) ? 00494 EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { 00495 if (Counter != 1) { 00496 printf("failed, count = %d\n", Counter); 00497 00498 } else { 00499 printf("succeeded..."); 00500 } 00501 00502 Counter += 1; 00503 } 00504 } 00505 00506 if (Counter != 2) { 00507 printf("failed, count = %d\n", Counter); 00508 00509 } else { 00510 printf("succeeded\n"); 00511 } 00512 00513 // 00514 // A goto from an exception clause that needs to pass 00515 // through a finally 00516 // 00517 00518 printf(" test14..."); 00519 Counter = 0; 00520 try { 00521 try { 00522 foo1(STATUS_ACCESS_VIOLATION); 00523 00524 } except ((GetExceptionCode() == STATUS_ACCESS_VIOLATION) ? 00525 EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { 00526 Counter += 1; 00527 goto t9; 00528 } 00529 00530 } finally { 00531 Counter += 1; 00532 } 00533 00534 t9:; 00535 if (Counter != 2) { 00536 printf("failed, count = %d\n", Counter); 00537 00538 } else { 00539 printf("succeeded\n"); 00540 } 00541 00542 // 00543 // A goto from an finally clause that needs to pass 00544 // through a finally 00545 // 00546 00547 printf(" test15..."); 00548 Counter = 0; 00549 try { 00550 try { 00551 Counter += 1; 00552 00553 } finally { 00554 Counter += 1; 00555 goto t10; 00556 } 00557 00558 } finally { 00559 Counter += 1; 00560 } 00561 00562 t10:; 00563 if (Counter != 3) { 00564 printf("failed, count = %d\n", Counter); 00565 00566 } else { 00567 printf("succeeded\n"); 00568 } 00569 00570 // 00571 // A goto from an exception clause that needs to pass 00572 // through a finally into the outer finally clause. 00573 // 00574 00575 printf(" test16..."); 00576 Counter = 0; 00577 try { 00578 try { 00579 try { 00580 Counter += 1; 00581 foo1(STATUS_INTEGER_OVERFLOW); 00582 00583 } except (EXCEPTION_EXECUTE_HANDLER) { 00584 Counter += 1; 00585 goto t11; 00586 } 00587 00588 } finally { 00589 Counter += 1; 00590 } 00591 t11:; 00592 } finally { 00593 Counter += 1; 00594 } 00595 00596 if (Counter != 4) { 00597 printf("failed, count = %d\n", Counter); 00598 00599 } else { 00600 printf("succeeded\n"); 00601 } 00602 00603 // 00604 // A goto from an finally clause that needs to pass 00605 // through a finally into the outer finally clause. 00606 // 00607 00608 printf(" test17..."); 00609 Counter = 0; 00610 try { 00611 try { 00612 Counter += 1; 00613 00614 } finally { 00615 Counter += 1; 00616 goto t12; 00617 } 00618 t12:; 00619 } finally { 00620 Counter += 1; 00621 } 00622 00623 if (Counter != 3) { 00624 printf("failed, count = %d\n", Counter); 00625 00626 } else { 00627 printf("succeeded\n"); 00628 } 00629 00630 // 00631 // A return from an except clause 00632 // 00633 00634 printf(" test18..."); 00635 Counter = 0; 00636 try { 00637 Counter += 1; 00638 eret(STATUS_ACCESS_VIOLATION, &Counter); 00639 00640 } finally { 00641 Counter += 1; 00642 } 00643 00644 if (Counter != 4) { 00645 printf("failed, count = %d\n", Counter); 00646 00647 } else { 00648 printf("succeeded\n"); 00649 } 00650 00651 // 00652 // A return from a finally clause 00653 // 00654 00655 printf(" test19..."); 00656 Counter = 0; 00657 try { 00658 Counter += 1; 00659 fret(&Counter); 00660 00661 } finally { 00662 Counter += 1; 00663 } 00664 00665 if (Counter != 5) { 00666 printf("failed, count = %d\n", Counter); 00667 00668 } else { 00669 printf("succeeded\n"); 00670 } 00671 00672 // 00673 // A simple set jump followed by a long jump. 00674 // 00675 00676 printf(" test20..."); 00677 Counter = 0; 00678 if (setjmp(JumpBuffer) == 0) { 00679 Counter += 1; 00680 longjmp(JumpBuffer, 1); 00681 00682 } else { 00683 Counter += 1; 00684 } 00685 00686 if (Counter != 2) { 00687 printf("failed, count = %d\n", Counter); 00688 00689 } else { 00690 printf("succeeded\n"); 00691 } 00692 00693 // 00694 // A set jump followed by a long jump out of a finally clause that is 00695 // sequentially executed. 00696 // 00697 00698 printf(" test21..."); 00699 Counter = 0; 00700 if (setjmp(JumpBuffer) == 0) { 00701 try { 00702 Counter += 1; 00703 00704 } finally { 00705 Counter += 1; 00706 longjmp(JumpBuffer, 1); 00707 } 00708 00709 } else { 00710 Counter += 1; 00711 } 00712 00713 if (Counter != 3) { 00714 printf("failed, count = %d\n", Counter); 00715 00716 } else { 00717 printf("succeeded\n"); 00718 } 00719 00720 // 00721 // A set jump within a try clause followed by a long jump out of a 00722 // finally clause that is sequentially executed. 00723 // 00724 00725 printf(" test22..."); 00726 Counter = 0; 00727 try { 00728 if (setjmp(JumpBuffer) == 0) { 00729 Counter += 1; 00730 00731 } else { 00732 Counter += 1; 00733 } 00734 00735 } finally { 00736 Counter += 1; 00737 if (Counter == 2) { 00738 Counter += 1; 00739 longjmp(JumpBuffer, 1); 00740 } 00741 } 00742 00743 if (Counter != 5) { 00744 printf("failed, count = %d\n", Counter); 00745 00746 } else { 00747 printf("succeeded\n"); 00748 } 00749 00750 // 00751 // A set jump followed by a try/except, followed by a try/finally where 00752 // the try body of the try/finally raises an exception that is handled 00753 // by the try/excecpt which causes the try/finally to do a long jump out 00754 // of a finally clause. This will create a collided unwind. 00755 // 00756 00757 printf(" test23..."); 00758 Counter = 0; 00759 if (setjmp(JumpBuffer) == 0) { 00760 try { 00761 try { 00762 Counter += 1; 00763 RtlRaiseStatus(STATUS_INTEGER_OVERFLOW); 00764 00765 } finally { 00766 Counter += 1; 00767 longjmp(JumpBuffer, 1); 00768 } 00769 00770 } except(EXCEPTION_EXECUTE_HANDLER) { 00771 Counter += 1; 00772 } 00773 00774 } else { 00775 Counter += 1; 00776 } 00777 00778 if (Counter != 3) { 00779 printf("failed, count = %d\n", Counter); 00780 00781 } else { 00782 printf("succeeded\n"); 00783 } 00784 00785 // 00786 // A set jump followed by a try/except, followed by a several nested 00787 // try/finally's where the inner try body of the try/finally raises an 00788 // exception that is handled by the try/except which causes the 00789 // try/finally to do a long jump out of a finally clause. This will 00790 // create a collided unwind. 00791 // 00792 00793 printf(" test24..."); 00794 Counter = 0; 00795 if (setjmp(JumpBuffer) == 0) { 00796 try { 00797 try { 00798 try { 00799 try { 00800 Counter += 1; 00801 RtlRaiseStatus(STATUS_INTEGER_OVERFLOW); 00802 00803 } finally { 00804 Counter += 1; 00805 } 00806 00807 } finally { 00808 Counter += 1; 00809 longjmp(JumpBuffer, 1); 00810 } 00811 00812 } finally { 00813 Counter += 1; 00814 } 00815 00816 } except(EXCEPTION_EXECUTE_HANDLER) { 00817 Counter += 1; 00818 } 00819 00820 } else { 00821 Counter += 1; 00822 } 00823 00824 if (Counter != 5) { 00825 printf("failed, count = %d\n", Counter); 00826 00827 } else { 00828 printf("succeeded\n"); 00829 } 00830 00831 // 00832 // A set jump followed by a try/except, followed by a try/finally which 00833 // calls a subroutine which contains a try finally that raises an 00834 // exception that is handled to the try/except. 00835 // 00836 00837 printf(" test25..."); 00838 Counter = 0; 00839 if (setjmp(JumpBuffer) == 0) { 00840 try { 00841 try { 00842 try { 00843 Counter += 1; 00844 dojump(JumpBuffer, &Counter); 00845 00846 } finally { 00847 Counter += 1; 00848 } 00849 00850 } finally { 00851 Counter += 1; 00852 } 00853 00854 } except(EXCEPTION_EXECUTE_HANDLER) { 00855 Counter += 1; 00856 } 00857 00858 } else { 00859 Counter += 1; 00860 } 00861 00862 if (Counter != 7) { 00863 printf("failed, count = %d\n", Counter); 00864 00865 } else { 00866 printf("succeeded\n"); 00867 } 00868 00869 // 00870 // A set jump followed by a try/except, followed by a try/finally which 00871 // calls a subroutine which contains a try finally that raises an 00872 // exception that is handled to the try/except. 00873 // 00874 00875 printf(" test26..."); 00876 Counter = 0; 00877 if (setjmp(JumpBuffer) == 0) { 00878 try { 00879 try { 00880 try { 00881 try { 00882 Counter += 1; 00883 dojump(JumpBuffer, &Counter); 00884 00885 } finally { 00886 Counter += 1; 00887 } 00888 00889 } finally { 00890 Counter += 1; 00891 longjmp(JumpBuffer, 1); 00892 } 00893 00894 } finally { 00895 Counter += 1; 00896 } 00897 00898 } except(EXCEPTION_EXECUTE_HANDLER) { 00899 Counter += 1; 00900 } 00901 00902 } else { 00903 Counter += 1; 00904 } 00905 00906 if (Counter != 8) { 00907 printf("failed, count = %d\n", Counter); 00908 00909 } else { 00910 printf("succeeded\n"); 00911 } 00912 00913 // 00914 // Test nested exceptions. 00915 // 00916 00917 printf(" test27..."); 00918 Counter = 0; 00919 try { 00920 try { 00921 Counter += 1; 00922 except1(&Counter); 00923 00924 } except(except2(GetExceptionInformation(), &Counter)) { 00925 Counter += 2; 00926 } 00927 00928 } except(EXCEPTION_EXECUTE_HANDLER) { 00929 Counter += 3; 00930 } 00931 00932 if (Counter != 55) { 00933 printf("failed, count = %d\n", Counter); 00934 00935 } else { 00936 printf("succeeded\n"); 00937 } 00938 00939 // 00940 // Simple try that causes an integer overflow exception. 00941 // 00942 00943 printf(" test28..."); 00944 Counter = 0; 00945 try { 00946 Counter += 1; 00947 addtwo(0x7fff0000, 0x10000, &Counter); 00948 00949 } except ((GetExceptionCode() == STATUS_INTEGER_OVERFLOW) ? 00950 EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { 00951 Counter += 1; 00952 } 00953 00954 if (Counter != 2) { 00955 printf("failed, count = %d\n", Counter); 00956 00957 } else { 00958 printf("succeeded\n"); 00959 } 00960 00961 // 00962 // Simple try that raises an misaligned data exception. 00963 // 00964 00965 #ifndef i386 00966 printf(" test29..."); 00967 Counter = 0; 00968 try { 00969 Counter += 1; 00970 foo2(BlackHole, (PLONG)BadByte); 00971 00972 } except ((GetExceptionCode() == STATUS_DATATYPE_MISALIGNMENT) ? 00973 EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { 00974 Counter += 1; 00975 } 00976 00977 if (Counter != 2) { 00978 printf("failed, count = %d\n", Counter); 00979 00980 } else { 00981 printf("succeeded\n"); 00982 } 00983 00984 #endif 00985 00986 // 00987 // Continue from a try body with an exception clause in a loop. 00988 // 00989 00990 printf(" test30..."); 00991 Counter = 0; 00992 for (Index1 = 0; Index1 < 10; Index1 += 1) { 00993 try { 00994 if ((Index1 & 0x1) == 0) { 00995 continue; 00996 00997 } else { 00998 Counter += 1; 00999 } 01000 01001 } except (EXCEPTION_EXECUTE_HANDLER) { 01002 Counter += 40; 01003 } 01004 01005 Counter += 2; 01006 } 01007 01008 if (Counter != 15) { 01009 printf("failed, count = %d\n", Counter); 01010 01011 } else { 01012 printf("succeeded\n"); 01013 } 01014 01015 // 01016 // Continue from a try body with an finally clause in a loop. 01017 // 01018 01019 printf(" test31..."); 01020 Counter = 0; 01021 for (Index1 = 0; Index1 < 10; Index1 += 1) { 01022 try { 01023 if ((Index1 & 0x1) == 0) { 01024 continue; 01025 01026 } else { 01027 Counter += 1; 01028 } 01029 01030 } finally { 01031 Counter += 2; 01032 } 01033 01034 Counter += 3; 01035 } 01036 01037 if (Counter != 40) { 01038 printf("failed, count = %d\n", Counter); 01039 01040 } else { 01041 printf("succeeded\n"); 01042 } 01043 01044 // 01045 // Continue from doubly nested try body with an exception clause in a 01046 // loop. 01047 // 01048 01049 printf(" test32..."); 01050 Counter = 0; 01051 for (Index1 = 0; Index1 < 10; Index1 += 1) { 01052 try { 01053 try { 01054 if ((Index1 & 0x1) == 0) { 01055 continue; 01056 01057 } else { 01058 Counter += 1; 01059 } 01060 01061 } except (EXCEPTION_EXECUTE_HANDLER) { 01062 Counter += 10; 01063 } 01064 01065 Counter += 2; 01066 01067 } except (EXCEPTION_EXECUTE_HANDLER) { 01068 Counter += 20; 01069 } 01070 01071 Counter += 3; 01072 } 01073 01074 if (Counter != 30) { 01075 printf("failed, count = %d\n", Counter); 01076 01077 } else { 01078 printf("succeeded\n"); 01079 } 01080 01081 // 01082 // Continue from doubly nested try body with an finally clause in a loop. 01083 // 01084 01085 printf(" test33..."); 01086 Counter = 0; 01087 for (Index1 = 0; Index1 < 10; Index1 += 1) { 01088 try { 01089 try { 01090 if ((Index1 & 0x1) == 0) { 01091 continue; 01092 01093 } else { 01094 Counter += 1; 01095 } 01096 01097 } finally { 01098 Counter += 2; 01099 } 01100 01101 Counter += 3; 01102 01103 } finally { 01104 Counter += 4; 01105 } 01106 01107 Counter += 5; 01108 } 01109 01110 if (Counter != 105) { 01111 printf("failed, count = %d\n", Counter); 01112 01113 } else { 01114 printf("succeeded\n"); 01115 } 01116 01117 // 01118 // Continue from a finally clause in a loop. 01119 // 01120 01121 printf(" test34..."); 01122 Counter = 0; 01123 for (Index1 = 0; Index1 < 10; Index1 += 1) { 01124 try { 01125 if ((Index1 & 0x1) == 0) { 01126 Counter += 1; 01127 } 01128 01129 } finally { 01130 Counter += 2; 01131 continue; 01132 } 01133 01134 Counter += 4; 01135 } 01136 01137 if (Counter != 25) { 01138 printf("failed, count = %d\n", Counter); 01139 01140 } else { 01141 printf("succeeded\n"); 01142 } 01143 01144 // 01145 // Continue from a doubly nested finally clause in a loop. 01146 // 01147 01148 printf(" test35..."); 01149 Counter = 0; 01150 for (Index1 = 0; Index1 < 10; Index1 += 1) { 01151 try { 01152 try { 01153 if ((Index1 & 0x1) == 0) { 01154 Counter += 1; 01155 } 01156 01157 } finally { 01158 Counter += 2; 01159 continue; 01160 } 01161 01162 Counter += 4; 01163 01164 } finally { 01165 Counter += 5; 01166 } 01167 01168 Counter += 6; 01169 } 01170 01171 if (Counter != 75) { 01172 printf("failed, count = %d\n", Counter); 01173 01174 } else { 01175 printf("succeeded\n"); 01176 } 01177 01178 // 01179 // Continue from a doubly nested finally clause in a loop. 01180 // 01181 01182 printf(" test36..."); 01183 Counter = 0; 01184 for (Index1 = 0; Index1 < 10; Index1 += 1) { 01185 try { 01186 try { 01187 if ((Index1 & 0x1) == 0) { 01188 Counter += 1; 01189 } 01190 01191 } finally { 01192 Counter += 2; 01193 } 01194 01195 Counter += 4; 01196 01197 } finally { 01198 Counter += 5; 01199 continue; 01200 } 01201 01202 Counter += 6; 01203 } 01204 01205 if (Counter != 115) { 01206 printf("failed, count = %d\n", Counter); 01207 01208 } else { 01209 printf("succeeded\n"); 01210 } 01211 01212 // 01213 // Break from a try body with an exception clause in a loop. 01214 // 01215 01216 printf(" test37..."); 01217 Counter = 0; 01218 for (Index1 = 0; Index1 < 10; Index1 += 1) { 01219 try { 01220 if ((Index1 & 0x1) == 1) { 01221 break; 01222 01223 } else { 01224 Counter += 1; 01225 } 01226 01227 } except (EXCEPTION_EXECUTE_HANDLER) { 01228 Counter += 40; 01229 } 01230 01231 Counter += 2; 01232 } 01233 01234 if (Counter != 3) { 01235 printf("failed, count = %d\n", Counter); 01236 01237 } else { 01238 printf("succeeded\n"); 01239 } 01240 01241 // 01242 // Break from a try body with an finally clause in a loop. 01243 // 01244 01245 printf(" test38..."); 01246 Counter = 0; 01247 for (Index1 = 0; Index1 < 10; Index1 += 1) { 01248 try { 01249 if ((Index1 & 0x1) == 1) { 01250 break; 01251 01252 } else { 01253 Counter += 1; 01254 } 01255 01256 } finally { 01257 Counter += 2; 01258 } 01259 01260 Counter += 3; 01261 } 01262 01263 if (Counter != 8) { 01264 printf("failed, count = %d\n", Counter); 01265 01266 } else { 01267 printf("succeeded\n"); 01268 } 01269 01270 // 01271 // Break from doubly nested try body with an exception clause in a 01272 // loop. 01273 // 01274 01275 printf(" test39..."); 01276 Counter = 0; 01277 for (Index1 = 0; Index1 < 10; Index1 += 1) { 01278 try { 01279 try { 01280 if ((Index1 & 0x1) == 1) { 01281 break; 01282 01283 } else { 01284 Counter += 1; 01285 } 01286 01287 } except (EXCEPTION_EXECUTE_HANDLER) { 01288 Counter += 10; 01289 } 01290 01291 Counter += 2; 01292 01293 } except (EXCEPTION_EXECUTE_HANDLER) { 01294 Counter += 20; 01295 } 01296 01297 Counter += 3; 01298 } 01299 01300 if (Counter != 6) { 01301 printf("failed, count = %d\n", Counter); 01302 01303 } else { 01304 printf("succeeded\n"); 01305 } 01306 01307 // 01308 // Break from doubly nested try body with an finally clause in a loop. 01309 // 01310 01311 printf(" test40..."); 01312 Counter = 0; 01313 for (Index1 = 0; Index1 < 10; Index1 += 1) { 01314 try { 01315 try { 01316 if ((Index1 & 0x1) == 1) { 01317 break; 01318 01319 } else { 01320 Counter += 1; 01321 } 01322 01323 } finally { 01324 Counter += 2; 01325 } 01326 01327 Counter += 3; 01328 01329 } finally { 01330 Counter += 4; 01331 } 01332 01333 Counter += 5; 01334 } 01335 01336 if (Counter != 21) { 01337 printf("failed, count = %d\n", Counter); 01338 01339 } else { 01340 printf("succeeded\n"); 01341 } 01342 01343 // 01344 // Break from a finally clause in a loop. 01345 // 01346 01347 printf(" test41..."); 01348 Counter = 0; 01349 for (Index1 = 0; Index1 < 10; Index1 += 1) { 01350 try { 01351 if ((Index1 & 0x1) == 1) { 01352 Counter += 1; 01353 } 01354 01355 } finally { 01356 Counter += 2; 01357 break; 01358 } 01359 01360 Counter += 4; 01361 } 01362 01363 if (Counter != 2) { 01364 printf("failed, count = %d\n", Counter); 01365 01366 } else { 01367 printf("succeeded\n"); 01368 } 01369 01370 // 01371 // Break from a doubly nested finally clause in a loop. 01372 // 01373 01374 printf(" test42..."); 01375 Counter = 0; 01376 for (Index1 = 0; Index1 < 10; Index1 += 1) { 01377 try { 01378 try { 01379 if ((Index1 & 0x1) == 1) { 01380 Counter += 1; 01381 } 01382 01383 } finally { 01384 Counter += 2; 01385 break; 01386 } 01387 01388 Counter += 4; 01389 01390 } finally { 01391 Counter += 5; 01392 } 01393 01394 Counter += 6; 01395 } 01396 01397 if (Counter != 7) { 01398 printf("failed, count = %d\n", Counter); 01399 01400 } else { 01401 printf("succeeded\n"); 01402 } 01403 01404 // 01405 // Break from a doubly nested finally clause in a loop. 01406 // 01407 01408 printf(" test43..."); 01409 Counter = 0; 01410 for (Index1 = 0; Index1 < 10; Index1 += 1) { 01411 try { 01412 try { 01413 if ((Index1 & 0x1) == 1) { 01414 Counter += 1; 01415 } 01416 01417 } finally { 01418 Counter += 2; 01419 } 01420 01421 Counter += 4; 01422 01423 } finally { 01424 Counter += 5; 01425 break; 01426 } 01427 01428 Counter += 6; 01429 } 01430 01431 if (Counter != 11) { 01432 printf("failed, count = %d\n", Counter); 01433 01434 } else { 01435 printf("succeeded\n"); 01436 } 01437 01438 // 01439 // Break from a try body with an exception clause in a switch. 01440 // 01441 01442 printf(" test44..."); 01443 Counter = 0; 01444 Index1 = 1; 01445 switch (Index2) { 01446 case BLUE: 01447 Counter += 100; 01448 break; 01449 01450 case RED: 01451 try { 01452 if ((Index1 & 0x1) == 1) { 01453 break; 01454 01455 } else { 01456 Counter += 1; 01457 } 01458 01459 } except (EXCEPTION_EXECUTE_HANDLER) { 01460 Counter += 40; 01461 } 01462 01463 Counter += 2; 01464 break; 01465 } 01466 01467 if (Counter != 0) { 01468 printf("failed, count = %d\n", Counter); 01469 01470 } else { 01471 printf("succeeded\n"); 01472 } 01473 01474 // 01475 // Break from a try body with an finally clause in a switch. 01476 // 01477 01478 printf(" test45..."); 01479 Counter = 0; 01480 Index1 = 1; 01481 switch (Index2) { 01482 case BLUE: 01483 Counter += 100; 01484 break; 01485 01486 case RED: 01487 try { 01488 if ((Index1 & 0x1) == 1) { 01489 break; 01490 01491 } else { 01492 Counter += 1; 01493 } 01494 01495 } finally { 01496 Counter += 2; 01497 } 01498 01499 Counter += 3; 01500 } 01501 01502 if (Counter != 2) { 01503 printf("failed, count = %d\n", Counter); 01504 01505 } else { 01506 printf("succeeded\n"); 01507 } 01508 01509 // 01510 // Break from doubly nested try body with an exception clause in a 01511 // switch. 01512 // 01513 01514 printf(" test46..."); 01515 Counter = 0; 01516 Index1 = 1; 01517 switch (Index2) { 01518 case BLUE: 01519 Counter += 100; 01520 break; 01521 01522 case RED: 01523 try { 01524 try { 01525 if ((Index1 & 0x1) == 1) { 01526 break; 01527 01528 } else { 01529 Counter += 1; 01530 } 01531 01532 } except (EXCEPTION_EXECUTE_HANDLER) { 01533 Counter += 10; 01534 } 01535 01536 Counter += 2; 01537 01538 } except (EXCEPTION_EXECUTE_HANDLER) { 01539 Counter += 20; 01540 } 01541 01542 Counter += 3; 01543 } 01544 01545 if (Counter != 0) { 01546 printf("failed, count = %d\n", Counter); 01547 01548 } else { 01549 printf("succeeded\n"); 01550 } 01551 01552 // 01553 // Break from doubly nested try body with an finally clause in a switch. 01554 // 01555 01556 printf(" test47..."); 01557 Counter = 0; 01558 Index1 = 1; 01559 switch (Index2) { 01560 case BLUE: 01561 Counter += 100; 01562 break; 01563 01564 case RED: 01565 try { 01566 try { 01567 if ((Index1 & 0x1) == 1) { 01568 break; 01569 01570 } else { 01571 Counter += 1; 01572 } 01573 01574 } finally { 01575 Counter += 2; 01576 } 01577 01578 Counter += 3; 01579 01580 } finally { 01581 Counter += 4; 01582 } 01583 01584 Counter += 5; 01585 } 01586 01587 if (Counter != 6) { 01588 printf("failed, count = %d\n", Counter); 01589 01590 } else { 01591 printf("succeeded\n"); 01592 } 01593 01594 // 01595 // Break from a finally clause in a switch. 01596 // 01597 01598 printf(" test48..."); 01599 Counter = 0; 01600 Index1 = 1; 01601 switch (Index2) { 01602 case BLUE: 01603 Counter += 100; 01604 break; 01605 01606 case RED: 01607 try { 01608 if ((Index1 & 0x1) == 1) { 01609 Counter += 1; 01610 } 01611 01612 } finally { 01613 Counter += 2; 01614 break; 01615 } 01616 01617 Counter += 4; 01618 } 01619 01620 if (Counter != 3) { 01621 printf("failed, count = %d\n", Counter); 01622 01623 } else { 01624 printf("succeeded\n"); 01625 } 01626 01627 // 01628 // Break from a doubly nested finally clause in a switch. 01629 // 01630 01631 printf(" test49..."); 01632 Counter = 0; 01633 Index1 = 1; 01634 switch (Index2) { 01635 case BLUE: 01636 Counter += 100; 01637 break; 01638 01639 case RED: 01640 try { 01641 try { 01642 if ((Index1 & 0x1) == 1) { 01643 Counter += 1; 01644 } 01645 01646 } finally { 01647 Counter += 2; 01648 break; 01649 } 01650 01651 Counter += 4; 01652 01653 } finally { 01654 Counter += 5; 01655 } 01656 01657 Counter += 6; 01658 } 01659 01660 if (Counter != 8) { 01661 printf("failed, count = %d\n", Counter); 01662 01663 } else { 01664 printf("succeeded\n"); 01665 } 01666 01667 // 01668 // Break from a doubly nested finally clause in a switch. 01669 // 01670 01671 printf(" test50..."); 01672 Counter = 0; 01673 Index1 = 1; 01674 switch (Index2) { 01675 case BLUE: 01676 Counter += 100; 01677 break; 01678 01679 case RED: 01680 try { 01681 try { 01682 if ((Index1 & 0x1) == 1) { 01683 Counter += 1; 01684 } 01685 01686 } finally { 01687 Counter += 2; 01688 } 01689 01690 Counter += 4; 01691 01692 } finally { 01693 Counter += 5; 01694 break; 01695 } 01696 01697 Counter += 6; 01698 } 01699 01700 if (Counter != 12) { 01701 printf("failed, count = %d\n", Counter); 01702 01703 } else { 01704 printf("succeeded\n"); 01705 } 01706 01707 // 01708 // Leave from an if in a simple try/finally. 01709 // 01710 01711 printf(" test51..."); 01712 Counter = 0; 01713 try { 01714 if (Echo(Counter) == Counter) { 01715 Counter += 3; 01716 leave; 01717 01718 } else { 01719 Counter += 100; 01720 } 01721 01722 } finally { 01723 if (abnormal_termination() == FALSE) { 01724 Counter += 5; 01725 } 01726 } 01727 01728 if (Counter != 8) { 01729 printf("failed, count = %d\n", Counter); 01730 01731 } else { 01732 printf("succeeded\n"); 01733 } 01734 01735 // 01736 // Leave from a loop in a simple try/finally. 01737 // 01738 01739 printf(" test52..."); 01740 Counter = 0; 01741 try { 01742 for (Index1 = 0; Index1 < 10; Index1 += 1) { 01743 if (Echo(Index1) == Index1) { 01744 Counter += 3; 01745 leave; 01746 } 01747 01748 Counter += 100; 01749 } 01750 01751 } finally { 01752 if (abnormal_termination() == FALSE) { 01753 Counter += 5; 01754 } 01755 } 01756 01757 if (Counter != 8) { 01758 printf("failed, count = %d\n", Counter); 01759 01760 } else { 01761 printf("succeeded\n"); 01762 } 01763 01764 // 01765 // Leave from a switch in a simple try/finally. 01766 // 01767 01768 printf(" test53..."); 01769 Counter = 0; 01770 try { 01771 switch (Index2) { 01772 case BLUE: 01773 break; 01774 01775 case RED: 01776 Counter += 3; 01777 leave; 01778 } 01779 01780 Counter += 100; 01781 01782 } finally { 01783 if (abnormal_termination() == FALSE) { 01784 Counter += 5; 01785 } 01786 } 01787 01788 if (Counter != 8) { 01789 printf("failed, count = %d\n", Counter); 01790 01791 } else { 01792 printf("succeeded\n"); 01793 } 01794 01795 // 01796 // Leave from an if in doubly nested try/finally followed by a leave 01797 // from an if in the outer try/finally. 01798 // 01799 01800 printf(" test54..."); 01801 Counter = 0; 01802 try { 01803 try { 01804 if (Echo(Counter) == Counter) { 01805 Counter += 3; 01806 leave; 01807 01808 } else { 01809 Counter += 100; 01810 } 01811 01812 } finally { 01813 if (abnormal_termination() == FALSE) { 01814 Counter += 5; 01815 } 01816 } 01817 01818 if (Echo(Counter) == Counter) { 01819 Counter += 3; 01820 leave; 01821 01822 } else { 01823 Counter += 100; 01824 } 01825 01826 01827 } finally { 01828 if (abnormal_termination() == FALSE) { 01829 Counter += 5; 01830 } 01831 } 01832 01833 if (Counter != 16) { 01834 printf("failed, count = %d\n", Counter); 01835 01836 } else { 01837 printf("succeeded\n"); 01838 } 01839 01840 // 01841 // Leave from an if in doubly nested try/finally followed by a leave 01842 // from the finally of the outer try/finally. 01843 // 01844 01845 printf(" test55..."); 01846 Counter = 0; 01847 try { 01848 try { 01849 if (Echo(Counter) == Counter) { 01850 Counter += 3; 01851 leave; 01852 01853 } else { 01854 Counter += 100; 01855 } 01856 01857 } finally { 01858 if (abnormal_termination() == FALSE) { 01859 Counter += 5; 01860 leave; 01861 } 01862 } 01863 01864 Counter += 100; 01865 01866 } finally { 01867 if (abnormal_termination() == FALSE) { 01868 Counter += 5; 01869 } 01870 } 01871 01872 if (Counter != 13) { 01873 printf("failed, count = %d\n", Counter); 01874 01875 } else { 01876 printf("succeeded\n"); 01877 } 01878 01879 // 01880 // Try/finally within the except clause of a try/except that is always 01881 // executed. 01882 // 01883 01884 printf(" test56..."); 01885 Counter = 0; 01886 try { 01887 Counter += 1; 01888 RtlRaiseStatus(STATUS_INTEGER_OVERFLOW); 01889 01890 } except (Counter) { 01891 try { 01892 Counter += 3; 01893 01894 } finally { 01895 if (abnormal_termination() == FALSE) { 01896 Counter += 5; 01897 } 01898 } 01899 } 01900 01901 if (Counter != 9) { 01902 printf("failed, count = %d\n", Counter); 01903 01904 } else { 01905 printf("succeeded\n"); 01906 } 01907 01908 // 01909 // Try/finally within the finally clause of a try/finally. 01910 // 01911 01912 printf(" test57..."); 01913 Counter = 0; 01914 try { 01915 Counter += 1; 01916 01917 } finally { 01918 if (abnormal_termination() == FALSE) { 01919 try { 01920 Counter += 3; 01921 01922 } finally { 01923 if (abnormal_termination() == FALSE) { 01924 Counter += 5; 01925 } 01926 } 01927 } 01928 } 01929 01930 if (Counter != 9) { 01931 printf("failed, count = %d\n", Counter); 01932 01933 } else { 01934 printf("succeeded\n"); 01935 } 01936 01937 // 01938 // Try/except within the finally clause of a try/finally. 01939 // 01940 /* 01941 printf(" test58..."); 01942 Counter = 0; 01943 try { 01944 Counter -= 1; 01945 01946 } finally { 01947 try { 01948 Counter += 2; 01949 RtlRaiseStatus(STATUS_INTEGER_OVERFLOW); 01950 01951 } except (Counter) { 01952 try { 01953 Counter += 3; 01954 01955 } finally { 01956 if (abnormal_termination() == FALSE) { 01957 Counter += 5; 01958 } 01959 } 01960 } 01961 } 01962 01963 if (Counter != 9) { 01964 printf("failed, count = %d\n", Counter); 01965 01966 } else { 01967 printf("succeeded\n"); 01968 } 01969 */ 01970 // 01971 // Try/except within the except clause of a try/except that is always 01972 // executed. 01973 // 01974 01975 printf(" test59..."); 01976 Counter = 0; 01977 try { 01978 Counter += 1; 01979 RtlRaiseStatus(STATUS_INTEGER_OVERFLOW); 01980 01981 } except (Counter) { 01982 try { 01983 Counter += 3; 01984 RtlRaiseStatus(STATUS_INTEGER_OVERFLOW); 01985 01986 } except(Counter - 3) { 01987 Counter += 5; 01988 } 01989 } 01990 01991 if (Counter != 9) { 01992 printf("failed, count = %d\n", Counter); 01993 01994 } else { 01995 printf("succeeded\n"); 01996 } 01997 01998 // 01999 // Try with a Try which exits the scope with a goto 02000 // 02001 02002 printf(" test60..."); 02003 Counter = 0; 02004 try { 02005 try { 02006 goto outside; 02007 02008 } except(1) { 02009 Counter += 1; 02010 } 02011 02012 outside: 02013 RtlRaiseStatus(STATUS_INTEGER_OVERFLOW); 02014 02015 } except(1) { 02016 Counter += 3; 02017 } 02018 02019 if (Counter != 3) { 02020 printf("failed, count = %d\n", Counter); 02021 } else { 02022 printf("succeeded\n"); 02023 } 02024 02025 // 02026 // Try/except which gets an exception from a subfunction within 02027 // a try/finally which has a try/except in the finally clause 02028 // 02029 02030 printf(" test61..."); 02031 Counter = 0; 02032 try { 02033 Test61Part2 (&Counter); 02034 } except (EXCEPTION_EXECUTE_HANDLER) { 02035 Counter += 11; 02036 } 02037 02038 if (Counter != 24) { 02039 printf("failed, count = %d\n", Counter); 02040 02041 } else { 02042 printf("succeeded\n"); 02043 } 02044 02045 // 02046 // Check for precision of floating point exception 02047 // 02048 02049 printf(" test62..."); 02050 02051 /* enable floating point overflow */ 02052 _controlfp(_controlfp(0,0) & ~EM_OVERFLOW, _MCW_EM); 02053 02054 Counter = 0; 02055 try { 02056 doubleresult = SquareDouble (1.7e300); 02057 02058 try { 02059 doubleresult = SquareDouble (1.0); 02060 02061 } except (1) { 02062 Counter += 3; 02063 } 02064 02065 } except (1) { 02066 Counter += 1; 02067 } 02068 02069 if (Counter != 1) { 02070 printf("failed, count = %d\n", Counter); 02071 02072 } else { 02073 printf("succeeded\n"); 02074 } 02075 02076 _clearfp (); 02077 02078 // 02079 // Callout for test #63 due to bogus compiler behaviour caused by test #62. 02080 // 02081 02082 PerformFpTest (); 02083 02084 // 02085 // Announce end of exception test. 02086 // 02087 02088 printf("End of exception test\n"); 02089 return; 02090 }

VOID PerformFpTest  ) 
 

Definition at line 2093 of file xcpt4.c.

References SquareDouble17E300().

Referenced by main().

02094 { 02095 LONG Counter; 02096 double doubleresult; 02097 02098 // 02099 // Check for precision of floating point exception in subfunction 02100 // 02101 02102 printf(" test63..."); 02103 02104 Counter = 0; 02105 try { 02106 SquareDouble17E300 ((PVOID) &doubleresult); 02107 02108 try { 02109 SquareDouble17E300 ((PVOID) &doubleresult); 02110 02111 } except (1) { 02112 Counter += 3; 02113 } 02114 02115 } except (1) { 02116 Counter += 1; 02117 } 02118 02119 if (Counter != 1) { 02120 printf("failed, count = %d\n", Counter); 02121 02122 } else { 02123 printf("succeeded\n"); 02124 } 02125 02126 _clearfp (); 02127 02128 }

VOID PerformFpTest VOID   ) 
 

double SquareDouble IN double  op  ) 
 

Definition at line 2384 of file xcpt4.c.

Referenced by main(), and SquareDouble17E300().

02387 { 02388 return op * op; 02389 }

VOID SquareDouble17E300 OUT PVOID  ans  ) 
 

Definition at line 2392 of file xcpt4.c.

References SquareDouble().

Referenced by PerformFpTest().

02395 { 02396 double ans; 02397 02398 ans = SquareDouble (1.7e300); 02399 *(double *) output = ans; 02400 }

VOID Test61Part2 IN OUT PULONG  Counter  ) 
 

Definition at line 2367 of file xcpt4.c.

References RtlRaiseStatus().

Referenced by main().

02370 { 02371 02372 try { 02373 *Counter -= 1; 02374 RtlRaiseStatus(STATUS_INTEGER_OVERFLOW); 02375 } finally { 02376 *Counter += 2; 02377 *Counter += 5; 02378 *Counter += 7; 02379 } 02380 }

BOOLEAN Tkm VOID   ) 
 


Generated on Sat May 15 19:46:11 2004 for test by doxygen 1.3.7