aboutsummaryrefslogtreecommitdiff
path: root/system
diff options
context:
space:
mode:
Diffstat (limited to 'system')
-rw-r--r--system/include/libc/locale.h9
-rw-r--r--system/include/libc/pthread.h4
-rw-r--r--system/include/libc/sys/types.h2
-rw-r--r--system/include/libc/time.h2
-rw-r--r--system/include/libcxx/__locale10
-rw-r--r--system/include/libcxx/exception14
-rw-r--r--system/include/libcxx/ios8
-rw-r--r--system/include/libcxx/locale14
-rw-r--r--system/include/libcxx/mutex1
-rw-r--r--system/include/libcxx/ostream9
-rw-r--r--system/include/libcxx/streambuf9
-rw-r--r--system/include/libcxx/string6
-rw-r--r--system/include/nl_types.h19
-rw-r--r--system/include/sys/sysctl.h14
-rw-r--r--system/include/xlocale.h39
-rw-r--r--system/lib/libcxx/LICENSE.txt76
-rw-r--r--system/lib/libcxx/Makefile35
-rw-r--r--system/lib/libcxx/algorithm.cpp83
-rw-r--r--system/lib/libcxx/bind.cpp30
-rw-r--r--system/lib/libcxx/chrono.cpp128
-rw-r--r--system/lib/libcxx/condition_variable.cpp70
-rw-r--r--system/lib/libcxx/debug.cpp473
-rw-r--r--system/lib/libcxx/exception.cpp206
-rw-r--r--system/lib/libcxx/future.cpp285
-rw-r--r--system/lib/libcxx/hash.cpp559
-rw-r--r--system/lib/libcxx/ios.cpp455
-rw-r--r--system/lib/libcxx/iostream.cpp53
-rw-r--r--system/lib/libcxx/locale.cpp5838
-rw-r--r--system/lib/libcxx/memory.cpp168
-rw-r--r--system/lib/libcxx/mutex.cpp250
-rw-r--r--system/lib/libcxx/new.cpp185
-rw-r--r--system/lib/libcxx/random.cpp45
-rw-r--r--system/lib/libcxx/readme.txt1
-rw-r--r--system/lib/libcxx/regex.cpp315
-rw-r--r--system/lib/libcxx/stdexcept.cpp178
-rw-r--r--system/lib/libcxx/string.cpp679
-rw-r--r--system/lib/libcxx/strstream.cpp327
-rw-r--r--system/lib/libcxx/symbols3129
-rw-r--r--system/lib/libcxx/system_error.cpp201
-rw-r--r--system/lib/libcxx/thread.cpp183
-rw-r--r--system/lib/libcxx/typeinfo.cpp50
-rw-r--r--system/lib/libcxx/utility.cpp16
-rw-r--r--system/lib/libcxx/valarray.cpp54
43 files changed, 14187 insertions, 45 deletions
diff --git a/system/include/libc/locale.h b/system/include/libc/locale.h
index 532faaa5..b75bed7a 100644
--- a/system/include/libc/locale.h
+++ b/system/include/libc/locale.h
@@ -21,6 +21,15 @@
#define LC_TIME 5
#define LC_MESSAGES 6
+/* XXX Emscripten: add masks */
+#define LC_ALL_MASK (1 << LC_ALL)
+#define LC_COLLATE_MASK (1 << LC_COLLATE)
+#define LC_CTYPE_MASK (1 << LC_CTYPE)
+#define LC_MONETARY_MASK (1 << LC_MONETARY)
+#define LC_NUMERIC_MASK (1 << LC_NUMERIC)
+#define LC_TIME_MASK (1 << LC_TIME)
+#define LC_MESSAGES_MASK (1 << LC_MESSAGES)
+
_BEGIN_STD_C
struct lconv
diff --git a/system/include/libc/pthread.h b/system/include/libc/pthread.h
index 63bb6dfa..1185fcc1 100644
--- a/system/include/libc/pthread.h
+++ b/system/include/libc/pthread.h
@@ -31,7 +31,7 @@ extern "C" {
#include <sys/types.h>
#include <time.h>
-#include <sys/sched.h>
+#include <sched.h> /* XXX Emscripten: removed sys/ */
/* Register Fork Handlers */
int _EXFUN(pthread_atfork,(void (*prepare)(void), void (*parent)(void),
@@ -46,7 +46,7 @@ int _EXFUN(pthread_mutexattr_getpshared,
int _EXFUN(pthread_mutexattr_setpshared,
(pthread_mutexattr_t *__attr, int __pshared));
-#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES)
+#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES) || defined(EMSCRIPTEN)
/* Single UNIX Specification 2 Mutex Attributes types */
diff --git a/system/include/libc/sys/types.h b/system/include/libc/sys/types.h
index 5cb126a7..734004e7 100644
--- a/system/include/libc/sys/types.h
+++ b/system/include/libc/sys/types.h
@@ -300,7 +300,7 @@ typedef __uint32_t pthread_t; /* identify a thread */
#define PTHREAD_CREATE_DETACHED 0
#define PTHREAD_CREATE_JOINABLE 1
-#if defined(__XMK__) || defined(__rtems__)
+#if defined(__XMK__) || defined(__rtems__) || defined(EMSCRIPTEN)
/* The following defines are part of the X/Open System Interface (XSI). */
/* This type of mutex does not detect deadlock. A thread attempting to relock this mutex without first unlocking
diff --git a/system/include/libc/time.h b/system/include/libc/time.h
index 3f167556..83993942 100644
--- a/system/include/libc/time.h
+++ b/system/include/libc/time.h
@@ -229,7 +229,7 @@ extern "C" {
#endif
-#if defined(_POSIX_MONOTONIC_CLOCK)
+#if defined(_POSIX_MONOTONIC_CLOCK) || defined(EMSCRIPTEN)
/* The identifier for the system-wide monotonic clock, which is defined
* as a clock whose value cannot be set via clock_settime() and which
diff --git a/system/include/libcxx/__locale b/system/include/libcxx/__locale
index b1c0dd7c..f63815c3 100644
--- a/system/include/libcxx/__locale
+++ b/system/include/libcxx/__locale
@@ -8,8 +8,6 @@
//
//===----------------------------------------------------------------------===//
-//class locale; // XXX Emscripten
-
#ifndef _LIBCPP___LOCALE
#define _LIBCPP___LOCALE
@@ -24,7 +22,7 @@
#if _WIN32
# include <support/win32/locale.h>
#else // _WIN32
-/* XXX EMSCRIPTEN # include <xlocale.h> */
+# include <xlocale.h>
#endif // _WIN32
#pragma GCC system_header
@@ -44,7 +42,6 @@ public:
class id;
typedef int category;
- /* XXX Emscripten
static const category // values assigned here are for exposition only
none = 0,
collate = LC_COLLATE_MASK,
@@ -54,7 +51,6 @@ public:
time = LC_TIME_MASK,
messages = LC_MESSAGES_MASK,
all = collate | ctype | monetary | numeric | time | messages;
- */
// construct/copy/destroy:
locale() _NOEXCEPT;
@@ -335,9 +331,9 @@ public:
static const mask xdigit = _HEX;
static const mask blank = _BLANK;
#else // __GLIBC__ || _WIN32
-#if __APPLE__
+#if defined(__APPLE__) || defined(EMSCRIPTEN)
typedef __uint32_t mask;
-#elif defined(__FreeBSD__) or defined(EMSCRIPTEN)
+#elif __FreeBSD__
typedef unsigned long mask;
#endif
static const mask space = _CTYPE_S;
diff --git a/system/include/libcxx/exception b/system/include/libcxx/exception
index f05855b4..f418575c 100644
--- a/system/include/libcxx/exception
+++ b/system/include/libcxx/exception
@@ -89,7 +89,7 @@ class _LIBCPP_EXCEPTION_ABI exception
{
public:
_LIBCPP_INLINE_VISIBILITY exception() _NOEXCEPT {}
- virtual ~exception() _NOEXCEPT{}
+ virtual ~exception() _NOEXCEPT;
virtual const char* what() const _NOEXCEPT;
};
@@ -105,19 +105,19 @@ public:
typedef void (*unexpected_handler)();
_LIBCPP_VISIBLE unexpected_handler set_unexpected(unexpected_handler) _NOEXCEPT;
_LIBCPP_VISIBLE unexpected_handler get_unexpected() _NOEXCEPT;
-_LIBCPP_VISIBLE void unexpected(); /* XXX Emscripten: remove _ATTRIBUTE(noreturn), here and two places below */
+_ATTRIBUTE(noreturn) _LIBCPP_VISIBLE void unexpected();
typedef void (*terminate_handler)();
_LIBCPP_VISIBLE terminate_handler set_terminate(terminate_handler) _NOEXCEPT;
_LIBCPP_VISIBLE terminate_handler get_terminate() _NOEXCEPT;
-_LIBCPP_VISIBLE void terminate() _NOEXCEPT;
+_ATTRIBUTE(noreturn) _LIBCPP_VISIBLE void terminate() _NOEXCEPT;
_LIBCPP_VISIBLE bool uncaught_exception() _NOEXCEPT;
class exception_ptr;
exception_ptr current_exception() _NOEXCEPT;
-void rethrow_exception(exception_ptr);
+_ATTRIBUTE(noreturn) void rethrow_exception(exception_ptr);
class _LIBCPP_VISIBLE exception_ptr
{
@@ -141,7 +141,7 @@ public:
{return !(__x == __y);}
friend exception_ptr current_exception() _NOEXCEPT;
- friend void rethrow_exception(exception_ptr);
+ _ATTRIBUTE(noreturn) friend void rethrow_exception(exception_ptr);
};
template<class _E>
@@ -172,7 +172,7 @@ public:
virtual ~nested_exception() _NOEXCEPT;
// access functions
- void rethrow_nested() const;
+ _ATTRIBUTE(noreturn) void rethrow_nested() const;
_LIBCPP_INLINE_VISIBILITY exception_ptr nested_ptr() const _NOEXCEPT {return __ptr_;}
};
@@ -185,6 +185,7 @@ struct __nested
};
template <class _Tp>
+_ATTRIBUTE(noreturn)
void
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
throw_with_nested(_Tp&& __t, typename enable_if<
@@ -203,6 +204,7 @@ throw_with_nested (_Tp& __t, typename enable_if<
}
template <class _Tp>
+_ATTRIBUTE(noreturn)
void
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
throw_with_nested(_Tp&& __t, typename enable_if<
diff --git a/system/include/libcxx/ios b/system/include/libcxx/ios
index 29bda558..e2f2b6fd 100644
--- a/system/include/libcxx/ios
+++ b/system/include/libcxx/ios
@@ -317,7 +317,7 @@ public:
_LIBCPP_INLINE_VISIBILITY bool bad() const;
_LIBCPP_INLINE_VISIBILITY iostate exceptions() const;
- _LIBCPP_INLINE_VISIBILITY void exceptions(iostate except); /* XXX Emscripten: renammed __except to except because it is a reserved keyword */
+ _LIBCPP_INLINE_VISIBILITY void exceptions(iostate __except);
void __set_badbit_and_consider_rethrow();
void __set_failbit_and_consider_rethrow();
@@ -553,9 +553,9 @@ ios_base::exceptions() const
inline _LIBCPP_INLINE_VISIBILITY
void
-ios_base::exceptions(iostate except) /* XXX Emscripten: renammed __except to except because it is a reserved keyword */
+ios_base::exceptions(iostate __except)
{
- __exceptions_ = except; /* XXX Emscripten: renammed __except to except because it is a reserved keyword */
+ __exceptions_ = __except;
clear(__rdstate_);
}
@@ -584,7 +584,7 @@ public:
_LIBCPP_ALWAYS_INLINE bool bad() const {return ios_base::bad();}
_LIBCPP_ALWAYS_INLINE iostate exceptions() const {return ios_base::exceptions();}
- _LIBCPP_ALWAYS_INLINE void exceptions(iostate except) {ios_base::exceptions(except);} /* XXX Emscripten: renammed __except to except because it is a reserved keyword */
+ _LIBCPP_ALWAYS_INLINE void exceptions(iostate __except) {ios_base::exceptions(__except);}
// 27.5.4.1 Constructor/destructor:
_LIBCPP_INLINE_VISIBILITY
diff --git a/system/include/libcxx/locale b/system/include/libcxx/locale
index 153038ee..e9a18e32 100644
--- a/system/include/libcxx/locale
+++ b/system/include/libcxx/locale
@@ -189,7 +189,7 @@ template <class charT> class messages_byname;
#if _WIN32
#include <support/win32/support.h> // vasprintf
#else // _WIN32
-// XXX Emscripten #include <nl_types.h>
+#include <nl_types.h>
#endif // !_WIN32
#pragma GCC system_header
@@ -800,7 +800,6 @@ template <class _CharT, class _InputIterator>
locale::id
num_get<_CharT, _InputIterator>::id;
-/* XXX Emscripten
template <class _Tp>
_Tp
__num_get_signed_integral(const char* __a, const char* __a_end,
@@ -1308,8 +1307,6 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
return __b;
}
-*/
-
extern template class num_get<char>;
extern template class num_get<wchar_t>;
@@ -1392,7 +1389,7 @@ void
__num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne,
_CharT* __ob, _CharT*& __op, _CharT*& __oe,
const locale& __loc)
-;/* XXX Emscripten {
+{
const ctype<_CharT>& __ct = use_facet<ctype<_CharT> > (__loc);
const numpunct<_CharT>& __npt = use_facet<numpunct<_CharT> >(__loc);
string __grouping = __npt.grouping();
@@ -1467,7 +1464,6 @@ __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne,
else
__op = __ob + (__np - __nb);
}
-*/
extern template class __num_put<char>;
extern template class __num_put<wchar_t>;
@@ -3717,7 +3713,7 @@ template <class _CharT>
typename messages<_CharT>::catalog
messages<_CharT>::do_open(const basic_string<char>& __nm, const locale&) const
{
-#if defined(_WIN32) || defined(EMSCRIPTEN)
+#if _WIN32
return -1;
#else // _WIN32
catalog __cat = reinterpret_cast<catalog>(catopen(__nm.c_str(), NL_CAT_LOCALE));
@@ -3732,7 +3728,7 @@ typename messages<_CharT>::string_type
messages<_CharT>::do_get(catalog __c, int __set, int __msgid,
const string_type& __dflt) const
{
-#if defined(_WIN32) || defined(EMSCRIPTEN)
+#if _WIN32
return __dflt;
#else // _WIN32
string __ndflt;
@@ -3754,7 +3750,7 @@ template <class _CharT>
void
messages<_CharT>::do_close(catalog __c) const
{
-#if !defined(_WIN32) && !defined(EMSCRIPTEN)
+#if !_WIN32
if (__c != -1)
__c <<= 1;
nl_catd __cat = reinterpret_cast<nl_catd>(__c);
diff --git a/system/include/libcxx/mutex b/system/include/libcxx/mutex
index b79201a5..297baca5 100644
--- a/system/include/libcxx/mutex
+++ b/system/include/libcxx/mutex
@@ -178,7 +178,6 @@ template<class Callable, class ...Args>
#ifndef _LIBCPP_HAS_NO_VARIADICS
#include <tuple>
#endif
-#include "sched.h" /* XXX Emscripten */
#pragma GCC system_header
diff --git a/system/include/libcxx/ostream b/system/include/libcxx/ostream
index f7cbb8a2..f1a3de9c 100644
--- a/system/include/libcxx/ostream
+++ b/system/include/libcxx/ostream
@@ -204,7 +204,6 @@ protected:
basic_ostream() {} // extension, intentially does not initialize
};
-/*
template <class _CharT, class _Traits>
class _LIBCPP_VISIBLE basic_ostream<_CharT, _Traits>::sentry
{
@@ -1181,7 +1180,6 @@ basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir)
return *this;
}
-*/
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_ostream<_CharT, _Traits>&
@@ -1210,7 +1208,6 @@ flush(basic_ostream<_CharT, _Traits>& __os)
return __os;
}
-/*
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _Stream, class _Tp>
@@ -1287,9 +1284,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x)
(use_facet<ctype<_CharT> >(__os.getloc()).widen('0'),
use_facet<ctype<_CharT> >(__os.getloc()).widen('1'));
}
-*/
-//extern template class basic_ostream<char>; /* XXX EMScripten */
-//extern template class basic_ostream<wchar_t>; /* XXX EMScripten */
+
+extern template class basic_ostream<char>;
+extern template class basic_ostream<wchar_t>;
_LIBCPP_END_NAMESPACE_STD
diff --git a/system/include/libcxx/streambuf b/system/include/libcxx/streambuf
index 20ae24f3..feb62c7e 100644
--- a/system/include/libcxx/streambuf
+++ b/system/include/libcxx/streambuf
@@ -111,7 +111,6 @@ protected:
#include <__config>
#include <iosfwd>
#include <ios>
-#include <__locale>
#pragma GCC system_header
@@ -552,11 +551,11 @@ basic_streambuf<_CharT, _Traits>::overflow(int_type __c)
return traits_type::eof();
}
-//extern template class basic_streambuf<char>; /* XXX EMScripten */
-//extern template class basic_streambuf<wchar_t>; /* XXX EMScripten */
+extern template class basic_streambuf<char>;
+extern template class basic_streambuf<wchar_t>;
-//extern template class basic_ios<char>; /* XXX EMScripten */
-//extern template class basic_ios<wchar_t>; /* XXX EMScripten */
+extern template class basic_ios<char>;
+extern template class basic_ios<wchar_t>;
_LIBCPP_END_NAMESPACE_STD
diff --git a/system/include/libcxx/string b/system/include/libcxx/string
index 4f3e0e76..2041510f 100644
--- a/system/include/libcxx/string
+++ b/system/include/libcxx/string
@@ -1021,7 +1021,7 @@ __basic_string_common<__b>::__throw_out_of_range() const
#endif
}
-//extern template class __basic_string_common<true>; /* XXX EMScripten: Comment to export the class */
+extern template class __basic_string_common<true>;
template<class _CharT, class _Traits, class _Allocator>
class _LIBCPP_VISIBLE basic_string
@@ -3965,8 +3965,8 @@ getline(basic_istream<_CharT, _Traits>&& __is,
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-//extern template class basic_string<char>; /* XXX EMScripten: Comment to export the class */
-//extern template class basic_string<wchar_t>; /* XXX EMScripten: Comment to export the class */
+extern template class basic_string<char>;
+extern template class basic_string<wchar_t>;
extern template
string
diff --git a/system/include/nl_types.h b/system/include/nl_types.h
new file mode 100644
index 00000000..818e9af8
--- /dev/null
+++ b/system/include/nl_types.h
@@ -0,0 +1,19 @@
+
+#ifndef _NL_TYPES_H_
+#define _NL_TYPES_H_
+
+typedef struct _nl_catd {
+ void *data;
+ int size;
+} *nl_catd;
+typedef int nl_item;
+
+#define NL_SETD 100
+#define NL_CAT_LOCALE 200
+
+nl_catd catopen(const char *, int);
+int catclose(nl_catd);
+char *catgets(nl_catd, int, int, const char *);
+
+#endif
+
diff --git a/system/include/sys/sysctl.h b/system/include/sys/sysctl.h
new file mode 100644
index 00000000..2863201a
--- /dev/null
+++ b/system/include/sys/sysctl.h
@@ -0,0 +1,14 @@
+
+#ifndef _SYS_POLL_H
+#define _SYS_POLL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/system/include/xlocale.h b/system/include/xlocale.h
new file mode 100644
index 00000000..1162f9b0
--- /dev/null
+++ b/system/include/xlocale.h
@@ -0,0 +1,39 @@
+
+#ifndef _XLOCALE_H_
+#define _XLOCALE_H_
+
+#include <string.h>
+#include <locale.h>
+
+long long strtoll_l(const char *start, char **end, int base, locale_t loc);
+unsigned long long strtoull_l(const char *start, char **end, int base, locale_t loc);
+double strtold_l(const char *start, char **end, locale_t loc);
+
+int strcoll_l(const char *s1, const char *s2, locale_t locale);
+int wcscoll_l(const wchar_t *ws1, const wchar_t *ws2, locale_t locale);
+
+size_t strxfrm_l(char *s1, const char *s2, size_t n, locale_t locale);
+size_t wcsxfrm_l(wchar_t *ws1, const wchar_t *ws2, size_t n, locale_t locale);
+
+int isxdigit_l(int c, locale_t locale);
+int isdigit_l(int c, locale_t locale);
+int toupper_l(int c, locale_t locale);
+int tolower_l(int c, locale_t locale);
+
+int iswspace_l(wint_t wc, locale_t locale);
+int iswupper_l(wint_t wc, locale_t locale);
+int iswlower_l(wint_t wc, locale_t locale);
+int iswprint_l(wint_t wc, locale_t locale);
+int iswcntrl_l(wint_t wc, locale_t locale);
+int iswalpha_l(wint_t wc, locale_t locale);
+int iswdigit_l(wint_t wc, locale_t locale);
+int iswpunct_l(wint_t wc, locale_t locale);
+int iswblank_l(wint_t wc, locale_t locale);
+int iswxdigit_l(wint_t wc, locale_t locale);
+int towupper_l(wint_t wc, locale_t locale);
+int towlower_l(wint_t wc, locale_t locale);
+
+size_t strftime_l(char *s, size_t maxsize, const char *format, const struct tm *timeptr, locale_t locale);
+
+#endif /* _LOCALE_H_ */
+
diff --git a/system/lib/libcxx/LICENSE.txt b/system/lib/libcxx/LICENSE.txt
new file mode 100644
index 00000000..926f0676
--- /dev/null
+++ b/system/lib/libcxx/LICENSE.txt
@@ -0,0 +1,76 @@
+==============================================================================
+libc++ License
+==============================================================================
+
+The libc++ library is dual licensed under both the University of Illinois
+"BSD-Like" license and the MIT license. As a user of this code you may choose
+to use it under either license. As a contributor, you agree to allow your code
+to be used under both.
+
+Full text of the relevant licenses is included below.
+
+==============================================================================
+
+University of Illinois/NCSA
+Open Source License
+
+Copyright (c) 2009-2010 by the contributors listed in CREDITS.TXT
+
+All rights reserved.
+
+Developed by:
+
+ LLVM Team
+
+ University of Illinois at Urbana-Champaign
+
+ http://llvm.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal with
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimers.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimers in the
+ documentation and/or other materials provided with the distribution.
+
+ * Neither the names of the LLVM Team, University of Illinois at
+ Urbana-Champaign, nor the names of its contributors may be used to
+ endorse or promote products derived from this Software without specific
+ prior written permission.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
+SOFTWARE.
+
+==============================================================================
+
+Copyright (c) 2009-2010 by the contributors listed in CREDITS.TXT
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/system/lib/libcxx/Makefile b/system/lib/libcxx/Makefile
new file mode 100644
index 00000000..432ba492
--- /dev/null
+++ b/system/lib/libcxx/Makefile
@@ -0,0 +1,35 @@
+OBJECTS = \
+ algorithm.bc \
+ condition_variable.bc \
+ future.bc \
+ iostream.bc \
+ memory.bc \
+ random.bc \
+ stdexcept.bc \
+ system_error.bc \
+ utility.bc \
+ bind.bc \
+ debug.bc \
+ hash.bc \
+ mutex.bc \
+ readme.txt \
+ string.bc \
+ thread.bc \
+ valarray.bc \
+ chrono.bc \
+ exception.bc \
+ ios.bc \
+ locale.bc \
+ new.bc \
+ regex.bc \
+ strstream.bc \
+ typeinfo.bc
+
+all: libcxx.bc
+
+%.bc: %.cpp
+ $(CXX) $< -o $@
+
+libcxx.bc: $(OBJECTS)
+ $(CXX) $(OBJECTS) -o libcxx.bc
+
diff --git a/system/lib/libcxx/algorithm.cpp b/system/lib/libcxx/algorithm.cpp
new file mode 100644
index 00000000..6d5cf7c0
--- /dev/null
+++ b/system/lib/libcxx/algorithm.cpp
@@ -0,0 +1,83 @@
+//===----------------------- algorithm.cpp --------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "algorithm"
+#include "random"
+#include "mutex"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template void __sort<__less<char>&, char*>(char*, char*, __less<char>&);
+template void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
+template void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&);
+template void __sort<__less<unsigned char>&, unsigned char*>(unsigned