From 6db7d4e96849fe2ccd17ef75295a711101e191cb Mon Sep 17 00:00:00 2001 From: anonymous Date: Wed, 30 Jun 2010 19:08:23 +0700 Subject: Missing header is added --- src/dwarf_eh.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/dwarf_eh.h b/src/dwarf_eh.h index 1ab25db..02b9db9 100644 --- a/src/dwarf_eh.h +++ b/src/dwarf_eh.h @@ -11,6 +11,8 @@ # include #endif +#include + typedef unsigned char *dw_eh_ptr_t; // Flag indicating a signed quantity #define DW_EH_PE_signed 0x08 -- cgit v1.2.3 From 14a33592c267fe9dc277412444525f3fcfe14f15 Mon Sep 17 00:00:00 2001 From: anonymous Date: Wed, 30 Jun 2010 19:09:37 +0700 Subject: uncaught_exception function is added --- src/exception.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/exception.cc b/src/exception.cc index ce06435..27c9e5f 100644 --- a/src/exception.cc +++ b/src/exception.cc @@ -7,6 +7,11 @@ #include "typeinfo.h" #include "dwarf_eh.h" + +namespace std { + void unexpected(); +} + /** * Class of exceptions to distinguish between this and other exception types. * @@ -877,5 +882,9 @@ namespace std } terminate(); } + bool uncaught_exception() throw() { + __cxa_thread_info *info = thread_info(); + return info->globals.uncaughtExceptions != 0; + } } -- cgit v1.2.3 From 16c253aab349547b256482e6dcc86029d8fe2eda Mon Sep 17 00:00:00 2001 From: anonymous Date: Wed, 30 Jun 2010 19:11:55 +0700 Subject: 1) Static library is added; 2) Aux std functions are added 3) Memory operators are added --- src/Makefile | 12 ++++++++- src/aux.cc | 13 +++++++++ src/memory.cc | 23 ++++++++++++++++ src/stdexcept.cc | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/stdexcept.h | 56 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 183 insertions(+), 1 deletion(-) create mode 100644 src/aux.cc create mode 100644 src/memory.cc create mode 100644 src/stdexcept.cc create mode 100644 src/stdexcept.h (limited to 'src') diff --git a/src/Makefile b/src/Makefile index d8240a7..499a05c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,4 +1,5 @@ -OBJECTS = typeinfo.o exception.o dynamic_cast.o terminate.o guard.o +OBJECTS = typeinfo.o exception.o dynamic_cast.o terminate.o guard.o \ + stdexcept.o memory.o aux.o # Needed for building the shared library CXXFLAGS = -fPIC @@ -20,10 +21,16 @@ LDFLAGS += -L/usr/local/lib -L. -lpthread -fexceptions PRODUCTS = libcxxabi.so.1 +all: libcxxabi.so.1 libcxxabi.a + libcxxabi.so.1: $(OBJECTS) @echo Linking $@... @gcc -fexception -shared $(OBJECTS) $(LDFLAGS) -o libcxxabi.so.1 #-lunwind +libcxxabi.a: $(OBJECTS) + @ar cr libcxxabi.a $(OBJECTS) + + .cc.o: @echo Compiling $<... @$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $< @@ -38,3 +45,6 @@ exception.o: exception.cc typeinfo.h abi_namespace.h typeinfo dwarf_eh.h guard.o: guard.cc terminate.o: terminate.cc typeinfo.o: typeinfo.cc typeinfo.h abi_namespace.h typeinfo +stdexcept.o: stdexcept.cc stdexcept.h +memory.o: memory.cc stdexcept.h +aux.o: aux.cc stdexcept.h diff --git a/src/aux.cc b/src/aux.cc new file mode 100644 index 0000000..c1590e5 --- /dev/null +++ b/src/aux.cc @@ -0,0 +1,13 @@ + +#include "stdexcept.h" + +extern "C" void __cxa_bad_cast() +{ + throw std::bad_cast(); +} + +extern "C" void __cxa_bad_typeid() +{ + throw std::bad_typeid(); +} + diff --git a/src/memory.cc b/src/memory.cc new file mode 100644 index 0000000..de4bc0c --- /dev/null +++ b/src/memory.cc @@ -0,0 +1,23 @@ + + +// This file contains definition of C++ new/delete operators + + +#include +#include +#include "stdexcept.h" + +void * operator new(size_t size) { + void * mem = malloc(size); + if(mem == NULL) { + throw std::bad_alloc(); + } + + return mem; +} + + +void operator delete(void * ptr) { + free(ptr); +} + diff --git a/src/stdexcept.cc b/src/stdexcept.cc new file mode 100644 index 0000000..3d4e086 --- /dev/null +++ b/src/stdexcept.cc @@ -0,0 +1,80 @@ + +#include "stdexcept.h" + +namespace std { + + +exception::exception() throw() { +} + +exception::exception(const exception&) throw() { +} + +exception& exception::operator=(const exception&) throw() { + return *this; +} + +exception::~exception() { +} + +const char* exception::what() const throw() { + return 0; +} + + +bad_alloc::bad_alloc() throw() { +} + +bad_alloc::bad_alloc(const bad_alloc&) throw() { +} + +bad_alloc& bad_alloc::operator=(const bad_alloc&) throw() { + return *this; +} + +bad_alloc::~bad_alloc() { +} + +const char* bad_alloc::what() const throw() { + return "cxxrt::bad_alloc"; +} + + + +bad_cast::bad_cast() throw() { +} + +bad_cast::bad_cast(const bad_cast&) throw() { +} + +bad_cast& bad_cast::operator=(const bad_cast&) throw() { + return *this; +} + +bad_cast::~bad_cast() { +} + +const char* bad_cast::what() const throw() { + return "std::bad_cast"; +} + + +bad_typeid::bad_typeid() throw() { +} + +bad_typeid::bad_typeid(const bad_typeid &__rhs) throw() { +} + +bad_typeid::~bad_typeid() { +} + +bad_typeid& bad_typeid::operator=(const bad_typeid &__rhs) throw() { + return *this; +} + +const char* bad_typeid::what() const throw() { + return "std::bad_typeid"; +} + +} + diff --git a/src/stdexcept.h b/src/stdexcept.h new file mode 100644 index 0000000..af06bda --- /dev/null +++ b/src/stdexcept.h @@ -0,0 +1,56 @@ + + +// This header defines standard exception classes which are needed +// for implementing new/delete operators + + +#ifndef __LIBCXXSUP_STDEXCEPT_H__ +#define __LIBCXXSUP_STDEXCEPT_H__ + +namespace std { + +class exception { +public: + exception() throw(); + exception(const exception&) throw(); + exception& operator=(const exception&) throw(); + virtual ~exception(); + virtual const char* what() const throw(); +}; + + +class bad_alloc: public exception { +public: + bad_alloc() throw(); + bad_alloc(const bad_alloc&) throw(); + bad_alloc& operator=(const bad_alloc&) throw(); + ~bad_alloc(); + virtual const char* what() const throw(); +}; + + +class bad_cast: public exception { +public: + bad_cast() throw(); + bad_cast(const bad_cast&) throw(); + bad_cast& operator=(const bad_cast&) throw(); + virtual ~bad_cast(); + virtual const char* what() const throw(); +}; + + +class bad_typeid: public exception { +public: + bad_typeid() throw(); + bad_typeid(const bad_typeid &__rhs) throw(); + virtual ~bad_typeid(); + bad_typeid& operator=(const bad_typeid &__rhs) throw(); + virtual const char* what() const throw(); +}; + + + +} // namespace std + +#endif // __LIBCXXSUP_STDEXCEPT_H__ + -- cgit v1.2.3 From 60e0a04c5096ca0b33066ac73e2424491ef04cb4 Mon Sep 17 00:00:00 2001 From: anonymous Date: Fri, 2 Jul 2010 18:08:47 +0700 Subject: Cmake project is added --- src/CMakeLists.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/CMakeLists.txt (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..f3c80b2 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,20 @@ + +set(CXXRT_SOURCES + dynamic_cast.cc + exception.cc + guard.cc + terminate.cc + typeinfo.cc + ) + + +add_library(cxxrt-static STATIC ${CXXRT_SOURCES}) +add_library(cxxrt-shared SHARED ${CXXRT_SOURCES}) + +set_target_properties(cxxrt-static cxxrt-shared PROPERTIES + OUTPUT_NAME "cxxrt" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib") + + + -- cgit v1.2.3 From 3310d8a2909b5759686452e68159cbca61038a40 Mon Sep 17 00:00:00 2001 From: anonymous Date: Fri, 2 Jul 2010 19:12:29 +0700 Subject: cmake scripts for testing are added --- src/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f3c80b2..f752b57 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,8 +13,7 @@ add_library(cxxrt-shared SHARED ${CXXRT_SOURCES}) set_target_properties(cxxrt-static cxxrt-shared PROPERTIES OUTPUT_NAME "cxxrt" - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib") + ) -- cgit v1.2.3 From 626ebac2ddee6dd34e52731add5e69496fd269cf Mon Sep 17 00:00:00 2001 From: anonymous Date: Tue, 6 Jul 2010 03:40:09 +0700 Subject: Missing sources are added to cmake project --- src/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f752b57..05fd171 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,6 +5,8 @@ set(CXXRT_SOURCES guard.cc terminate.cc typeinfo.cc + stdexcept.cc + memory.cc ) -- cgit v1.2.3 From 44cd974ddf2d4cf10dc428e5244c99ad6312a3f2 Mon Sep 17 00:00:00 2001 From: anonymous Date: Tue, 6 Jul 2010 03:59:47 +0700 Subject: aux.cc is added to cmake project --- src/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 05fd171..d30da28 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,6 +7,7 @@ set(CXXRT_SOURCES typeinfo.cc stdexcept.cc memory.cc + aux.cc ) -- cgit v1.2.3 From a0de666da82b08c67821f1dd16a1dd81dba80513 Mon Sep 17 00:00:00 2001 From: anonymous Date: Mon, 5 Jul 2010 22:56:06 +0000 Subject: Missing throw() specifier is added --- src/exception.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/exception.cc b/src/exception.cc index 27c9e5f..11f8ca5 100644 --- a/src/exception.cc +++ b/src/exception.cc @@ -758,7 +758,7 @@ extern "C" _Unwind_Reason_Code __gxx_personality_v0(int version, * pointer to the caught exception, which is either the adjusted pointer (for * C++ exceptions) of the unadjusted pointer (for foreign exceptions). */ -extern "C" void *__cxa_begin_catch(void *e) +extern "C" void *__cxa_begin_catch(void *e) throw() { // Decrement the uncaught exceptions count __cxa_eh_globals *globals = __cxa_get_globals(); -- cgit v1.2.3 From 44b2f6d2bf4a1c7695651a908b392a5c3faf6190 Mon Sep 17 00:00:00 2001 From: anonymous Date: Thu, 8 Jul 2010 05:46:22 +0700 Subject: Fix for gcc-4.2 --- src/exception.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/exception.cc b/src/exception.cc index 11f8ca5..5b2c011 100644 --- a/src/exception.cc +++ b/src/exception.cc @@ -758,7 +758,11 @@ extern "C" _Unwind_Reason_Code __gxx_personality_v0(int version, * pointer to the caught exception, which is either the adjusted pointer (for * C++ exceptions) of the unadjusted pointer (for foreign exceptions). */ +#if __GNUC_MINOR__ > 2 extern "C" void *__cxa_begin_catch(void *e) throw() +#else +extern "C" void *__cxa_begin_catch(void *e) +#endif { // Decrement the uncaught exceptions count __cxa_eh_globals *globals = __cxa_get_globals(); -- cgit v1.2.3