1232950Stheraven/*
2232950Stheraven * Copyright 2010-2011 PathScale, Inc. All rights reserved.
3232950Stheraven *
4232950Stheraven * Redistribution and use in source and binary forms, with or without
5232950Stheraven * modification, are permitted provided that the following conditions are met:
6232950Stheraven *
7232950Stheraven * 1. Redistributions of source code must retain the above copyright notice,
8232950Stheraven *    this list of conditions and the following disclaimer.
9232950Stheraven *
10232950Stheraven * 2. Redistributions in binary form must reproduce the above copyright notice,
11232950Stheraven *    this list of conditions and the following disclaimer in the documentation
12232950Stheraven *    and/or other materials provided with the distribution.
13232950Stheraven *
14232950Stheraven * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
15232950Stheraven * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16232950Stheraven * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17232950Stheraven * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
18232950Stheraven * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19232950Stheraven * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20232950Stheraven * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21232950Stheraven * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22232950Stheraven * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23232950Stheraven * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24232950Stheraven * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25232950Stheraven */
26232950Stheraven
27227825Stheraven/**
28227825Stheraven * aux.cc - Compiler helper functions.
29227825Stheraven *
30227825Stheraven * The functions declared in this file are intended to be called only by code
31227825Stheraven * that is automatically generated by C++ compilers for some common cases.
32227825Stheraven */
33227825Stheraven
34227825Stheraven#include <stdlib.h>
35227825Stheraven#include "stdexcept.h"
36227825Stheraven
37227825Stheraven/**
38227825Stheraven * Called to generate a bad cast exception.  This function is intended to allow
39227825Stheraven * compilers to insert code generating this exception without needing to
40227825Stheraven * duplicate the code for throwing the exception in every call site.
41227825Stheraven */
42227825Stheravenextern "C" void __cxa_bad_cast()
43227825Stheraven{
44227825Stheraven    throw std::bad_cast();
45227825Stheraven}
46227825Stheraven
47227825Stheraven/**
48227825Stheraven * Called to generate a bad typeid exception.  This function is intended to
49227825Stheraven * allow compilers to insert code generating this exception without needing to
50227825Stheraven * duplicate the code for throwing the exception in every call site.
51227825Stheraven */
52227825Stheravenextern "C" void __cxa_bad_typeid()
53227825Stheraven{
54227825Stheraven    throw std::bad_typeid();
55227825Stheraven}
56227825Stheraven
57227825Stheraven/**
58227825Stheraven * Compilers may (but are not required to) set any pure-virtual function's
59227825Stheraven * vtable entry to this function.  This makes debugging slightly easier, as
60227825Stheraven * users can add a breakpoint on this function to tell if they've accidentally
61227825Stheraven * called a pure-virtual function.
62227825Stheraven */
63227825Stheravenextern "C" void __cxa_pure_virtual()
64227825Stheraven{
65227825Stheraven    abort();
66227825Stheraven}
67227825Stheraven
68253222Sdim/**
69253222Sdim * Compilers may (but are not required to) set any deleted-virtual function's
70253222Sdim * vtable entry to this function.  This makes debugging slightly easier, as
71253222Sdim * users can add a breakpoint on this function to tell if they've accidentally
72253222Sdim * called a deleted-virtual function.
73253222Sdim */
74253222Sdimextern "C" void __cxa_deleted_virtual()
75253222Sdim{
76253222Sdim    abort();
77253222Sdim}
78