Author: tfaber Date: Tue May 5 02:44:17 2015 New Revision: 67555
URL: http://svn.reactos.org/svn/reactos?rev=67555&view=rev Log: [C++] - Add nothrow versions of new/delete operators - Add <cassert> - Fix a TODO and add missing dependency to <exception> header
Added: trunk/reactos/include/c++/cassert (with props) trunk/reactos/lib/sdk/cpprt/new_nothrow.cpp (with props) Modified: trunk/reactos/include/c++/exception trunk/reactos/lib/sdk/cpprt/CMakeLists.txt trunk/reactos/lib/sdk/cpprt/i386/cpprt.s trunk/reactos/lib/sdk/cpprt/typeinfo.cpp
Added: trunk/reactos/include/c++/cassert URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/c%2B%2B/cassert?rev... ============================================================================== --- trunk/reactos/include/c++/cassert (added) +++ trunk/reactos/include/c++/cassert [iso-8859-1] Tue May 5 02:44:17 2015 @@ -0,0 +1,5 @@ +// C++ forwarding C assert header. + +#pragma once + +#include <assert.h>
Propchange: trunk/reactos/include/c++/cassert ------------------------------------------------------------------------------ svn:eol-style = native
Modified: trunk/reactos/include/c++/exception URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/c%2B%2B/exception?r... ============================================================================== --- trunk/reactos/include/c++/exception [iso-8859-1] (original) +++ trunk/reactos/include/c++/exception [iso-8859-1] Tue May 5 02:44:17 2015 @@ -2,6 +2,8 @@
#ifndef __EXCEPTION__ #define __EXCEPTION__ + +#include <crtdefs.h>
extern "C++" {
Modified: trunk/reactos/lib/sdk/cpprt/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/cpprt/CMakeLists.tx... ============================================================================== --- trunk/reactos/lib/sdk/cpprt/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/lib/sdk/cpprt/CMakeLists.txt [iso-8859-1] Tue May 5 02:44:17 2015 @@ -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")
Modified: trunk/reactos/lib/sdk/cpprt/i386/cpprt.s URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/cpprt/i386/cpprt.s?... ============================================================================== --- trunk/reactos/lib/sdk/cpprt/i386/cpprt.s [iso-8859-1] (original) +++ trunk/reactos/lib/sdk/cpprt/i386/cpprt.s [iso-8859-1] Tue May 5 02:44:17 2015 @@ -39,4 +39,10 @@ ; 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
Added: trunk/reactos/lib/sdk/cpprt/new_nothrow.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/cpprt/new_nothrow.c... ============================================================================== --- trunk/reactos/lib/sdk/cpprt/new_nothrow.cpp (added) +++ trunk/reactos/lib/sdk/cpprt/new_nothrow.cpp [iso-8859-1] Tue May 5 02:44:17 2015 @@ -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; + } +}
Propchange: trunk/reactos/lib/sdk/cpprt/new_nothrow.cpp ------------------------------------------------------------------------------ svn:eol-style = native
Modified: trunk/reactos/lib/sdk/cpprt/typeinfo.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/cpprt/typeinfo.cpp?... ============================================================================== --- trunk/reactos/lib/sdk/cpprt/typeinfo.cpp [iso-8859-1] (original) +++ trunk/reactos/lib/sdk/cpprt/typeinfo.cpp [iso-8859-1] Tue May 5 02:44:17 2015 @@ -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