aboutsummaryrefslogtreecommitdiff
path: root/libcilkrts/runtime/except.h
blob: 58e2238c5815256bcd18e9f7d5dd57c93c49100d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/* except.h                  -*-C++-*-
 *
 *************************************************************************
 *
 *  @copyright
 *  Copyright (C) 2009-2013, Intel Corporation
 *  All rights reserved.
 *  
 *  @copyright
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions
 *  are met:
 *  
 *    * Redistributions of source code must retain the above copyright
 *      notice, this list of conditions and the following disclaimer.
 *    * Redistributions in binary form must reproduce the above copyright
 *      notice, this list of conditions and the following disclaimer in
 *      the documentation and/or other materials provided with the
 *      distribution.
 *    * Neither the name of Intel Corporation nor the names of its
 *      contributors may be used to endorse or promote products derived
 *      from this software without specific prior written permission.
 *  
 *  @copyright
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 *  HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 *  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 *  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
 *  WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 *  POSSIBILITY OF SUCH DAMAGE.
 **************************************************************************/

/**
 * @file except.h
 *
 * @brief Common definitions for the various implementations of exception
 * handling.
 */

#ifndef INCLUDED_EXCEPT_DOT_H
#define INCLUDED_EXCEPT_DOT_H

#include <cilk/common.h>
#include <internal/abi.h>
#include "full_frame.h"

__CILKRTS_BEGIN_EXTERN_C

/**
 * OS-dependent information about an exception that's being moved between
 * strands.
 */
typedef struct pending_exception_info pending_exception_info;

/**
 * Merge the right exception record into the left.  The left is logically
 * earlier.
 *
 * On entry the left state is synched and can not have an unresolved
 * exception.  The merge may result in an unresolved exception.
 *
 * If there is both a right and left exception, the right exception will
 * be disposed of in preference to the left exception, destructing the
 * exception object.
 *
 * @param w The worker that is preparing to resume execution.
 * @param left_exception The exception that would have happened earlier
 * if the code executed serially.  Can be NULL if the left strand has not
 * raised an exception.
 * @param right_exception The exception that would have happened later
 * if the code executed serially.  Can be NULL if the right strand has not
 * raised an exception.
 *
 * @return NULL if there both the right and left exception are NULL. This
 * indicates that there are no pending exceptions.
 * @return The pending exception that is to be raised to continue searching
 * for a catch block to handle the exception.
 */
COMMON_SYSDEP
struct pending_exception_info *__cilkrts_merge_pending_exceptions(
    __cilkrts_worker *w,
    pending_exception_info *left_exception,
    pending_exception_info *right_exception);

/**
 * Move the exception information from the worker to the full_frame.
 *
 * @param w The worker which is suspending work on a full_frame.
 * @param ff The full_frame which is being suspended.
 */
COMMON_SYSDEP
void __cilkrts_save_exception_state(__cilkrts_worker *w,
                                    full_frame *ff);

/**
 * Function to delete pending exception.  This will delete the
 * exception object and then free the stack/fiber.
 *
 * @param w The worker we're running on.
 * @param pei The pending exception to be delete
 * @param delete_object Unused.  Should always be 1.
 */
void delete_exception_obj (__cilkrts_worker *w,
                           struct pending_exception_info *pei,
                           int delete_object);

#ifndef _WIN32
/* gcc-style exception handling */
NON_COMMON NORETURN __cilkrts_c_sync_except(__cilkrts_worker *w,
                                            __cilkrts_stack_frame *sf);
NON_COMMON void __attribute__((nonnull))
__cilkrts_gcc_rethrow(__cilkrts_stack_frame *sf);
#endif

__CILKRTS_END_EXTERN_C

#endif // ! defined(INCLUDED_EXCEPT_DOT_H)