PR ada/81070
[official-gcc.git] / libcilkrts / runtime / except.h
blob6df7443e01a0eebd868cd1b67703b6e1fc6850ec
1 /* except.h -*-C++-*-
3 *************************************************************************
5 * Copyright (C) 2009-2016, Intel Corporation
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
29 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
30 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
32 * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
35 * *********************************************************************
37 * PLEASE NOTE: This file is a downstream copy of a file mainitained in
38 * a repository at cilkplus.org. Changes made to this file that are not
39 * submitted through the contribution process detailed at
40 * http://www.cilkplus.org/submit-cilk-contribution will be lost the next
41 * time that a new version is released. Changes only submitted to the
42 * GNU compiler collection or posted to the git repository at
43 * https://bitbucket.org/intelcilkruntime/intel-cilk-runtime.git are
44 * not tracked.
46 * We welcome your contributions to this open source project. Thank you
47 * for your assistance in helping us improve Cilk Plus.
48 **************************************************************************/
50 /**
51 * @file except.h
53 * @brief Common definitions for the various implementations of exception
54 * handling.
57 #ifndef INCLUDED_EXCEPT_DOT_H
58 #define INCLUDED_EXCEPT_DOT_H
60 #include <cilk/common.h>
61 #include <internal/abi.h>
62 #include "full_frame.h"
64 __CILKRTS_BEGIN_EXTERN_C
66 /**
67 * OS-dependent information about an exception that's being moved between
68 * strands.
70 typedef struct pending_exception_info pending_exception_info;
72 /**
73 * Merge the right exception record into the left. The left is logically
74 * earlier.
76 * On entry the left state is synched and can not have an unresolved
77 * exception. The merge may result in an unresolved exception.
79 * If there is both a right and left exception, the right exception will
80 * be disposed of in preference to the left exception, destructing the
81 * exception object.
83 * @param w The worker that is preparing to resume execution.
84 * @param left_exception The exception that would have happened earlier
85 * if the code executed serially. Can be NULL if the left strand has not
86 * raised an exception.
87 * @param right_exception The exception that would have happened later
88 * if the code executed serially. Can be NULL if the right strand has not
89 * raised an exception.
91 * @return NULL if there both the right and left exception are NULL. This
92 * indicates that there are no pending exceptions.
93 * @return The pending exception that is to be raised to continue searching
94 * for a catch block to handle the exception.
96 COMMON_SYSDEP
97 struct pending_exception_info *__cilkrts_merge_pending_exceptions(
98 __cilkrts_worker *w,
99 pending_exception_info *left_exception,
100 pending_exception_info *right_exception);
103 * Move the exception information from the worker to the full_frame.
105 * @param w The worker which is suspending work on a full_frame.
106 * @param ff The full_frame which is being suspended.
108 COMMON_SYSDEP
109 void __cilkrts_save_exception_state(__cilkrts_worker *w,
110 full_frame *ff);
113 * Function to delete pending exception. This will delete the
114 * exception object and then free the stack/fiber.
116 * @param w The worker we're running on.
117 * @param pei The pending exception to be delete
118 * @param delete_object Unused. Should always be 1.
120 void delete_exception_obj (__cilkrts_worker *w,
121 struct pending_exception_info *pei,
122 int delete_object);
124 #ifndef _WIN32
125 /* gcc-style exception handling */
126 NON_COMMON NORETURN __cilkrts_c_sync_except(__cilkrts_worker *w,
127 __cilkrts_stack_frame *sf);
128 NON_COMMON void __attribute__((nonnull))
129 __cilkrts_gcc_rethrow(__cilkrts_stack_frame *sf);
130 #endif
132 __CILKRTS_END_EXTERN_C
134 #endif // ! defined(INCLUDED_EXCEPT_DOT_H)