[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH 1/3] * 18.6 Language support library, Type identification: <typeinfo>



---
 STATUS                            |    4 +-
 include/cxxabi.h                  |  463 +++++++++++++++++++++++++++++++++++++
 include/lightlibc++/doxygen.hpp   |    8 +
 include/lightlibc++/exception.hpp |   15 --
 include/lightlibc++/new.hpp       |   15 --
 include/lightlibc++/typeinfo.hpp  |  274 ++++++++++++++++++++++
 include/typeinfo                  |   17 ++
 source/cxxabi/exceptions.cpp      |   41 ++++
 source/cxxabi/typeinfo.cpp        |   92 ++++++++
 source/typeinfo.cpp               |   57 +++++
 testcase/cxxabi/typeinfo.cpp      |  130 +++++++++++
 testcase/typeinfo/bad_cast.cpp    |   52 ++++
 testcase/typeinfo/bad_typeid.cpp  |   47 ++++
 13 files changed, 1183 insertions(+), 32 deletions(-)
 create mode 100644 include/cxxabi.h
 create mode 100644 include/lightlibc++/typeinfo.hpp
 create mode 100644 include/typeinfo
 create mode 100644 source/cxxabi/exceptions.cpp
 create mode 100644 source/cxxabi/typeinfo.cpp
 create mode 100644 source/typeinfo.cpp
 create mode 100644 testcase/cxxabi/typeinfo.cpp
 create mode 100644 testcase/typeinfo/bad_cast.cpp
 create mode 100644 testcase/typeinfo/bad_typeid.cpp

diff --git a/STATUS b/STATUS
index 449002f..f5b891d 100644
--- a/STATUS
+++ b/STATUS
@@ -8,7 +8,7 @@ This file documents the status of the implementation.
 18.3 Integer types                                                   [X]
 18.4 Start and termination                                           [X]
 18.5 Dynamic memory management <new>                                 [X]
-18.6 Type identi�cation                                              [ ]
+18.6 Type identi�cation                                              [X]
 18.7 Exception handling                                              [X]
 18.8 Other runtime support                                           [ ]
 
@@ -96,7 +96,7 @@ This file documents the status of the implementation.
 
 
 C++ Application Binary Interface (Itanium C++ ABI)
-* RTTI (2.9.5)                                                       [ ]
+* RTTI (2.9.5)                                                       [X]
 * dynamic_cast (2.9.7)                                               [ ]
 * Pure virtual functions (3.2.6)                                     [ ]
 * One-time construction (3.3.2)                                      [ ]
diff --git a/include/cxxabi.h b/include/cxxabi.h
new file mode 100644
index 0000000..0449f63
--- /dev/null
+++ b/include/cxxabi.h
@@ -0,0 +1,463 @@
+/*
+Permission is granted to use, modify, and / or redistribute at will.
+
+This includes removing authorship notices, re-use of code parts in
+other software (with or without giving credit), and / or creating a
+commercial product based on it.
+
+This permission is not revocable by the author.
+
+This software is provided as-is. Use it at your own risk. There is
+no warranty whatsoever, neither expressed nor implied, and by using
+this software you accept that the author(s) shall not be held liable
+for any loss of data, loss of service, or other damages, be they
+incidental or consequential. Your only option other than accepting
+this is not to use the software at all.
+*/
+#ifndef _LIGHTLIBCPP_CXXABI_H
+#define _LIGHTLIBCPP_CXXABI_H
+
+
+
+#include <typeinfo>          // std::type_info
+
+
+
+/**
+ *\english
+ *  \brief internal namespace of the C++ ABI
+ *\endenglish
+ *\german
+ *  \brief intern verwendeter Namensraum der C++ ABI
+ *\endgerman
+ */
+namespace __cxxabiv1
+{
+  /** \addtogroup lightlibcpp_cxxabi_rtti */
+  /*@{*/
+
+  /**
+   *\english
+   *  \brief Base class for the runtime type information of the builtin types
+   *\endenglish
+   *\german
+   *  \brief Basisklasse für die Laufzeittypinformation der eingebauten Typen
+   *\endgerman
+   */
+  class __fundamental_type_info : public std::type_info
+  {
+    public:
+      /**
+       *\english
+       *  Destructor
+       *  \note Needed to generate vtables and type information for this class
+       *        and type information for the builtin types
+       *\endenglish
+       *\german
+       *  Destruktor
+       *  \note Wird benötigt um vtables und Typinformationen für diese Klasse
+       *        und Typinformationen für die eingebauten Typen zu generieren
+       *\endgerman
+       */
+      virtual ~__fundamental_type_info();
+  };
+
+  /**
+   *\english
+   *  \brief Base class for the runtime type information of array types
+   *\endenglish
+   *\german
+   *  \brief Basisklasse für die Laufzeittypinformationen von Arraytypen
+   *\endgerman
+   */
+  class __array_type_info : public std::type_info
+  {
+    public:
+      /**
+       *\english
+       *  Destructor
+       *  \note Needed to generate vtables and type information for this class
+       *\endenglish
+       *\german
+       *  Destruktor
+       *  \note Wird benötigt um vtables und Typinformationen für diese Klasse
+       *        zu generieren
+       *\endgerman
+       */
+      virtual ~__array_type_info();
+  };
+
+  /**
+   *\english
+   *  \brief Base class for the runtime type information of (non-member)
+   *         functions
+   *\endenglish
+   *\german
+   *  \brief Basisklasse für die Laufzeittypinformationen von (nicht-member)
+   *         Funktionen
+   *\endgerman
+   */
+  class __function_type_info : public std::type_info
+  {
+    public:
+      /**
+       *\english
+       *  Destructor
+       *  \note Needed to generate vtables and type information for this class
+       *\endenglish
+       *\german
+       *  Destruktor
+       *  \note Wird benötigt um vtables und Typinformationen für diese Klasse
+       *        zu generieren
+       *\endgerman
+       */
+      virtual ~__function_type_info();
+  };
+
+  /**
+   *\english
+   *  \brief Base class for the runtime type information of enumeration types
+   *\endenglish
+   *\german
+   *  \brief Basisklasse für die Laufzeittypinformationen von Enumerationstypen
+   *\endgerman
+   */
+  class __enum_type_info : public std::type_info
+  {
+    public:
+      /**
+       *\english
+       *  Destructor
+       *  \note Needed to generate vtables and type information for this class
+       *\endenglish
+       *\german
+       *  Destruktor
+       *  \note Wird benötigt um vtables und Typinformationen für diese Klasse
+       *        zu generieren
+       *\endgerman
+       */
+      virtual ~__enum_type_info();
+  };
+
+  /**
+   *\english
+   *  \brief Base class for the runtime type information of class types
+   *\endenglish
+   *\german
+   *  \brief Basiskalsse für die Laufzeittypinformationen von Klassentypen
+   *\endgerman
+   */
+  class __class_type_info : public std::type_info
+  {
+    public:
+      /**
+       *\english
+       *  Destructor
+       *  \note Needed to generate vtables and type information for this class
+       *\endenglish
+       *\german
+       *  Destruktor
+       *  \note Wird benötigt um vtables und Typinformationen für diese Klasse
+       *        zu generieren
+       *\endgerman
+       */
+      virtual ~__class_type_info();
+  };
+
+  /**
+   *\english
+   *  \brief Base class for the runtime type information of class types with
+   *         single inheritance
+   *\endenglish
+   *\german
+   *  \brief Basisklasse für die Laufzeittypinformationen von Klassentypen mit
+   *         Einfachvererbung
+   *\endgerman
+   */
+  class __si_class_type_info : public __class_type_info
+  {
+    public:
+      /**
+       *\english
+       *  pointer to the type information of the base class
+       *\endenglish
+       *\german
+       *  Zeiger auf die Typinformationen der Basisklasse
+       *\endgerman
+       */
+      const __class_type_info* __base_type;
+
+      /**
+       *\english
+       *  Destructor
+       *  \note Needed to generate vtables and type information for this class
+       *\endenglish
+       *\german
+       *  Destruktor
+       *  \note Wird benötigt um vtables und Typinformationen für diese Klasse
+       *        zu generieren
+       *\endgerman
+       */
+      virtual ~__si_class_type_info();
+  };
+
+  /**
+   *\english
+   *  \brief Information about a base class in a inheritance hierarchy with
+   *         multiple inheritance
+   *\endenglish
+   *\german
+   *  \brief Informationen über eine Basisklasse in einer Vererbungshierarchie
+   *         mit Mehrfachvererbung
+   *\endgerman
+   */
+  struct __base_class_type_info
+  {
+    public:
+      /**
+       *\english
+       *  pointer to the type information of the base class
+       *\endenglish
+       *\german
+       *  Zeiger auf die Typinformationen der Basisklasse
+       *\endgerman
+       */
+      const __class_type_info* __base_type;
+
+      /**
+       *\english
+       *  flags describing the precise type of the inheritance, see
+       *  __base_class_type_info::__offset_flags_masks
+       *\endenglish
+       *\german
+       *  Flags die den genauen Vererbungstyp angeben, siehe
+       *  __base_class_type_info::__offset_flags_masks
+       *\endgerman
+       */
+      long                     __offset_flags;
+
+      /** \todo document */
+      enum __offset_flags_masks
+      {
+        /** \todo document */
+        __virtual_mask = 0x01,
+        /** \todo document */
+        __public_mask  = 0x02,
+        /** \todo document */
+        __offset_shift = 8
+      };
+  };
+
+  /** \todo document */
+  class __vmi_class_type_info : public __class_type_info
+  {
+    public:
+      /** \todo document */
+      unsigned int __flags;
+      /** \todo document */
+      unsigned int __base_count;
+      /** \todo document */
+      __base_class_type_info __base_info[1];
+
+      /** \todo document */
+      enum __flags_masks
+      {
+        /** \todo document */
+        __non_diamond_repeat_mask = 0x01,
+        /** \todo document */
+        __diamond_shaped_mask     = 0x02
+      };
+
+      /**
+       *\english
+       *  Destructor
+       *  \note Needed to generate vtables and type information for this class
+       *\endenglish
+       *\german
+       *  Destruktor
+       *  \note Wird benötigt um vtables und Typinformationen für diese Klasse
+       *        zu generieren
+       *\endgerman
+       */
+      virtual ~__vmi_class_type_info();
+  };
+
+  /**
+   *\english
+   *  \brief Base class for the runtime type information of pointer types
+   *         except pointer to non-member functions
+   *\endenglish
+   *\german
+   *  \brief Basisklasse für die Laufzeittypinformationen von Zeigertypen
+   *         auÃ?er Zeiger auf nicht-Memberfunktionen
+   *\endgerman
+   */
+  class __pbase_type_info : public std::type_info
+  {
+    public:
+      /**
+       *\english
+       *  flags describing the precise type of the pointer, see __pbase_type_info::__masks
+       *\endenglish
+       *\german
+       *  Flags die den genauen Typ des Zeigers angeben, siehe __pbase_type_info::__masks
+       *\endgerman
+       */
+      unsigned int          __flags;
+
+      /**
+       *\english
+       *  pointer to the type information of the type pointed to
+       *\endenglish
+       *\german
+       *  Zeiger auf die Typinformationen des Typs auf den der Zeiger zeigt
+       *\endgerman
+       */
+      const std::type_info* __pointee;
+
+      /**
+       *\english
+       *  flags of the __flags variable
+       *\endenglish
+       *\german
+       *  Flags für die __flags Variable
+       *\endgerman
+       */
+      enum __masks
+      {
+        /** const */
+        __const_mask            = 0x01,
+
+        /** volatile */
+        __volatile_mask         = 0x02,
+
+        /** restrict */
+        __restrict_mask         = 0x04,
+
+        /**
+         *\english
+         *  incomplete type information
+         *\endenglish
+         *\german
+         *  unvollständige Typinformationen
+         *\endgerman
+         */
+        __incomplete_mask       = 0x08,
+
+        /**
+         *\english
+         *  incomplete type information for a class type
+         *\endenglish
+         *\german
+         *  unvollständige Typinformationen für einen Klassentyp
+         *\endgerman
+         */
+        __incomplete_class_mask = 0x10
+      };
+
+      /**
+       *\english
+       *  Destructor
+       *  \note Needed to generate vtables and type information for this class
+       *\endenglish
+       *\german
+       *  Destruktor
+       *  \note Wird benötigt um vtables und Typinformationen für diese Klasse
+       *        zu generieren
+       *\endgerman
+       */
+      virtual ~__pbase_type_info();
+  };
+
+  /**
+   *\english
+   *  \brief Base class for the runtime type information of pointer types
+   *         except pointer to member
+   *\endenglish
+   *\german
+   *  \brief Basisklasse für die Laufzeittypinformationen von Zeigertypen
+   *         auÃ?er Zeiger auf Klassenmember
+   *\endgerman
+   */
+  class __pointer_type_info : public __pbase_type_info
+  {
+    public:
+      /**
+       *\english
+       *  Destructor
+       *  \note Needed to generate vtables and type information for this class
+       *\endenglish
+       *\german
+       *  Destruktor
+       *  \note Wird benötigt um vtables und Typinformationen für diese Klasse
+       *        zu generieren
+       *\endgerman
+       */
+      virtual ~__pointer_type_info();
+  };
+
+  /**
+   *\english
+   *  \brief Base class for the runtime type information of pointer-to-member
+   *         types
+   *\endenglish
+   *\german
+   *  \brief Basisklasse für die Laufzeittypinformationen von Zeiger-auf-Member
+   *         Typen
+   *\endgerman
+   */
+  class __pointer_to_member_type_info : public __pbase_type_info
+  {
+    public:
+      /**
+       *\english
+       *  pointer to the type information of the class of the pointer-to-member
+       *\endenglish
+       *\german
+       *  Zeiger auf die Typinformationen der Klasse des Zeigers-auf-Member
+       *\endgerman
+       */
+      const __class_type_info* __context;
+
+      /**
+       *\english
+       *  Destructor
+       *  \note Needed to generate vtables and type information for this class
+       *\endenglish
+       *\german
+       *  Destruktor
+       *  \note Wird benötigt um vtables und Typinformationen für diese Klasse
+       *        zu generieren
+       *\endgerman
+       */
+      virtual ~__pointer_to_member_type_info();
+  };
+
+  /*@}*/
+}
+
+
+
+/**
+ *\english
+ *  \brief Namespace of the C++ ABI
+ *
+ *  This namespace contains additionally to those members listed here all
+ *  members of the __cxxabiv1 namespace.
+ *\endenglish
+ *\german
+ *  \brief Namensraum der C++ ABI
+ *
+ *  Dieser Namensraum zusätzlich zu den hier gelisteten alle Elemente aus dem
+ *  Namensraum __cxxabiv1 .
+ *\endgerman
+ */
+namespace abi
+{
+  // Lift all classes from __cxxabiv1 to the abi namespace
+  using namespace __cxxabiv1;
+}
+
+
+
+#endif
diff --git a/include/lightlibc++/doxygen.hpp b/include/lightlibc++/doxygen.hpp
index 39eba00..bbbfe46 100644
--- a/include/lightlibc++/doxygen.hpp
+++ b/include/lightlibc++/doxygen.hpp
@@ -28,9 +28,17 @@ this is not to use the software at all.
  *  \ingroup lightlibcpp_18_5 */
 /** \defgroup lightlibcpp_18_5_2 18.5.2 Storage allocation errors
  *  \ingroup lightlibcpp_18_5 */
+/** \defgroup lightlibcpp_18_6 18.6 Type identification
+ *  \ingroup lightlibcpp_18 */
 /** \defgroup lightlibcpp_18_7 18.7 Exception handling
  *  \ingroup lightlibcpp_18 */
 /** \defgroup lightlibcpp_18_7_2 18.7.2 Violating exception-speci�cations
  *  \ingroup lightlibcpp_18_7 */
 /** \defgroup lightlibcpp_18_7_3 18.7.3 Abnormal termination
  *  \ingroup lightlibcpp_18_7 */
+
+
+
+/** \defgroup lightlibcpp_cxxabi C++ Application Binary Interface */
+/** \defgroup lightlibcpp_cxxabi_rtti RTTI (= Runtime Type Information)
+ *  \ingroup lightlibcpp_cxxabi */
diff --git a/include/lightlibc++/exception.hpp b/include/lightlibc++/exception.hpp
index 7f1309e..9475d6e 100644
--- a/include/lightlibc++/exception.hpp
+++ b/include/lightlibc++/exception.hpp
@@ -165,21 +165,6 @@ namespace std
 
       /**
        *\english
-       *  Copies an object of class bad_exception.
-       *  \param[in] x reference to the object to copy
-       *\endenglish
-       *\german
-       *  Kopiert ein Objekt der Klasse bad_exception.
-       *  \param[in] x Referenz auf das zu kopierende Objekt
-       *\endgerman */
-      inline bad_exception& operator = (const bad_exception& x) throw()
-      {
-        (void)x;
-        return *this;
-      }
-
-      /**
-       *\english
        *  Destructs an object of class bad_exception
        *\endenglish
        *\german
diff --git a/include/lightlibc++/new.hpp b/include/lightlibc++/new.hpp
index 48252c1..76dd91a 100644
--- a/include/lightlibc++/new.hpp
+++ b/include/lightlibc++/new.hpp
@@ -114,21 +114,6 @@ namespace std
 
       /**
        *\english
-       *  Copies an object of class bad_alloc.
-       *  \param[in] x reference to the object to copy
-       *\endenglish
-       *\german
-       *  Kopiert ein Objekt der Klasse bad_alloc.
-       *  \param[in] x Referenz auf das zu kopierende Objekt
-       *\endgerman */
-      inline bad_alloc& operator = (const bad_alloc& x) throw()
-      {
-        (void)x;
-        return *this;
-      }
-
-      /**
-       *\english
        *  Destructs an object of class bad_alloc
        *\endenglish
        *\german
diff --git a/include/lightlibc++/typeinfo.hpp b/include/lightlibc++/typeinfo.hpp
new file mode 100644
index 0000000..1a46804
--- /dev/null
+++ b/include/lightlibc++/typeinfo.hpp
@@ -0,0 +1,274 @@
+/*
+Permission is granted to use, modify, and / or redistribute at will.
+
+This includes removing authorship notices, re-use of code parts in
+other software (with or without giving credit), and / or creating a
+commercial product based on it.
+
+This permission is not revocable by the author.
+
+This software is provided as-is. Use it at your own risk. There is
+no warranty whatsoever, neither expressed nor implied, and by using
+this software you accept that the author(s) shall not be held liable
+for any loss of data, loss of service, or other damages, be they
+incidental or consequential. Your only option other than accepting
+this is not to use the software at all.
+*/
+#ifndef _LIGHTLIBCPP_TYPEINFO_HPP
+#define _LIGHTLIBCPP_TYPEINFO_HPP
+
+
+
+#include <exception>         // std::exception
+
+
+
+namespace std
+{
+  /** \addtogroup lightlibcpp_18_6 */
+  /*@{*/
+
+  /**
+   *\english
+   *  \brief Base class for runtime type-information return by the typeid
+   *         operator
+   *\endenglish
+   *\german
+   *  \brief Basisklasse für Laufzeittypinformationen vom typeid-Operator
+   *\endgerman
+   */
+  class type_info
+  {
+    public:
+      /**
+       *\english
+       *  analogue to the == operator
+       *  \param[in] x the object to compare to
+       *\endenglish
+       *\german
+       *  analog dem == Operator
+       *  \param[in] x das Objekt mit dem verglichen werden soll
+       *\endgerman
+       */
+      inline bool operator != (const type_info& x) const
+      {
+        return !(*this == x);
+      }
+
+      /**
+       *\english
+       *  mangled name of the type the type_info references
+       *  \note The described functionality is specific to the implemented C++
+       *        ABI
+       *\endenglish
+       *\german
+       *  'mangled name' des Typs den diese type_info Klasse beschreibt
+       *  \note Die beschriebene Funktionalität ist abhängig von der
+       *        implementierten C++ ABI
+       *\endgerman
+       */
+      inline const char* name() const
+      {
+        return __type_name;
+      }
+
+      /**
+       *\english
+       *  \note The implementation of this function is part of the C++ ABI
+       *  \param[in] x the object to compare to
+       *  \return true, if two type_info's reference the same type, false
+       *          otherwise
+       *\endenglish
+       *\german
+       *  \note Die Implementation dieser Funktion ist Teil der C++ ABI
+       *  \param[in] x das Objekt mit dem verglichen werden soll
+       *  \return true, falls zwei type_info's den gleichen Typ beschreiben,
+       *          sonst false
+       *\endgerman
+       */
+      inline bool operator == (const type_info& x) const
+      {
+        return (__type_name == x.__type_name);
+      }
+
+      /** \todo what is this supposed to be used for?
+       *  \param x */
+      bool before(const type_info& x) const;
+
+      /**
+       *\english
+       *  Destructor
+       *\endenglish
+       *\german
+       *  Destruktor
+       *\endgerman
+       */
+      virtual ~type_info();
+
+  #ifndef _LIGHTLIB_CPP10
+    private:
+      /**
+       *\english
+       *  \note No copy-constructor available
+       *\endenglish
+       *\german
+       *  \note Kein Kopierkonstruktor verfügbar
+       *\endgerman
+       */
+      type_info(const type_info&);
+
+      /**
+       *\english
+       *  \note No assignment-operator available
+       *\endenglish
+       *\german
+       *  \note Kein Zuweisungsoperator verfügbar
+       *\endgerman
+       */
+      type_info& operator = (const type_info&);
+  #else
+      /**
+       *\english
+       *  \note No copy-constructor available
+       *\endenglish
+       *\german
+       *  \note Kein Kopierkonstruktor verfügbar
+       *\endgerman
+       */
+      type_info(const type_info&) = delete;
+
+      /**
+       *\english
+       *  \note No assignment-operator available
+       *\german
+       *  \note Kein Zuweisungsoperator verfügbar
+       *\endgerman
+       */
+      type_info& operator = (const type_info&) = delete;
+  #endif
+
+    private:
+      /**
+       *\english
+       *  pointer to the mangled name of the type
+       *  \warning This member is part of the C++ ABI
+       *\endenglish
+       *\german
+       *  Zeiger auf den 'mangled name' des Typs
+       *  \warning Dieser Member ist Teil der C++ ABI
+       *\endgerman
+       */
+      const char* __type_name;
+  };
+
+  /**
+   *\english
+   *  \brief Class thrown by an invalid dynamic_cast expression
+   *\endenglish
+   *\german
+   *  \brief Klasse die von einem ungültigen dynamic_cast Ausdruck geworfen
+   *         wird
+   *\endgerman
+   */
+  class bad_cast : public std::exception
+  {
+    public:
+      /**
+       *\english
+       *  Constructs an object of class bad_cast.
+       *\endenglish
+       *\german
+       *  Konstruiert ein Objekt der Klasse bad_cast.
+       *\endgerman
+       */
+      inline bad_cast() throw()
+      {
+      }
+
+      /**
+       *\english
+       *  Copies an object of class bad_exception.
+       *  \param[in] x reference to the object to copy
+       *\endenglish
+       *\german
+       *  Kopiert ein Objekt der Klasse bad_exception.
+       *  \param[in] x Referenz auf das zu kopierende Objekt
+       *\endgerman
+       */
+      inline bad_cast(const bad_cast& x) throw()
+        : std::exception(x)
+      {
+      }
+
+      /**
+       *\english
+       *  Destructs an object of class bad_cast
+       *\endenglish
+       *\german
+       *  Zerstört ein Objekt der Klasse bad_cast
+       *\endgerman
+       */
+      virtual ~bad_cast() throw();
+
+      virtual const char* what() const throw();
+  };
+
+  /**
+   *\english
+   *  \brief Class thrown by the implementation to report a null pointer in a
+   *         typeid expression
+   *\endenglish
+   *\german
+   *  \brief Klasse die von der Implementierung geworfen wird, um einen
+   *         Nullzeiger in einem typeid Ausdruck zu melden
+   *\endgerman
+   */
+  class bad_typeid : public std::exception
+  {
+    public:
+      /**
+       *\english
+       *  Constructs an object of class bad_typeid.
+       *\endenglish
+       *\german
+       *  Konstruiert ein Objekt der Klasse bad_typeid.
+       *\endgerman
+       */
+      inline bad_typeid() throw()
+      {
+      }
+
+      /**
+       *\english
+       *  Copies an object of class bad_typeid.
+       *  \param[in] x reference to the object to copy
+       *\endenglish
+       *\german
+       *  Kopiert ein Objekt der Klasse bad_typeid.
+       *  \param[in] x Referenz auf das zu kopierende Objekt
+       *\endgerman
+       */
+      inline bad_typeid(const bad_typeid& x) throw()
+        : std::exception(x)
+      {
+      }
+
+      /**
+       *\english
+       *  Destructs an object of class bad_typeid
+       *\endenglish
+       *\german
+       *  Zerstört ein Objekt der Klasse bad_typeid
+       *\endgerman
+       */
+      virtual ~bad_typeid() throw();
+
+      virtual const char* what() const throw();
+  };
+
+  /*@}*/
+}
+
+
+
+#endif
diff --git a/include/typeinfo b/include/typeinfo
new file mode 100644
index 0000000..163c500
--- /dev/null
+++ b/include/typeinfo
@@ -0,0 +1,17 @@
+/*
+Permission is granted to use, modify, and / or redistribute at will.
+
+This includes removing authorship notices, re-use of code parts in
+other software (with or without giving credit), and / or creating a
+commercial product based on it.
+
+This permission is not revocable by the author.
+
+This software is provided as-is. Use it at your own risk. There is
+no warranty whatsoever, neither expressed nor implied, and by using
+this software you accept that the author(s) shall not be held liable
+for any loss of data, loss of service, or other damages, be they
+incidental or consequential. Your only option other than accepting
+this is not to use the software at all.
+*/
+#include <lightlibc++/typeinfo.hpp>
diff --git a/source/cxxabi/exceptions.cpp b/source/cxxabi/exceptions.cpp
new file mode 100644
index 0000000..6353251
--- /dev/null
+++ b/source/cxxabi/exceptions.cpp
@@ -0,0 +1,41 @@
+/*
+Permission is granted to use, modify, and / or redistribute at will.
+
+This includes removing authorship notices, re-use of code parts in
+other software (with or without giving credit), and / or creating a
+commercial product based on it.
+
+This permission is not revocable by the author.
+
+This software is provided as-is. Use it at your own risk. There is
+no warranty whatsoever, neither expressed nor implied, and by using
+this software you accept that the author(s) shall not be held liable
+for any loss of data, loss of service, or other damages, be they
+incidental or consequential. Your only option other than accepting
+this is not to use the software at all.
+*/
+
+// TODO: C++ exception handling
+extern "C" void _Unwind_Resume()
+{
+}
+
+extern "C" void __gcc_personality_v0()
+{
+}
+
+extern "C" void _Unwind_Backtrace()
+{
+}
+
+extern "C" void _Unwind_GetIP()
+{
+}
+
+extern "C" void _Unwind_GetGR()
+{
+}
+
+extern "C" void _Unwind_GetCFA()
+{
+}
diff --git a/source/cxxabi/typeinfo.cpp b/source/cxxabi/typeinfo.cpp
new file mode 100644
index 0000000..2685da9
--- /dev/null
+++ b/source/cxxabi/typeinfo.cpp
@@ -0,0 +1,92 @@
+/*
+Permission is granted to use, modify, and / or redistribute at will.
+
+This includes removing authorship notices, re-use of code parts in
+other software (with or without giving credit), and / or creating a
+commercial product based on it.
+
+This permission is not revocable by the author.
+
+This software is provided as-is. Use it at your own risk. There is
+no warranty whatsoever, neither expressed nor implied, and by using
+this software you accept that the author(s) shall not be held liable
+for any loss of data, loss of service, or other damages, be they
+incidental or consequential. Your only option other than accepting
+this is not to use the software at all.
+*/
+#include <typeinfo>
+#include <cxxabi.h>
+#include <string.h>
+// TODO #include <cstring>           // std::strcmp
+
+
+
+/*
+ * class std::type_info
+ */
+
+bool std::type_info::before(const type_info& x) const
+{
+  // TODO std::strcmp
+  return (strcmp(__type_name, x.__type_name) < 0);
+}
+
+
+
+/*
+ * class abi::__fundamental_type_info
+ * NOTE: Emits the __fundamental_type_info's for the following types:
+ *       void, bool, wchar_t, char, unsigned char, signed char, short,
+ *       unsigned short, int, unsigned int, long, unsigned long, long long,
+ *       unsigned long long, float, double, long double and for every pointer
+ *       and pointer-to-const to these types
+ *       And Emits vtables and typeinfo for __fundamental_type_info
+ */
+
+abi::__fundamental_type_info::~__fundamental_type_info()
+{
+}
+
+
+
+/*
+ * NOTE: Emits vtables and typeinfo for __array_type_info, __function_type_info,
+ *       __enum_type_info, __pointer_to_member_type_info, __class_type_info,
+ *       __si_class_type_info and __vmi_class_type_info
+ */
+
+abi::__array_type_info::~__array_type_info()
+{
+}
+
+abi::__function_type_info::~__function_type_info()
+{
+}
+
+abi::__enum_type_info::~__enum_type_info()
+{
+}
+
+abi::__pbase_type_info::~__pbase_type_info()
+{
+}
+
+abi::__pointer_type_info::~__pointer_type_info()
+{
+}
+
+abi::__pointer_to_member_type_info::~__pointer_to_member_type_info()
+{
+}
+
+abi::__class_type_info::~__class_type_info()
+{
+}
+
+abi::__si_class_type_info::~__si_class_type_info()
+{
+}
+
+abi::__vmi_class_type_info::~__vmi_class_type_info()
+{
+}
diff --git a/source/typeinfo.cpp b/source/typeinfo.cpp
new file mode 100644
index 0000000..9b62251
--- /dev/null
+++ b/source/typeinfo.cpp
@@ -0,0 +1,57 @@
+/*
+Permission is granted to use, modify, and / or redistribute at will.
+
+This includes removing authorship notices, re-use of code parts in
+other software (with or without giving credit), and / or creating a
+commercial product based on it.
+
+This permission is not revocable by the author.
+
+This software is provided as-is. Use it at your own risk. There is
+no warranty whatsoever, neither expressed nor implied, and by using
+this software you accept that the author(s) shall not be held liable
+for any loss of data, loss of service, or other damages, be they
+incidental or consequential. Your only option other than accepting
+this is not to use the software at all.
+*/
+#include <typeinfo>
+
+
+
+/*
+ * class std::type_info
+ */
+
+std::type_info::~type_info()
+{
+}
+
+
+
+/*
+ * class std::bad_cast
+ */
+
+std::bad_cast::~bad_cast() throw()
+{
+}
+
+const char* std::bad_cast::what() const throw()
+{
+  return "std::bad_cast";
+}
+
+
+
+/*
+ * class std::bad_typeid
+ */
+
+std::bad_typeid::~bad_typeid() throw()
+{
+}
+
+const char* std::bad_typeid::what() const throw()
+{
+  return "std::bad_typeid";
+}
diff --git a/testcase/cxxabi/typeinfo.cpp b/testcase/cxxabi/typeinfo.cpp
new file mode 100644
index 0000000..2bf873d
--- /dev/null
+++ b/testcase/cxxabi/typeinfo.cpp
@@ -0,0 +1,130 @@
+/*
+Permission is granted to use, modify, and / or redistribute at will.
+
+This includes removing authorship notices, re-use of code parts in
+other software (with or without giving credit), and / or creating a
+commercial product based on it.
+
+This permission is not revocable by the author.
+
+This software is provided as-is. Use it at your own risk. There is
+no warranty whatsoever, neither expressed nor implied, and by using
+this software you accept that the author(s) shall not be held liable
+for any loss of data, loss of service, or other damages, be they
+incidental or consequential. Your only option other than accepting
+this is not to use the software at all.
+*/
+#include <typeinfo>
+#include <cstdlib>
+#include <stdio.h>
+
+/*
+ * Checks that type information is properly generated
+ */
+
+enum some_enum
+{
+};
+
+class some_class
+{
+  public:
+    void f(){}
+    virtual ~some_class(){}
+};
+
+class single_derived : public some_class
+{
+};
+
+class some_other_base
+{
+  public:
+    virtual ~some_other_base(){}
+};
+
+class multiple_derived : public some_class,
+                         public some_other_base
+{
+};
+
+int main()
+{
+  /* Check type information for the fundamental types */
+  printf("%s\n", typeid(void).name());
+  printf("%s\n", typeid(bool).name());
+  printf("%s\n", typeid(wchar_t).name());
+  printf("%s\n", typeid(char).name());
+  printf("%s\n", typeid(unsigned char).name());
+  printf("%s\n", typeid(signed char).name());
+  printf("%s\n", typeid(short).name());
+  printf("%s\n", typeid(unsigned short).name());
+  printf("%s\n", typeid(int).name());
+  printf("%s\n", typeid(unsigned int).name());
+  printf("%s\n", typeid(long).name());
+  printf("%s\n", typeid(unsigned long).name());
+  printf("%s\n", typeid(long long).name());
+  printf("%s\n", typeid(unsigned long long).name());
+  printf("%s\n", typeid(float).name());
+  printf("%s\n", typeid(double).name());
+  printf("%s\n", typeid(long double).name());
+
+  /* Check type information for array types */
+  printf("%s\n", typeid(int [5]).name());
+
+  /* Check type information for function types */
+  printf("%s\n", typeid(main).name());
+
+  /* Check type information for enum types */
+  printf("%s\n", typeid(some_enum).name());
+
+  /* Check type information for normal class */
+  printf("%s\n", typeid(some_class).name());
+
+  /* Check type information for class with single inheritance */
+  printf("%s\n", typeid(single_derived).name());
+
+  /* Check type information for class with multiple inheritance */
+  printf("%s\n", typeid(multiple_derived).name());
+
+  /* Check type information for fundamental pointer types */
+  printf("%s\n", typeid(void*).name());
+  printf("%s\n", typeid(bool*).name());
+  printf("%s\n", typeid(wchar_t*).name());
+  printf("%s\n", typeid(char*).name());
+  printf("%s\n", typeid(unsigned char*).name());
+  printf("%s\n", typeid(signed char*).name());
+  printf("%s\n", typeid(short*).name());
+  printf("%s\n", typeid(unsigned short*).name());
+  printf("%s\n", typeid(int*).name());
+  printf("%s\n", typeid(unsigned int*).name());
+  printf("%s\n", typeid(long*).name());
+  printf("%s\n", typeid(unsigned long*).name());
+  printf("%s\n", typeid(long long*).name());
+  printf("%s\n", typeid(unsigned long long*).name());
+  printf("%s\n", typeid(float*).name());
+  printf("%s\n", typeid(double*).name());
+  printf("%s\n", typeid(long double*).name());
+  printf("%s\n", typeid(const void*).name());
+  printf("%s\n", typeid(const bool*).name());
+  printf("%s\n", typeid(const wchar_t*).name());
+  printf("%s\n", typeid(const char*).name());
+  printf("%s\n", typeid(const unsigned char*).name());
+  printf("%s\n", typeid(const signed char*).name());
+  printf("%s\n", typeid(const short*).name());
+  printf("%s\n", typeid(const unsigned short*).name());
+  printf("%s\n", typeid(const int*).name());
+  printf("%s\n", typeid(const unsigned int*).name());
+  printf("%s\n", typeid(const long*).name());
+  printf("%s\n", typeid(const unsigned long*).name());
+  printf("%s\n", typeid(const long long*).name());
+  printf("%s\n", typeid(const unsigned long long*).name());
+  printf("%s\n", typeid(const float*).name());
+  printf("%s\n", typeid(const double*).name());
+  printf("%s\n", typeid(const long double*).name());
+
+  /* Check type information for pointer to member types */
+  printf("%s\n", typeid(&some_class::f).name());
+
+  return EXIT_SUCCESS;
+}
diff --git a/testcase/typeinfo/bad_cast.cpp b/testcase/typeinfo/bad_cast.cpp
new file mode 100644
index 0000000..50f7e39
--- /dev/null
+++ b/testcase/typeinfo/bad_cast.cpp
@@ -0,0 +1,52 @@
+/*
+Permission is granted to use, modify, and / or redistribute at will.
+
+This includes removing authorship notices, re-use of code parts in
+other software (with or without giving credit), and / or creating a
+commercial product based on it.
+
+This permission is not revocable by the author.
+
+This software is provided as-is. Use it at your own risk. There is
+no warranty whatsoever, neither expressed nor implied, and by using
+this software you accept that the author(s) shall not be held liable
+for any loss of data, loss of service, or other damages, be they
+incidental or consequential. Your only option other than accepting
+this is not to use the software at all.
+*/
+#include <typeinfo>
+#include <cstdlib>
+// TODO #include <cstdio>
+#include <stdio.h>
+
+/*
+ * Trigger a std::bad_cast exception
+ */
+
+class some_class
+{
+  public:
+    virtual ~some_class(){}
+};
+
+class some_derived : public some_class
+{
+};
+
+int main()
+{
+  some_class* p = new some_class();
+
+  try
+  {
+    dynamic_cast<some_derived&>(*p);
+  }
+  catch (std::bad_cast& e)
+  {
+    delete p;
+    return EXIT_SUCCESS;
+  }
+
+  delete p;
+  return EXIT_FAILURE;
+}
diff --git a/testcase/typeinfo/bad_typeid.cpp b/testcase/typeinfo/bad_typeid.cpp
new file mode 100644
index 0000000..9c395a2
--- /dev/null
+++ b/testcase/typeinfo/bad_typeid.cpp
@@ -0,0 +1,47 @@
+/*
+Permission is granted to use, modify, and / or redistribute at will.
+
+This includes removing authorship notices, re-use of code parts in
+other software (with or without giving credit), and / or creating a
+commercial product based on it.
+
+This permission is not revocable by the author.
+
+This software is provided as-is. Use it at your own risk. There is
+no warranty whatsoever, neither expressed nor implied, and by using
+this software you accept that the author(s) shall not be held liable
+for any loss of data, loss of service, or other damages, be they
+incidental or consequential. Your only option other than accepting
+this is not to use the software at all.
+*/
+#include <typeinfo>
+#include <cstdlib>
+// TODO: #include <cstdio>
+#include <stdio.h>
+
+/*
+ * Trigger a std::bad_typeid exception
+ */
+
+// NOTE: This class has to be polymorphic
+class some_class
+{
+  virtual ~some_class(){}
+};
+
+some_class* p = 0;
+
+int main()
+{
+  try
+  {
+    const std::type_info& info = typeid(*p);
+    printf("%s\n", info.name());
+  }
+  catch (std::bad_typeid& e)
+  {
+    return EXIT_SUCCESS;
+  }
+
+  return EXIT_FAILURE;
+}
-- 
1.6.0.4