Author: tfaber Date: Sat Jun 22 15:40:20 2013 New Revision: 59289
URL: http://svn.reactos.org/svn/reactos?rev=59289&view=rev Log: [CPPRT] - Add C++ runtime library for MSVC (analogous to GCC's libsupc++) CORE-6950
Added: trunk/reactos/lib/sdk/cpprt/ (with props) trunk/reactos/lib/sdk/cpprt/CMakeLists.txt (with props) trunk/reactos/lib/sdk/cpprt/ehvec.cpp (with props) trunk/reactos/lib/sdk/cpprt/i386/ (with props) trunk/reactos/lib/sdk/cpprt/i386/cpprt.s (with props) trunk/reactos/lib/sdk/cpprt/typeinfo.cpp (with props) Modified: trunk/reactos/lib/sdk/CMakeLists.txt
Modified: trunk/reactos/lib/sdk/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/CMakeLists.txt?rev=... ============================================================================== --- trunk/reactos/lib/sdk/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/lib/sdk/CMakeLists.txt [iso-8859-1] Sat Jun 22 15:40:20 2013 @@ -1,5 +1,8 @@
add_subdirectory(comsupp) +if(MSVC) + add_subdirectory(cpprt) +endif() add_subdirectory(crt) add_subdirectory(delayimp) add_subdirectory(dxguid)
Propchange: trunk/reactos/lib/sdk/cpprt/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Sat Jun 22 15:40:20 2013 @@ -0,0 +1,2 @@ +([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))? +(\d+)
Propchange: trunk/reactos/lib/sdk/cpprt/ ------------------------------------------------------------------------------ bugtraq:message = See issue #%BUGID% for more details.
Propchange: trunk/reactos/lib/sdk/cpprt/ ------------------------------------------------------------------------------ bugtraq:url = http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Propchange: trunk/reactos/lib/sdk/cpprt/ ------------------------------------------------------------------------------ tsvn:logminsize = 10
Added: 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 (added) +++ trunk/reactos/lib/sdk/cpprt/CMakeLists.txt [iso-8859-1] Sat Jun 22 15:40:20 2013 @@ -0,0 +1,4 @@ + +set_cpp(WITH_EXCEPTIONS) + +add_library(cpprt ehvec.cpp typeinfo.cpp i386/cpprt.s)
Propchange: trunk/reactos/lib/sdk/cpprt/CMakeLists.txt ------------------------------------------------------------------------------ svn:eol-style = native
Added: trunk/reactos/lib/sdk/cpprt/ehvec.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/cpprt/ehvec.cpp?rev... ============================================================================== --- trunk/reactos/lib/sdk/cpprt/ehvec.cpp (added) +++ trunk/reactos/lib/sdk/cpprt/ehvec.cpp [iso-8859-1] Sat Jun 22 15:40:20 2013 @@ -0,0 +1,48 @@ +/* + * PROJECT: ReactOS c++ runtime library + * LICENSE: GPLv2+ - See COPYING in the top level directory + * PURPOSE: Exception-handling vector ctor/dtor iterator implementation + * PROGRAMMER: Thomas Faber (thomas.faber@reactos.org) + */ + +#include <stddef.h> + +void __stdcall MSVCRTEX_eh_vector_constructor_iterator(void *pMem, size_t sizeOfItem, int nItems, void (__thiscall *ctor)(void *), void (__thiscall *dtor)(void *)) +{ + char *pEnd = static_cast<char *>(pMem) + nItems * sizeOfItem; + for (char *pItem = static_cast<char *>(pMem); + pItem < pEnd; + pItem += sizeOfItem) + { + try + { + ctor(pItem); + } + catch (...) + { + for (pItem -= sizeOfItem; pItem >= pMem; pItem -= sizeOfItem) + dtor(pItem); + throw; + } + } +} + +void __stdcall MSVCRTEX_eh_vector_destructor_iterator(void *pMem, size_t sizeOfItem, int nItems, void (__thiscall *dtor)(void *)) +{ + char *pEnd = static_cast<char *>(pMem) + nItems * sizeOfItem; + for (char *pItem = pEnd - sizeOfItem; + pItem >= pMem; + pItem -= sizeOfItem) + { + try + { + dtor(pItem); + } + catch (...) + { + for (pItem -= sizeOfItem; pItem >= pMem; pItem -= sizeOfItem) + dtor(pItem); + throw; + } + } +}
Propchange: trunk/reactos/lib/sdk/cpprt/ehvec.cpp ------------------------------------------------------------------------------ svn:eol-style = native
Propchange: trunk/reactos/lib/sdk/cpprt/i386/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Sat Jun 22 15:40:20 2013 @@ -0,0 +1,2 @@ +([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))? +(\d+)
Propchange: trunk/reactos/lib/sdk/cpprt/i386/ ------------------------------------------------------------------------------ bugtraq:message = See issue #%BUGID% for more details.
Propchange: trunk/reactos/lib/sdk/cpprt/i386/ ------------------------------------------------------------------------------ bugtraq:url = http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Propchange: trunk/reactos/lib/sdk/cpprt/i386/ ------------------------------------------------------------------------------ tsvn:logminsize = 10
Added: 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 (added) +++ trunk/reactos/lib/sdk/cpprt/i386/cpprt.s [iso-8859-1] Sat Jun 22 15:40:20 2013 @@ -0,0 +1,16 @@ +#include <asm.inc> + +.code + +MACRO(DEFINE_ALIAS, alias, orig, type) +EXTERN &orig:&type +ALIAS <&alias> = <&orig> +ENDM + +; void __stdcall `eh vector constructor iterator'(void *,unsigned int,int,void (__thiscall*)(void *),void (__thiscall*)(void *)) +DEFINE_ALIAS ??_L@YGXPAXIHP6EX0@Z1@Z, ?MSVCRTEX_eh_vector_constructor_iterator@@YGXPAXIHP6EX0@Z1@Z + +; void __stdcall `eh vector destructor iterator'(void *,unsigned int,int,void (__thiscall*)(void *)) +DEFINE_ALIAS ??_M@YGXPAXIHP6EX0@Z@Z, ?MSVCRTEX_eh_vector_destructor_iterator@@YGXPAXIHP6EX0@Z@Z + +END
Propchange: trunk/reactos/lib/sdk/cpprt/i386/cpprt.s ------------------------------------------------------------------------------ svn:eol-style = native
Added: 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 (added) +++ trunk/reactos/lib/sdk/cpprt/typeinfo.cpp [iso-8859-1] Sat Jun 22 15:40:20 2013 @@ -0,0 +1,27 @@ +/* + * PROJECT: ReactOS c++ runtime library + * LICENSE: GPLv2+ - See COPYING in the top level directory + * PURPOSE: Type info stub implementation + * 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 &); +}; + +/* 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 + * and generated destructor thunks available to programs */ +type_info::type_info(const type_info &) +{ +} + +type_info &type_info::operator=(const type_info &) +{ + return *this; +}
Propchange: trunk/reactos/lib/sdk/cpprt/typeinfo.cpp ------------------------------------------------------------------------------ svn:eol-style = native