mirror of
https://github.com/reactos/reactos.git
synced 2025-05-30 14:39:46 +00:00
[C++]
- 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:
parent
72d0938ba9
commit
6e72d71daa
6 changed files with 55 additions and 9 deletions
5
reactos/include/c++/cassert
Normal file
5
reactos/include/c++/cassert
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
// C++ forwarding C assert header.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <assert.h>
|
|
@ -3,6 +3,8 @@
|
||||||
#ifndef __EXCEPTION__
|
#ifndef __EXCEPTION__
|
||||||
#define __EXCEPTION__
|
#define __EXCEPTION__
|
||||||
|
|
||||||
|
#include <crtdefs.h>
|
||||||
|
|
||||||
extern "C++" {
|
extern "C++" {
|
||||||
|
|
||||||
class exception
|
class exception
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
|
|
||||||
set_cpp(WITH_EXCEPTIONS)
|
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
|
list(APPEND SOURCE
|
||||||
ehvec.cpp
|
ehvec.cpp
|
||||||
|
new_nothrow.cpp
|
||||||
typeinfo.cpp)
|
typeinfo.cpp)
|
||||||
|
|
||||||
if(ARCH STREQUAL "i386")
|
if(ARCH STREQUAL "i386")
|
||||||
|
|
|
@ -39,4 +39,10 @@ DEFINE_ALIAS ??_M@YGXPAXIIP6EX0@Z@Z, ?MSVCRTEX_eh_vector_destructor_iterator@@YG
|
||||||
; void __cdecl operator delete(void *,unsigned int)
|
; void __cdecl operator delete(void *,unsigned int)
|
||||||
DEFINE_ALIAS ??3@YAXPAXI@Z, ??3@YAXPAX@Z
|
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
|
END
|
||||||
|
|
37
reactos/lib/sdk/cpprt/new_nothrow.cpp
Normal file
37
reactos/lib/sdk/cpprt/new_nothrow.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,14 +5,7 @@
|
||||||
* PROGRAMMER: Thomas Faber (thomas.faber@reactos.org)
|
* PROGRAMMER: Thomas Faber (thomas.faber@reactos.org)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* TODO: #include <exception> instead */
|
#include <typeinfo>
|
||||||
class type_info {
|
|
||||||
public:
|
|
||||||
__declspec(dllimport) virtual ~type_info();
|
|
||||||
private:
|
|
||||||
type_info(const type_info &);
|
|
||||||
type_info &operator=(const type_info &);
|
|
||||||
};
|
|
||||||
|
|
||||||
/* These stubs don't need to do anything (those private functions are never
|
/* 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
|
* called). They need to be in cpprt, though, in order to have the vtable
|
||||||
|
|
Loading…
Reference in a new issue