except.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. * @file except.h
  40. *
  41. * @brief Common definitions for the various implementations of exception
  42. * handling.
  43. */
  44. #ifndef INCLUDED_EXCEPT_DOT_H
  45. #define INCLUDED_EXCEPT_DOT_H
  46. #include <cilk/common.h>
  47. #include <internal/abi.h>
  48. #include "full_frame.h"
  49. __CILKRTS_BEGIN_EXTERN_C
  50. /**
  51. * OS-dependent information about an exception that's being moved between
  52. * strands.
  53. */
  54. typedef struct pending_exception_info pending_exception_info;
  55. /**
  56. * Merge the right exception record into the left. The left is logically
  57. * earlier.
  58. *
  59. * On entry the left state is synched and can not have an unresolved
  60. * exception. The merge may result in an unresolved exception.
  61. *
  62. * If there is both a right and left exception, the right exception will
  63. * be disposed of in preference to the left exception, destructing the
  64. * exception object.
  65. *
  66. * @param w The worker that is preparing to resume execution.
  67. * @param left_exception The exception that would have happened earlier
  68. * if the code executed serially. Can be NULL if the left strand has not
  69. * raised an exception.
  70. * @param right_exception The exception that would have happened later
  71. * if the code executed serially. Can be NULL if the right strand has not
  72. * raised an exception.
  73. *
  74. * @return NULL if there both the right and left exception are NULL. This
  75. * indicates that there are no pending exceptions.
  76. * @return The pending exception that is to be raised to continue searching
  77. * for a catch block to handle the exception.
  78. */
  79. COMMON_SYSDEP
  80. struct pending_exception_info *__cilkrts_merge_pending_exceptions(
  81. __cilkrts_worker *w,
  82. pending_exception_info *left_exception,
  83. pending_exception_info *right_exception);
  84. /**
  85. * Move the exception information from the worker to the full_frame.
  86. *
  87. * @param w The worker which is suspending work on a full_frame.
  88. * @param ff The full_frame which is being suspended.
  89. */
  90. COMMON_SYSDEP
  91. void __cilkrts_save_exception_state(__cilkrts_worker *w,
  92. full_frame *ff);
  93. /**
  94. * Function to delete pending exception. This will delete the
  95. * exception object and then free the stack/fiber.
  96. *
  97. * @param w The worker we're running on.
  98. * @param pei The pending exception to be delete
  99. * @param delete_object Unused. Should always be 1.
  100. */
  101. void delete_exception_obj (__cilkrts_worker *w,
  102. struct pending_exception_info *pei,
  103. int delete_object);
  104. #ifndef _WIN32
  105. /* gcc-style exception handling */
  106. NON_COMMON NORETURN __cilkrts_c_sync_except(__cilkrts_worker *w,
  107. __cilkrts_stack_frame *sf);
  108. NON_COMMON void __attribute__((nonnull))
  109. __cilkrts_gcc_rethrow(__cilkrts_stack_frame *sf);
  110. #endif
  111. __CILKRTS_END_EXTERN_C
  112. #endif // ! defined(INCLUDED_EXCEPT_DOT_H)