~ubuntu-branches/ubuntu/vivid/emscripten/vivid-proposed

« back to all changes in this revision

Viewing changes to system/lib/libcxx/exception.cpp

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2014-01-19 14:12:40 UTC
  • mfrom: (4.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20140119141240-nfiw0p8033oitpfz
Tags: 1.9.0~20140119~7dc8c2f-1
* New snapshot release (Closes: #733714)
* Provide sources for javascript and flash. Done in orig-tar.sh
  Available in third_party/websockify/include/web-socket-js/src/
  (Closes: #735903)

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
#include <stdio.h>
11
11
 
12
12
#include "exception"
 
13
#include "new"
13
14
 
14
15
#ifndef __has_include
15
16
#define __has_include(inc) 0
23
24
  #ifndef _LIBCPPABI_VERSION
24
25
    using namespace __cxxabiapple;
25
26
    // On Darwin, there are two STL shared libraries and a lower level ABI
26
 
    // shared libray.  The globals holding the current terminate handler and
 
27
    // shared library.  The globals holding the current terminate handler and
27
28
    // current unexpected handler are in the ABI library.
28
29
    #define __terminate_handler  __cxxabiapple::__cxa_terminate_handler
29
30
    #define __unexpected_handler __cxxabiapple::__cxa_unexpected_handler
90
91
        (*get_terminate())();
91
92
        // handler should not return
92
93
        printf("terminate_handler unexpectedly returned\n");
93
 
        ::abort ();
 
94
        ::abort();
94
95
#ifndef _LIBCPP_NO_EXCEPTIONS
95
96
    }
96
97
    catch (...)
97
98
    {
98
99
        // handler should not throw exception
99
100
        printf("terminate_handler unexpectedly threw an exception\n");
100
 
        ::abort ();
 
101
        ::abort();
101
102
    }
102
103
#endif  // _LIBCPP_NO_EXCEPTIONS
103
104
}
111
112
    // on Darwin, there is a helper function so __cxa_get_globals is private
112
113
    return __cxa_uncaught_exception();
113
114
#else  // __APPLE__
114
 
    #warning uncaught_exception not yet implemented
 
115
#   if defined(_MSC_VER) && ! defined(__clang__)
 
116
        _LIBCPP_WARNING("uncaught_exception not yet implemented")
 
117
#   else
 
118
#       warning uncaught_exception not yet implemented
 
119
#   endif
115
120
    printf("uncaught_exception not yet implemented\n");
116
121
    ::abort();
117
122
#endif  // __APPLE__
118
123
}
119
124
 
 
125
 
120
126
#ifndef _LIBCPPABI_VERSION
121
127
 
122
128
exception::~exception() _NOEXCEPT
143
149
 
144
150
#endif
145
151
 
 
152
#if defined(__GLIBCXX__)
 
153
 
 
154
// libsupc++ does not implement the dependent EH ABI and the functionality
 
155
// it uses to implement std::exception_ptr (which it declares as an alias of
 
156
// std::__exception_ptr::exception_ptr) is not directly exported to clients. So
 
157
// we have little choice but to hijack std::__exception_ptr::exception_ptr's
 
158
// (which fortunately has the same layout as our std::exception_ptr) copy
 
159
// constructor, assignment operator and destructor (which are part of its
 
160
// stable ABI), and its rethrow_exception(std::__exception_ptr::exception_ptr)
 
161
// function.
 
162
 
 
163
namespace __exception_ptr
 
164
{
 
165
 
 
166
struct exception_ptr
 
167
{
 
168
    void* __ptr_;
 
169
 
 
170
    exception_ptr(const exception_ptr&) _NOEXCEPT;
 
171
    exception_ptr& operator=(const exception_ptr&) _NOEXCEPT;
 
172
    ~exception_ptr() _NOEXCEPT;
 
173
};
 
174
 
 
175
}
 
176
 
 
177
_LIBCPP_NORETURN void rethrow_exception(__exception_ptr::exception_ptr);
 
178
 
 
179
#endif
146
180
 
147
181
exception_ptr::~exception_ptr() _NOEXCEPT
148
182
{
149
183
#if HAVE_DEPENDENT_EH_ABI
150
184
    __cxa_decrement_exception_refcount(__ptr_);
 
185
#elif defined(__GLIBCXX__)
 
186
    reinterpret_cast<__exception_ptr::exception_ptr*>(this)->~exception_ptr();
151
187
#else
152
 
    #warning exception_ptr not yet implemented
 
188
#   if defined(_MSC_VER) && ! defined(__clang__)
 
189
        _LIBCPP_WARNING("exception_ptr not yet implemented")
 
190
#   else
 
191
#       warning exception_ptr not yet implemented
 
192
#   endif
153
193
    printf("exception_ptr not yet implemented\n");
154
194
    ::abort();
155
 
#endif  // __APPLE__
 
195
#endif
156
196
}
157
197
 
158
198
exception_ptr::exception_ptr(const exception_ptr& other) _NOEXCEPT
160
200
{
161
201
#if HAVE_DEPENDENT_EH_ABI
162
202
    __cxa_increment_exception_refcount(__ptr_);
 
203
#elif defined(__GLIBCXX__)
 
204
    new (reinterpret_cast<void*>(this)) __exception_ptr::exception_ptr(
 
205
        reinterpret_cast<const __exception_ptr::exception_ptr&>(other));
163
206
#else
164
 
    #warning exception_ptr not yet implemented
 
207
#   if defined(_MSC_VER) && ! defined(__clang__)
 
208
        _LIBCPP_WARNING("exception_ptr not yet implemented")
 
209
#   else
 
210
#       warning exception_ptr not yet implemented
 
211
#   endif
165
212
    printf("exception_ptr not yet implemented\n");
166
213
    ::abort();
167
 
#endif  // __APPLE__
 
214
#endif
168
215
}
169
216
 
170
217
exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT
177
224
        __ptr_ = other.__ptr_;
178
225
    }
179
226
    return *this;
180
 
#else  // __APPLE__
181
 
    #warning exception_ptr not yet implemented
 
227
#elif defined(__GLIBCXX__)
 
228
    *reinterpret_cast<__exception_ptr::exception_ptr*>(this) =
 
229
        reinterpret_cast<const __exception_ptr::exception_ptr&>(other);
 
230
    return *this;
 
231
#else
 
232
#   if defined(_MSC_VER) && ! defined(__clang__)
 
233
        _LIBCPP_WARNING("exception_ptr not yet implemented")
 
234
#   else
 
235
#       warning exception_ptr not yet implemented
 
236
#   endif
182
237
    printf("exception_ptr not yet implemented\n");
183
238
    ::abort();
184
 
#endif  // __APPLE__
 
239
#endif
185
240
}
186
241
 
187
242
nested_exception::nested_exception() _NOEXCEPT
189
244
{
190
245
}
191
246
 
 
247
#if !defined(__GLIBCXX__)
 
248
 
192
249
nested_exception::~nested_exception() _NOEXCEPT
193
250
{
194
251
}
195
252
 
 
253
#endif
 
254
 
196
255
_LIBCPP_NORETURN
197
256
void
198
257
nested_exception::rethrow_nested() const
202
261
    rethrow_exception(__ptr_);
203
262
}
204
263
 
 
264
#if !defined(__GLIBCXX__)
205
265
 
206
266
exception_ptr current_exception() _NOEXCEPT
207
267
{
212
272
    exception_ptr ptr;
213
273
    ptr.__ptr_ = __cxa_current_primary_exception();
214
274
    return ptr;
215
 
#else  // __APPLE__
216
 
    #warning exception_ptr not yet implemented
 
275
#else
 
276
#   if defined(_MSC_VER) && ! defined(__clang__)
 
277
        _LIBCPP_WARNING( "exception_ptr not yet implemented" )
 
278
#   else
 
279
#       warning exception_ptr not yet implemented
 
280
#   endif
217
281
    printf("exception_ptr not yet implemented\n");
218
282
    ::abort();
219
 
#endif  // __APPLE__
 
283
#endif
220
284
}
221
285
 
 
286
#endif  // !__GLIBCXX__
 
287
 
222
288
_LIBCPP_NORETURN
223
289
void rethrow_exception(exception_ptr p)
224
290
{
226
292
    __cxa_rethrow_primary_exception(p.__ptr_);
227
293
    // if p.__ptr_ is NULL, above returns so we terminate
228
294
    terminate();
229
 
#else  // __APPLE__
230
 
    #warning exception_ptr not yet implemented
 
295
#elif defined(__GLIBCXX__)
 
296
    rethrow_exception(reinterpret_cast<__exception_ptr::exception_ptr&>(p));
 
297
#else
 
298
#   if defined(_MSC_VER) && ! defined(__clang__)
 
299
        _LIBCPP_WARNING("exception_ptr not yet implemented")
 
300
#   else
 
301
#       warning exception_ptr not yet implemented
 
302
#   endif
231
303
    printf("exception_ptr not yet implemented\n");
232
304
    ::abort();
233
 
#endif  // __APPLE__
 
305
#endif
234
306
}
235
307
} // std