1 /* libstdcxx_wrapper.cc
3 Copyright 2009 Red Hat, Inc.
5 This file is part of Cygwin.
7 This software is a copyrighted work licensed under the terms of the
8 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
12 /* We provide these stubs to call into a user's
13 provided ONDEE replacement if there is one - otherwise
14 it must fall back to the standard libstdc++ version. */
17 #include "cygwin-cxx.h"
18 #include "perprocess.h"
20 /* We are declaring asm names for the functions we define here, as we want
21 to define the wrappers in this file. GCC links everything with wrappers
22 around the standard C++ memory management operators; these are the wrappers,
23 but we want the compiler to know they are the malloc operators and not have
24 it think they're just any old function matching 'extern "C" _wrap_*'. */
26 extern void *operator new(std::size_t sz) throw (std::bad_alloc)
27 __asm__ ("___wrap__Znwj");
28 extern void *operator new[](std::size_t sz) throw (std::bad_alloc)
29 __asm__ ("___wrap__Znaj");
30 extern void operator delete(void *p) throw()
31 __asm__ ("___wrap__ZdlPv");
32 extern void operator delete[](void *p) throw()
33 __asm__ ("___wrap__ZdaPv");
34 extern void *operator new(std::size_t sz, const std::nothrow_t &nt) throw()
35 __asm__ ("___wrap__ZnwjRKSt9nothrow_t");
36 extern void *operator new[](std::size_t sz, const std::nothrow_t &nt) throw()
37 __asm__ ("___wrap__ZnajRKSt9nothrow_t");
38 extern void operator delete(void *p, const std::nothrow_t &nt) throw()
39 __asm__ ("___wrap__ZdlPvRKSt9nothrow_t");
40 extern void operator delete[](void *p, const std::nothrow_t &nt) throw()
41 __asm__ ("___wrap__ZdaPvRKSt9nothrow_t");
44 operator new(std::size_t sz) throw (std::bad_alloc)
46 return (*user_data->cxx_malloc->oper_new) (sz);
50 operator new[](std::size_t sz) throw (std::bad_alloc)
52 return (*user_data->cxx_malloc->oper_new__) (sz);
56 operator delete(void *p) throw()
58 (*user_data->cxx_malloc->oper_delete) (p);
62 operator delete[](void *p) throw()
64 (*user_data->cxx_malloc->oper_delete__) (p);
68 operator new(std::size_t sz, const std::nothrow_t &nt) throw()
70 return (*user_data->cxx_malloc->oper_new_nt) (sz, nt);
74 operator new[](std::size_t sz, const std::nothrow_t &nt) throw()
76 return (*user_data->cxx_malloc->oper_new___nt) (sz, nt);
80 operator delete(void *p, const std::nothrow_t &nt) throw()
82 (*user_data->cxx_malloc->oper_delete_nt) (p, nt);
86 operator delete[](void *p, const std::nothrow_t &nt) throw()
88 (*user_data->cxx_malloc->oper_delete___nt) (p, nt);