ReactOS 0.4.15-dev-7942-gd23573b
recursive_throw.cpp
Go to the documentation of this file.
1// Copyright (c) Microsoft. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for
3// full license information.
4
5#include <stdio.h>
6#include <windows.h>
7#ifdef _M_CEE
8#define MAX_REC 200
9#else
10#define MAX_REC 200
11#endif
12
13#define NLOOPS 10
14
15#if defined(_M_SH) || defined(TRISC)
16#undef MAX_REC
17#define MAX_REC 3
18#endif
19
20#if defined(_M_AMD64)
21#undef MAX_REC
22#define MAX_REC 50
23#endif
24
25void foo(int level)
26{
27 if(level < MAX_REC)
28 {
29 try
30 {
31 foo(level+1);
32 }
33 catch(int& throw_level)
34 {
35 //printf("Level %d catched level %d\n",level,throw_level);
36 throw_level = level;
37 //printf("Level %d throwing\n",level);
38 throw level;
39 }
40 }
41 else
42 {
43 printf("Level MAX_REC throwing.\n");
44 throw level;
45 }
46}
47
48int main(void)
49{
50 int n;
52
53#if !defined(_M_AMD64) && !defined(_M_ARM) && !defined(_M_ARM64)
56#endif
57
58 //printf("Max Recursion level: %d\n", MAX_REC);
59 printf("N loops: %d\n", NLOOPS);
60
61 for(n=0;n<NLOOPS;n++)
62 {
63 try
64 {
65 foo(0);
66 }
67 catch(int& throw_level)
68 {
69 printf("main catched level %d\n",throw_level);
70 }
71 }
72#if !defined(_M_AMD64) && !defined(_M_ARM) && !defined(_M_ARM64)
74#endif
75
76 //printf("Exceptions per sec %lf\n",(double)(NLOOPS*MAX_REC)/((double)(end.QuadPart-start.QuadPart)/(double)freq.QuadPart));
77}
BOOL WINAPI QueryPerformanceFrequency(OUT PLARGE_INTEGER lpFrequency)
Definition: perfcnt.c:45
BOOL WINAPI QueryPerformanceCounter(OUT PLARGE_INTEGER lpPerformanceCount)
Definition: perfcnt.c:23
#define printf
Definition: freeldr.h:97
GLuint start
Definition: gl.h:1545
GLint level
Definition: gl.h:1546
GLuint GLuint end
Definition: gl.h:1545
GLdouble n
Definition: glext.h:7729
#define MAX_REC
int main(void)
#define NLOOPS