Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / native_client / pnacl / support / bitcode / sjlj_eh_redirect.cc
1 /*
2  * Copyright (c) 2013 The Native Client Authors. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the LICENSE file.
5  */
6
7 /*
8  * This file defines _Unwind_RaiseException() etc. using the SJLJ
9  * (setjmp()/longjmp()-based) versions provided by PNaCl's libstdc++.
10  *
11  * This allows a single build of libstdc++ to support both the SJLJ
12  * and non-SJLJ models of C++ exception handling.  The SJLJ version is
13  * enabled by linking in this redirection file.
14  */
15
16 #include <stdlib.h>
17
18
19 extern "C" {
20
21 struct _Unwind_Exception;
22
23 int __pnacl_eh_sjlj_Unwind_RaiseException(struct _Unwind_Exception *exc);
24 int __pnacl_eh_sjlj_Unwind_Resume_or_Rethrow(struct _Unwind_Exception *exc);
25 void __pnacl_eh_sjlj_Unwind_DeleteException(struct _Unwind_Exception *exc);
26 void __pnacl_eh_sjlj_cxa_call_unexpected(struct _Unwind_Exception *exc);
27
28
29 int _Unwind_RaiseException(struct _Unwind_Exception *exc) {
30   return __pnacl_eh_sjlj_Unwind_RaiseException(exc);
31 }
32
33 int _Unwind_Resume_or_Rethrow(struct _Unwind_Exception *exc) {
34   return __pnacl_eh_sjlj_Unwind_Resume_or_Rethrow(exc);
35 }
36
37 void _Unwind_DeleteException(struct _Unwind_Exception *exc) {
38   __pnacl_eh_sjlj_Unwind_DeleteException(exc);
39 }
40
41 void __cxa_call_unexpected(struct _Unwind_Exception *exc) {
42   __pnacl_eh_sjlj_cxa_call_unexpected(exc);
43 }
44
45 /*
46  * This is a dummy version of the C++ personality function to prevent
47  * libstdc++'s eh_personality.cc from being linked in, since that file
48  * also defines __cxa_call_unexpected(), which would clash with our
49  * definition above.
50  *
51  * The only references to this personality function will be from LLVM
52  * "landingpad" instructions, which will be removed by the PNaClSjLjEH
53  * pass.
54  */
55 void __gxx_personality_v0() {
56   abort();
57 }
58
59 }