except-gcc.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /* except-gcc.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-gcc.h
  40. *
  41. * @brief ABI for gcc exception handling.
  42. *
  43. * @par Origin
  44. * The code below is generally copied from the Intel Itanium ABI (Intel
  45. * download 245370).
  46. */
  47. #ifndef INCLUDED_EXCEPT_GCC_DOT_H
  48. #define INCLUDED_EXCEPT_GCC_DOT_H
  49. #ifndef __cplusplus
  50. # error except-gcc.h should be used in C++ code only.
  51. #endif
  52. #include <cilk/common.h>
  53. #include <exception>
  54. #include <typeinfo>
  55. struct __cxa_exception;
  56. __CILKRTS_BEGIN_EXTERN_C
  57. /** Unwind reason code (Itanium ABI 6.1.2.1) */
  58. typedef enum _Unwind_Reason_Code {
  59. _URC_NO_REASON = 0,
  60. _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
  61. _URC_FATAL_PHASE2_ERROR = 2,
  62. _URC_FATAL_PHASE1_ERROR = 3,
  63. _URC_NORMAL_STOP = 4,
  64. _URC_END_OF_STACK = 5,
  65. _URC_HANDLER_FOUND = 6,
  66. _URC_INSTALL_CONTEXT = 7,
  67. _URC_CONTINUE_UNWIND = 8
  68. } _Unwind_Reason_Code;
  69. typedef struct _Unwind_Exception _Unwind_Exception;
  70. /** Exception cleanup function pointer (Itanium ABI 6.1.2.2) */
  71. typedef void (*_Unwind_Exception_Cleanup_Fn)(_Unwind_Reason_Code reason,
  72. _Unwind_Exception *exc);
  73. /**
  74. * @brief Exception undwinding information
  75. *
  76. * This is copied from the Intel Itanium ABI except that the
  77. * private fields are declared unsigned long for binary
  78. * compatibility with gcc/g++ on 32 bit machines.
  79. */
  80. struct _Unwind_Exception
  81. {
  82. uint64_t exception_class;
  83. _Unwind_Exception_Cleanup_Fn exception_cleanup;
  84. unsigned long private_1;
  85. unsigned long private_2;
  86. };
  87. /** Throw or rethrow an exception */
  88. _Unwind_Reason_Code
  89. _Unwind_RaiseException(_Unwind_Exception *exception_object);
  90. /** Resume an exception other than by rethrowing it. */
  91. void _Unwind_Resume(_Unwind_Exception *exception_object);
  92. /** Delete an exception object */
  93. void _Unwind_DeleteException(_Unwind_Exception *exception_object);
  94. /**
  95. * C++ exception ABI.
  96. * The following declarations are from
  97. *
  98. * http://www.codesourcery.com/public/cxx-abi/abi-eh.html#cxx-abi
  99. */
  100. struct __cxa_exception {
  101. std::type_info * exceptionType;
  102. void (*exceptionDestructor)(void *);
  103. std::unexpected_handler unexpectedHandler;
  104. std::terminate_handler terminateHandler;
  105. __cxa_exception * nextException;
  106. int handlerCount;
  107. int handlerSwitchValue;
  108. const char * actionRecord;
  109. const char * languageSpecificData;
  110. void * catchTemp;
  111. void * adjustedPtr;
  112. _Unwind_Exception unwindHeader;
  113. };
  114. static inline __cxa_exception *to_cxx(_Unwind_Exception *e)
  115. {
  116. return ((__cxa_exception *)(e+1)) - 1;
  117. }
  118. typedef struct __cxa_eh_globals {
  119. __cxa_exception *caughtExceptions;
  120. unsigned int uncaughtExceptions;
  121. } __cxa_eh_globals;
  122. __cxa_eh_globals*__cxa_get_globals(void) throw();
  123. __CILKRTS_END_EXTERN_C
  124. #endif // ! defined(INCLUDED_EXCEPT_GCC_DOT_H)