1 /*
2  *              ThreadX C++ Library Support
3  *
4  *      Copyright 1983-2019 Green Hills Software LLC.
5  *
6  *  This program is the property of Green Hills Software LLC.,
7  *  its contents are proprietary information and no part of it
8  *  is to be disclosed to anyone except employees of Green Hills
9  *  Software LLC., or as agreed in writing signed by the President
10  *  of Green Hills Software LLC.
11  */
12 #include "tx_ghs.h"
13 #define TX_DISABLE_ERROR_CHECKING
14 #include "tx_api.h"
15 
16 /*
17   C++ Exception Handling
18   ======================
19 
20   These routines allow C++ exceptions to be used in multiple threads.
21   The default implementation uses __ghs_GetThreadLocalStorageItem
22   to return a thread-specific __eh_globals pointer.
23 
24 */
25 
26 #if defined(__ghs) && (__GHS_VERSION_NUMBER >= 560)
27 #ifdef _WIN32
28 /* Windows uses a different linker, so include a stub routine, never called,
29    to pull in __cpp_exception_init and __cpp_exception_cleanup */
30 extern void __cpp_exception_init(void **);
31 extern void __cpp_exception_cleanup(void **);
__tx_win32_pull_in_exceptions(void)32 void __tx_win32_pull_in_exceptions(void) {
33     __cpp_exception_init(0);
34     __cpp_exception_cleanup(0);
35 }
36 #else
37 #pragma ghs reference __cpp_exception_init
38 #pragma ghs reference __cpp_exception_cleanup
39 #endif
40 
41 /* Must be called after __cpp_exception_init() is called to allocate
42  * and initialize the per-thread exception handling structure */
__get_eh_globals(void)43 void *__get_eh_globals(void)
44 {
45     return *(void **)__ghs_GetThreadLocalStorageItem(__ghs_TLS___eh_globals);
46 }
47 #endif
48