xref: /netbsd-src/external/bsd/libc++/dist/libcxxrt/src/auxhelper.cc (revision fec583f48bb2b0329630246c25e9635fec7c3f97)
1ccec91a1Sjoerg /*
2ccec91a1Sjoerg  * Copyright 2010-2011 PathScale, Inc. All rights reserved.
3ccec91a1Sjoerg  *
4ccec91a1Sjoerg  * Redistribution and use in source and binary forms, with or without
5ccec91a1Sjoerg  * modification, are permitted provided that the following conditions are met:
6ccec91a1Sjoerg  *
7ccec91a1Sjoerg  * 1. Redistributions of source code must retain the above copyright notice,
8ccec91a1Sjoerg  *    this list of conditions and the following disclaimer.
9ccec91a1Sjoerg  *
10ccec91a1Sjoerg  * 2. Redistributions in binary form must reproduce the above copyright notice,
11ccec91a1Sjoerg  *    this list of conditions and the following disclaimer in the documentation
12ccec91a1Sjoerg  *    and/or other materials provided with the distribution.
13ccec91a1Sjoerg  *
14ccec91a1Sjoerg  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
15ccec91a1Sjoerg  * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16ccec91a1Sjoerg  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17ccec91a1Sjoerg  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
18ccec91a1Sjoerg  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19ccec91a1Sjoerg  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20ccec91a1Sjoerg  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21ccec91a1Sjoerg  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22ccec91a1Sjoerg  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23ccec91a1Sjoerg  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24ccec91a1Sjoerg  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25ccec91a1Sjoerg  */
26ccec91a1Sjoerg 
27ccec91a1Sjoerg /**
28ccec91a1Sjoerg  * aux.cc - Compiler helper functions.
29ccec91a1Sjoerg  *
30ccec91a1Sjoerg  * The functions declared in this file are intended to be called only by code
31ccec91a1Sjoerg  * that is automatically generated by C++ compilers for some common cases.
32ccec91a1Sjoerg  */
33ccec91a1Sjoerg 
34ccec91a1Sjoerg #include <stdlib.h>
35ccec91a1Sjoerg #include "stdexcept.h"
36ccec91a1Sjoerg 
37ccec91a1Sjoerg /**
38ccec91a1Sjoerg  * Called to generate a bad cast exception.  This function is intended to allow
39ccec91a1Sjoerg  * compilers to insert code generating this exception without needing to
40ccec91a1Sjoerg  * duplicate the code for throwing the exception in every call site.
41ccec91a1Sjoerg  */
__cxa_bad_cast()42ccec91a1Sjoerg extern "C" void __cxa_bad_cast()
43ccec91a1Sjoerg {
44ccec91a1Sjoerg     throw std::bad_cast();
45ccec91a1Sjoerg }
46ccec91a1Sjoerg 
47ccec91a1Sjoerg /**
48ccec91a1Sjoerg  * Called to generate a bad typeid exception.  This function is intended to
49ccec91a1Sjoerg  * allow compilers to insert code generating this exception without needing to
50ccec91a1Sjoerg  * duplicate the code for throwing the exception in every call site.
51ccec91a1Sjoerg  */
__cxa_bad_typeid()52ccec91a1Sjoerg extern "C" void __cxa_bad_typeid()
53ccec91a1Sjoerg {
54ccec91a1Sjoerg     throw std::bad_typeid();
55ccec91a1Sjoerg }
56ccec91a1Sjoerg 
57ccec91a1Sjoerg /**
58ccec91a1Sjoerg  * Compilers may (but are not required to) set any pure-virtual function's
59ccec91a1Sjoerg  * vtable entry to this function.  This makes debugging slightly easier, as
60ccec91a1Sjoerg  * users can add a breakpoint on this function to tell if they've accidentally
61ccec91a1Sjoerg  * called a pure-virtual function.
62ccec91a1Sjoerg  */
__cxa_pure_virtual()63ccec91a1Sjoerg extern "C" void __cxa_pure_virtual()
64ccec91a1Sjoerg {
65ccec91a1Sjoerg     abort();
66ccec91a1Sjoerg }
67ccec91a1Sjoerg 
685067d178Sjoerg /**
695067d178Sjoerg  * Compilers may (but are not required to) set any deleted-virtual function's
705067d178Sjoerg  * vtable entry to this function.  This makes debugging slightly easier, as
715067d178Sjoerg  * users can add a breakpoint on this function to tell if they've accidentally
725067d178Sjoerg  * called a deleted-virtual function.
735067d178Sjoerg  */
__cxa_deleted_virtual()745067d178Sjoerg extern "C" void __cxa_deleted_virtual()
755067d178Sjoerg {
765067d178Sjoerg     abort();
775067d178Sjoerg }
78*fec583f4Spooka 
__cxa_throw_bad_array_new_length()79*fec583f4Spooka extern "C" void __cxa_throw_bad_array_new_length()
80*fec583f4Spooka {
81*fec583f4Spooka 	throw std::bad_array_new_length();
82*fec583f4Spooka }
83