1 /* except.h -*-C++-*- 2 * 3 ************************************************************************* 4 * 5 * @copyright 6 * Copyright (C) 2009-2013, Intel Corporation 7 * All rights reserved. 8 * 9 * @copyright 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 14 * * Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * * Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in 18 * the documentation and/or other materials provided with the 19 * distribution. 20 * * Neither the name of Intel Corporation nor the names of its 21 * contributors may be used to endorse or promote products derived 22 * from this software without specific prior written permission. 23 * 24 * @copyright 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 29 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 30 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 31 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 32 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 33 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY 35 * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * POSSIBILITY OF SUCH DAMAGE. 37 **************************************************************************/ 38 39 /** 40 * @file except.h 41 * 42 * @brief Common definitions for the various implementations of exception 43 * handling. 44 */ 45 46 #ifndef INCLUDED_EXCEPT_DOT_H 47 #define INCLUDED_EXCEPT_DOT_H 48 49 #include <cilk/common.h> 50 #include <internal/abi.h> 51 #include "full_frame.h" 52 53 __CILKRTS_BEGIN_EXTERN_C 54 55 /** 56 * OS-dependent information about an exception that's being moved between 57 * strands. 58 */ 59 typedef struct pending_exception_info pending_exception_info; 60 61 /** 62 * Merge the right exception record into the left. The left is logically 63 * earlier. 64 * 65 * On entry the left state is synched and can not have an unresolved 66 * exception. The merge may result in an unresolved exception. 67 * 68 * If there is both a right and left exception, the right exception will 69 * be disposed of in preference to the left exception, destructing the 70 * exception object. 71 * 72 * @param w The worker that is preparing to resume execution. 73 * @param left_exception The exception that would have happened earlier 74 * if the code executed serially. Can be NULL if the left strand has not 75 * raised an exception. 76 * @param right_exception The exception that would have happened later 77 * if the code executed serially. Can be NULL if the right strand has not 78 * raised an exception. 79 * 80 * @return NULL if there both the right and left exception are NULL. This 81 * indicates that there are no pending exceptions. 82 * @return The pending exception that is to be raised to continue searching 83 * for a catch block to handle the exception. 84 */ 85 COMMON_SYSDEP 86 struct pending_exception_info *__cilkrts_merge_pending_exceptions( 87 __cilkrts_worker *w, 88 pending_exception_info *left_exception, 89 pending_exception_info *right_exception); 90 91 /** 92 * Move the exception information from the worker to the full_frame. 93 * 94 * @param w The worker which is suspending work on a full_frame. 95 * @param ff The full_frame which is being suspended. 96 */ 97 COMMON_SYSDEP 98 void __cilkrts_save_exception_state(__cilkrts_worker *w, 99 full_frame *ff); 100 101 /** 102 * Function to delete pending exception. This will delete the 103 * exception object and then free the stack/fiber. 104 * 105 * @param w The worker we're running on. 106 * @param pei The pending exception to be delete 107 * @param delete_object Unused. Should always be 1. 108 */ 109 void delete_exception_obj (__cilkrts_worker *w, 110 struct pending_exception_info *pei, 111 int delete_object); 112 113 #ifndef _WIN32 114 /* gcc-style exception handling */ 115 NON_COMMON NORETURN __cilkrts_c_sync_except(__cilkrts_worker *w, 116 __cilkrts_stack_frame *sf); 117 NON_COMMON void __attribute__((nonnull)) 118 __cilkrts_gcc_rethrow(__cilkrts_stack_frame *sf); 119 #endif 120 121 __CILKRTS_END_EXTERN_C 122 123 #endif // ! defined(INCLUDED_EXCEPT_DOT_H) 124