source:
doc/theses/andrew_beach_MMath/code/resume-empty.cfa@
cb6b8cb
| Last change on this file since cb6b8cb was 54651005, checked in by , 4 years ago | |
|---|---|
|
|
| File size: 849 bytes | |
| Rev | Line | |
|---|---|---|
| [ea593a3] | 1 | // Resume Across Empty Function |
| [ee23a8d] | 2 | #include <clock.hfa> |
| [ea593a3] | 3 | #include <exception.hfa> |
| [ee23a8d] | 4 | #include <fstream.hfa> |
| [ea593a3] | 5 | #include <stdlib.hfa> |
| 6 | ||
| 7 | EHM_EXCEPTION(empty_exception)(); | |
| 8 | ||
| 9 | EHM_VIRTUAL_TABLE(empty_exception, empty_vt); | |
| 10 | ||
| 11 | void unwind_empty(unsigned int frames) { | |
| 12 | if (frames) { | |
| 13 | unwind_empty(frames - 1); | |
| 14 | } else { | |
| [d2278e9] | 15 | throwResume (empty_exception){&empty_vt}; |
| [ea593a3] | 16 | } |
| 17 | } | |
| 18 | ||
| 19 | int main(int argc, char * argv[]) { | |
| 20 | unsigned int times = 1; | |
| 21 | unsigned int total_frames = 1; | |
| [ee23a8d] | 22 | if (1 < argc) { |
| [ea593a3] | 23 | times = strtol(argv[1], 0p, 10); |
| 24 | } | |
| [ee23a8d] | 25 | if (2 < argc) { |
| [ea593a3] | 26 | total_frames = strtol(argv[2], 0p, 10); |
| 27 | } | |
| 28 | ||
| [ee23a8d] | 29 | Time start_time = timeHiRes(); |
| [ea593a3] | 30 | for (int count = 0 ; count < times ; ++count) { |
| 31 | try { | |
| 32 | unwind_empty(total_frames); | |
| [d2278e9] | 33 | } catchResume (empty_exception *) { |
| [54651005] | 34 | asm volatile ("# fixup block"); |
| [ea593a3] | 35 | } |
| 36 | } | |
| [ee23a8d] | 37 | Time end_time = timeHiRes(); |
| 38 | sout | "Run-Time (ns): " | (end_time - start_time)`ns; | |
| [ea593a3] | 39 | } |
Note:
See TracBrowser
for help on using the repository browser.