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