source: doc/theses/andrew_beach_MMath/code/throw-empty.cfa @ 55ad35c

ADTast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 55ad35c was ea593a3, checked in by Andrew Beach <ajbeach@…>, 3 years ago

First draft of all the exception benchmarks. There is an issue with the Cforall linking.

  • Property mode set to 100644
File size: 658 bytes
Line 
1// Throw Across Empty Function
2#include <exception.hfa>
3#include <stdlib.hfa>
4
5EHM_EXCEPTION(empty_exception)();
6
7EHM_VIRTUAL_TABLE(empty_exception, empty_vt);
8
9void unwind_empty(unsigned int frames) {
10        if (frames) {
11                unwind_empty(frames - 1);
12        } else {
13                throw (empty_exception){&empty_vt};
14        }
15}
16
17int main(int argc, char * argv[]) {
18        unsigned int times = 1;
19        unsigned int total_frames = 1;
20        if (2 < argc) {
21                times = strtol(argv[1], 0p, 10);
22        }
23        if (3 < argc) {
24                total_frames = strtol(argv[2], 0p, 10);
25        }
26
27        for (unsigned int count = 0 ; count < times ; ++count) {
28                try {
29                        unwind_empty(total_frames);
30                } catch (empty_exception *) {
31                        // ...
32                }
33        }
34}
Note: See TracBrowser for help on using the repository browser.