- Add nothrow versions of new/delete operators
- Add <cassert>
- Fix a TODO and add missing dependency to <exception> header

svn path=/trunk/; revision=67555
This commit is contained in:
Thomas Faber 2015-05-05 02:44:17 +00:00
parent 72d0938ba9
commit 6e72d71daa
6 changed files with 55 additions and 9 deletions

View file

@ -0,0 +1,5 @@
// C++ forwarding C assert header.
#pragma once
#include <assert.h>

View file

@ -3,6 +3,8 @@
#ifndef __EXCEPTION__
#define __EXCEPTION__
#include <crtdefs.h>
extern "C++" {
class exception

View file

@ -1,10 +1,13 @@
set_cpp(WITH_EXCEPTIONS)
include_directories(${REACTOS_SOURCE_DIR}/lib/sdk/crt/include)
include_directories(
${REACTOS_SOURCE_DIR}/lib/sdk/crt/include
${REACTOS_SOURCE_DIR}/include/c++)
list(APPEND SOURCE
ehvec.cpp
new_nothrow.cpp
typeinfo.cpp)
if(ARCH STREQUAL "i386")

View file

@ -39,4 +39,10 @@ DEFINE_ALIAS ??_M@YGXPAXIIP6EX0@Z@Z, ?MSVCRTEX_eh_vector_destructor_iterator@@YG
; void __cdecl operator delete(void *,unsigned int)
DEFINE_ALIAS ??3@YAXPAXI@Z, ??3@YAXPAX@Z
; void __cdecl operator delete(void *,struct std::nothrow_t const &)
DEFINE_ALIAS ??3@YAXPAXABUnothrow_t@std@@@Z, ??3@YAXPAX@Z
; void __cdecl operator delete[](void *,struct std::nothrow_t const &)
DEFINE_ALIAS ??_V@YAXPAXABUnothrow_t@std@@@Z, ??3@YAXPAX@Z
END

View file

@ -0,0 +1,37 @@
/*
* PROJECT: ReactOS C++ runtime library
* LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
* PURPOSE: nothrow version of the new operators
* PROGRAMMER: Thomas Faber (thomas.faber@reactos.org)
*/
#include <new>
void* operator new (std::size_t) throw(std::bad_alloc);
void* operator new[] (std::size_t) throw(std::bad_alloc);
const std::nothrow_t std::nothrow;
void* operator new (std::size_t size, const std::nothrow_t& nothrow_constant) throw()
{
try
{
return operator new (size);
}
catch (std::bad_alloc)
{
return NULL;
}
}
void* operator new[] (std::size_t size, const std::nothrow_t& nothrow_constant) throw()
{
try
{
return operator new[] (size);
}
catch (std::bad_alloc)
{
return NULL;
}
}

View file

@ -5,14 +5,7 @@
* PROGRAMMER: Thomas Faber (thomas.faber@reactos.org)
*/
/* TODO: #include <exception> instead */
class type_info {
public:
__declspec(dllimport) virtual ~type_info();
private:
type_info(const type_info &);
type_info &operator=(const type_info &);
};
#include <typeinfo>
/* These stubs don't need to do anything (those private functions are never
* called). They need to be in cpprt, though, in order to have the vtable