1 /*
2  *  Created by Phil on 21/08/2014
3  *  Copyright 2014 Two Blue Cubes Ltd. All rights reserved.
4  *
5  *  Distributed under the Boost Software License, Version 1.0. (See accompanying
6  *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7  *
8  */
9 #ifndef TWOBLUECUBES_CATCH_FATAL_CONDITION_H_INCLUDED
10 #define TWOBLUECUBES_CATCH_FATAL_CONDITION_H_INCLUDED
11 
12 #include "catch_platform.h"
13 #include "catch_compiler_capabilities.h"
14 #include "catch_windows_h_proxy.h"
15 
16 
17 #if defined( CATCH_CONFIG_WINDOWS_SEH )
18 
19 namespace Catch {
20 
21     struct FatalConditionHandler {
22 
23         static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo);
24         FatalConditionHandler();
25         static void reset();
26         ~FatalConditionHandler();
27 
28     private:
29         static bool isSet;
30         static ULONG guaranteeSize;
31         static PVOID exceptionHandlerHandle;
32     };
33 
34 } // namespace Catch
35 
36 #elif defined ( CATCH_CONFIG_POSIX_SIGNALS )
37 
38 #include <signal.h>
39 
40 namespace Catch {
41 
42     struct FatalConditionHandler {
43 
44         static bool isSet;
45         static struct sigaction oldSigActions[];
46         static stack_t oldSigStack;
47         static char altStackMem[];
48 
49         static void handleSignal( int sig );
50 
51         FatalConditionHandler();
52         ~FatalConditionHandler();
53         static void reset();
54     };
55 
56 } // namespace Catch
57 
58 
59 #else
60 
61 namespace Catch {
62     struct FatalConditionHandler {
63         void reset();
64     };
65 }
66 
67 #endif
68 
69 #endif // TWOBLUECUBES_CATCH_FATAL_CONDITION_H_INCLUDED
70