2 * Copyright (c) 1996,1997
3 * Silicon Graphics Computer Systems, Inc.
8 * This material is provided "as is", with absolutely no warranty expressed
9 * or implied. Any use is at your own risk.
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.
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.
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
28 #ifndef _STLP_INTERNAL_EXCEPTION
29 #define _STLP_INTERNAL_EXCEPTION
31 #if !defined (_STLP_NO_EXCEPTION_HEADER)
33 # if defined ( _UNCAUGHT_EXCEPTION )
34 # undef _STLP_NO_UNCAUGHT_EXCEPT_SUPPORT
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)
43 # include _STLP_NATIVE_CPP_RUNTIME_HEADER(Exception)
48 # if defined (_STLP_NO_NEW_NEW_HEADER)
49 # include _STLP_NATIVE_CPP_RUNTIME_HEADER(exception.h)
51 # include _STLP_NATIVE_CPP_RUNTIME_HEADER(exception)
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>
62 # if defined (_STLP_USE_OWN_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;
71 using _STLP_VENDOR_EXCEPT_STD::bad_exception;
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
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.
84 # if !defined (_STLP_VENDOR_TERMINATE_STD)
85 # define _STLP_VENDOR_TERMINATE_STD _STLP_VENDOR_UNEXPECTED_STD
87 # if !defined (_STLP_VENDOR_UNCAUGHT_EXCEPTION_STD)
88 # define _STLP_VENDOR_UNCAUGHT_EXCEPTION_STD _STLP_VENDOR_UNEXPECTED_STD
91 # if !defined (_STLP_VENDOR_TERMINATE_STD)
92 # define _STLP_VENDOR_TERMINATE_STD _STLP_VENDOR_EXCEPT_STD
94 # if !defined (_STLP_VENDOR_UNCAUGHT_EXCEPTION_STD)
95 # define _STLP_VENDOR_UNCAUGHT_EXCEPTION_STD _STLP_VENDOR_EXCEPT_STD
97 # if !defined (_STLP_VENDOR_TERMINATE_STD)
98 # define _STLP_VENDOR_TERMINATE_STD _STLP_VENDOR_EXCEPT_STD
100 # if !defined (_STLP_VENDOR_UNCAUGHT_EXCEPTION_STD)
101 # define _STLP_VENDOR_UNCAUGHT_EXCEPTION_STD _STLP_VENDOR_EXCEPT_STD
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;
109 using _STLP_VENDOR_UNEXPECTED_STD::unexpected;
111 using _STLP_VENDOR_UNEXPECTED_STD::unexpected_handler;
112 using _STLP_VENDOR_UNEXPECTED_STD::set_unexpected;
114 using _STLP_VENDOR_TERMINATE_STD::terminate;
115 using _STLP_VENDOR_TERMINATE_STD::terminate_handler;
116 using _STLP_VENDOR_TERMINATE_STD::set_terminate;
118 # if !defined (_STLP_NO_UNCAUGHT_EXCEPT_SUPPORT)
119 using _STLP_VENDOR_UNCAUGHT_EXCEPTION_STD::uncaught_exception;
121 # endif /* !_STLP_NO_USING_FOR_GLOBAL_FUNCTIONS */
123 # endif /* _STLP_OWN_NAMESPACE */
124 #else /* _STLP_NO_EXCEPTION_HEADER */
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.
135 typedef void (*unexpected_handler)();
136 unexpected_handler set_unexpected(unexpected_handler f) _STLP_NOTHROW_INHERENTLY;
139 typedef void (*terminate_handler)();
140 terminate_handler set_terminate(terminate_handler f) _STLP_NOTHROW_INHERENTLY;
143 bool uncaught_exception(); // not implemented under mpw as of Jan/1999
147 #endif /* _STLP_NO_EXCEPTION_HEADER */
149 #if defined (_STLP_NO_EXCEPTION_HEADER) || defined (_STLP_BROKEN_EXCEPTION_CLASS)
150 _STLP_BEGIN_NAMESPACE
153 class _STLP_CLASS_DECLSPEC exception {
155 # ifndef _STLP_USE_NO_IOSTREAMS
156 exception() _STLP_NOTHROW;
157 virtual ~exception() _STLP_NOTHROW;
158 virtual const char* what() const _STLP_NOTHROW;
160 exception() _STLP_NOTHROW {}
161 virtual ~exception() _STLP_NOTHROW {}
162 virtual const char* what() const _STLP_NOTHROW {return "class exception";}
167 class _STLP_CLASS_DECLSPEC bad_exception : public exception {
169 # ifndef _STLP_USE_NO_IOSTREAMS
170 bad_exception() _STLP_NOTHROW;
171 ~bad_exception() _STLP_NOTHROW;
172 const char* what() const _STLP_NOTHROW;
174 bad_exception() _STLP_NOTHROW {}
175 ~bad_exception() _STLP_NOTHROW {}
176 const char* what() const _STLP_NOTHROW {return "class bad_exception";}
180 // forward declaration
181 class __Named_exception;
185 #endif /* _STLP_INTERNAL_EXCEPTION */