source:
doc/theses/andrew_beach_MMath/code/cross-catch.cfa
@
98233b3
Last change on this file since 98233b3 was 866cad3, checked in by , 3 years ago | |
---|---|
|
|
File size: 757 bytes |
Rev | Line | |
---|---|---|
[ea593a3] | 1 | // Cross a Try Statement with a Termination Handler |
[ee23a8d] | 2 | #include <clock.hfa> |
[ea593a3] | 3 | #include <exception.hfa> |
[ee23a8d] | 4 | #include <fstream.hfa> |
[ea593a3] | 5 | #include <stdlib.hfa> |
6 | ||
7 | EHM_EXCEPTION(not_raised_exception)(); | |
8 | ||
[54651005] | 9 | EHM_VIRTUAL_TABLE(not_raised_exception, not_vt); |
10 | ||
[ea593a3] | 11 | int main(int argc, char * argv[]) { |
12 | unsigned int times = 1; | |
[866cad3] | 13 | volatile bool should_throw = false; |
[ee23a8d] | 14 | if (1 < argc) { |
[ea593a3] | 15 | times = strtol(argv[1], 0p, 10); |
16 | } | |
17 | ||
[47e413b] | 18 | Time start_time = timeHiRes(); |
[ea593a3] | 19 | for (unsigned int count = 0 ; count < times ; ++count) { |
20 | try { | |
[866cad3] | 21 | asm volatile ("# try block"); |
[54651005] | 22 | if (should_throw) { |
23 | throw (not_raised_exception){¬_vt}; | |
24 | } | |
[ea593a3] | 25 | } catch (not_raised_exception *) { |
[54651005] | 26 | asm volatile ("# catch block"); |
[ea593a3] | 27 | } |
28 | } | |
[47e413b] | 29 | Time end_time = timeHiRes(); |
[ee23a8d] | 30 | sout | "Run-Time (ns): " | (end_time - start_time)`ns; |
[ea593a3] | 31 | } |
Note: See TracBrowser
for help on using the repository browser.