1 /* 2 * Copyright (c) 1996,1997 3 * Silicon Graphics Computer Systems, Inc. 4 * 5 * Copyright (c) 1999 6 * Boris Fomitchev 7 * 8 * This material is provided "as is", with absolutely no warranty expressed 9 * or implied. Any use is at your own risk. 10 * 11 * Permission to use or copy this software for any purpose is hereby granted 12 * without fee, provided the above notices are retained on all copies. 13 * Permission to modify the code and to distribute modified code is granted, 14 * provided the above notices are retained, and a notice that the code was 15 * modified is included with the above copyright notice. 16 */ 17 18 // The header <exception> contains low-level functions that interact 19 // with a compiler's exception-handling mechanism. It is assumed to 20 // be supplied with the compiler, rather than with the library, because 21 // it is inherently tied very closely to the compiler itself. 22 23 // On platforms where <exception> does not exist, this header defines 24 // an exception base class. This is *not* a substitute for everything 25 // in <exception>, but it suffices to support a bare minimum of STL 26 // functionality. 27 28 #ifndef _STLP_INTERNAL_EXCEPTION 29 #define _STLP_INTERNAL_EXCEPTION 30 31 #if !defined (_STLP_NO_EXCEPTION_HEADER) 32 33 # if defined ( _UNCAUGHT_EXCEPTION ) 34 # undef _STLP_NO_UNCAUGHT_EXCEPT_SUPPORT 35 # endif 36 37 # if defined (_STLP_BROKEN_EXCEPTION_CLASS) 38 # define exception _STLP_NULLIFIED_BROKEN_EXCEPTION_CLASS 39 # define bad_exception _STLP_NULLIFIED_BROKEN_BAD_EXCEPTION_CLASS 40 # if defined (_STLP_NO_NEW_NEW_HEADER) 41 # include _STLP_NATIVE_CPP_RUNTIME_HEADER(Exception.h) 42 # else 43 # include _STLP_NATIVE_CPP_RUNTIME_HEADER(Exception) 44 # endif 45 # undef exception 46 # undef bad_exception 47 # else 48 # if defined (_STLP_NO_NEW_NEW_HEADER) 49 # include _STLP_NATIVE_CPP_RUNTIME_HEADER(exception.h) 50 # else 51 # include _STLP_NATIVE_CPP_RUNTIME_HEADER(exception) 52 # endif 53 # endif 54 55 # if defined (_STLP_HAS_SPECIFIC_PROLOG_EPILOG) && (defined (_STLP_MSVC) || defined (__ICL)) 56 // dwa 02/04/00 - here I'm assuming that __ICL uses the same library headers as vc6. 57 // the header <yvals.h> which ships with vc6 and is included by its native <exception> 58 // actually turns on warnings, so we have to turn them back off. 59 # include <stl/config/_warnings_off.h> 60 # endif 61 62 # if defined (_STLP_USE_OWN_NAMESPACE) 63 64 _STLP_BEGIN_NAMESPACE 65 # if !defined (_STLP_BROKEN_EXCEPTION_CLASS) 66 # if !defined (_STLP_USING_PLATFORM_SDK_COMPILER) || !defined (_WIN64) 67 using _STLP_VENDOR_EXCEPT_STD::exception; 68 # else 69 using ::exception; 70 # endif 71 using _STLP_VENDOR_EXCEPT_STD::bad_exception; 72 # endif 73 74 # if !defined (_STLP_NO_USING_FOR_GLOBAL_FUNCTIONS) 75 // fbp : many platforms present strange mix of 76 // those in various namespaces 77 # if !defined (_STLP_VENDOR_UNEXPECTED_STD) 78 # define _STLP_VENDOR_UNEXPECTED_STD _STLP_VENDOR_EXCEPT_STD 79 # else 80 /* The following definitions are for backward compatibility as _STLP_VENDOR_TERMINATE_STD 81 * and _STLP_VENDOR_UNCAUGHT_EXCEPTION_STD has been introduce after _STLP_VENDOR_UNEXPECTED_STD 82 * and _STLP_VENDOR_UNEXPECTED_STD was the macro used in their place before that introduction. 83 */ 84 # if !defined (_STLP_VENDOR_TERMINATE_STD) 85 # define _STLP_VENDOR_TERMINATE_STD _STLP_VENDOR_UNEXPECTED_STD 86 # endif 87 # if !defined (_STLP_VENDOR_UNCAUGHT_EXCEPTION_STD) 88 # define _STLP_VENDOR_UNCAUGHT_EXCEPTION_STD _STLP_VENDOR_UNEXPECTED_STD 89 # endif 90 # endif 91 # if !defined (_STLP_VENDOR_TERMINATE_STD) 92 # define _STLP_VENDOR_TERMINATE_STD _STLP_VENDOR_EXCEPT_STD 93 # endif 94 # if !defined (_STLP_VENDOR_UNCAUGHT_EXCEPTION_STD) 95 # define _STLP_VENDOR_UNCAUGHT_EXCEPTION_STD _STLP_VENDOR_EXCEPT_STD 96 # endif 97 # if !defined (_STLP_VENDOR_TERMINATE_STD) 98 # define _STLP_VENDOR_TERMINATE_STD _STLP_VENDOR_EXCEPT_STD 99 # endif 100 # if !defined (_STLP_VENDOR_UNCAUGHT_EXCEPTION_STD) 101 # define _STLP_VENDOR_UNCAUGHT_EXCEPTION_STD _STLP_VENDOR_EXCEPT_STD 102 # endif 103 // weird errors 104 # if !defined (_STLP_NO_UNEXPECTED_EXCEPT_SUPPORT) 105 # if defined (__ICL) && (__ICL >= 900) && (_STLP_MSVC_LIB < 1300) 106 //See config/_intel.h for reason about this workaround 107 using std::unexpected; 108 # else 109 using _STLP_VENDOR_UNEXPECTED_STD::unexpected; 110 # endif 111 using _STLP_VENDOR_UNEXPECTED_STD::unexpected_handler; 112 using _STLP_VENDOR_UNEXPECTED_STD::set_unexpected; 113 # endif 114 using _STLP_VENDOR_TERMINATE_STD::terminate; 115 using _STLP_VENDOR_TERMINATE_STD::terminate_handler; 116 using _STLP_VENDOR_TERMINATE_STD::set_terminate; 117 118 # if !defined (_STLP_NO_UNCAUGHT_EXCEPT_SUPPORT) 119 using _STLP_VENDOR_UNCAUGHT_EXCEPTION_STD::uncaught_exception; 120 # endif 121 # endif /* !_STLP_NO_USING_FOR_GLOBAL_FUNCTIONS */ 122 _STLP_END_NAMESPACE 123 # endif /* _STLP_OWN_NAMESPACE */ 124 #else /* _STLP_NO_EXCEPTION_HEADER */ 125 126 /* fbp : absence of <exception> usually means that those 127 * functions are not going to be called by compiler. 128 * Still, define them for the user. 129 * dums: Policy modification, if the function do not behave like the Standard 130 * defined it we do not grant it in the STLport namespace. We will have 131 * compile time error rather than runtime error. 132 */ 133 #if 0 134 /* 135 typedef void (*unexpected_handler)(); 136 unexpected_handler set_unexpected(unexpected_handler f) _STLP_NOTHROW_INHERENTLY; 137 void unexpected(); 138 139 typedef void (*terminate_handler)(); 140 terminate_handler set_terminate(terminate_handler f) _STLP_NOTHROW_INHERENTLY; 141 void terminate(); 142 143 bool uncaught_exception(); // not implemented under mpw as of Jan/1999 144 */ 145 #endif 146 147 #endif /* _STLP_NO_EXCEPTION_HEADER */ 148 149 #if defined (_STLP_NO_EXCEPTION_HEADER) || defined (_STLP_BROKEN_EXCEPTION_CLASS) 150 _STLP_BEGIN_NAMESPACE 151 152 // section 18.6.1 153 class _STLP_CLASS_DECLSPEC exception { 154 public: 155 # ifndef _STLP_USE_NO_IOSTREAMS 156 exception() _STLP_NOTHROW; 157 virtual ~exception() _STLP_NOTHROW; 158 virtual const char* what() const _STLP_NOTHROW; 159 # else 160 exception() _STLP_NOTHROW {} 161 virtual ~exception() _STLP_NOTHROW {} 162 virtual const char* what() const _STLP_NOTHROW {return "class exception";} 163 # endif 164 }; 165 166 // section 18.6.2.1 167 class _STLP_CLASS_DECLSPEC bad_exception : public exception { 168 public: 169 # ifndef _STLP_USE_NO_IOSTREAMS 170 bad_exception() _STLP_NOTHROW; 171 ~bad_exception() _STLP_NOTHROW; 172 const char* what() const _STLP_NOTHROW; 173 # else 174 bad_exception() _STLP_NOTHROW {} 175 ~bad_exception() _STLP_NOTHROW {} 176 const char* what() const _STLP_NOTHROW {return "class bad_exception";} 177 # endif 178 }; 179 180 // forward declaration 181 class __Named_exception; 182 _STLP_END_NAMESPACE 183 #endif 184 185 #endif /* _STLP_INTERNAL_EXCEPTION */ 186