From 76ddb8091266741ae046d1b6fdeef4f782617d5b Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 17 Jan 2012 14:08:09 -0800 Subject: libc++ sources --- system/lib/libcxx/algorithm.cpp | 83 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 system/lib/libcxx/algorithm.cpp (limited to 'system/lib/libcxx/algorithm.cpp') 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*, __less&); +template void __sort<__less&, wchar_t*>(wchar_t*, wchar_t*, __less&); +template void __sort<__less&, signed char*>(signed char*, signed char*, __less&); +template void __sort<__less&, unsigned char*>(unsigned char*, unsigned char*, __less&); +template void __sort<__less&, short*>(short*, short*, __less&); +template void __sort<__less&, unsigned short*>(unsigned short*, unsigned short*, __less&); +template void __sort<__less&, int*>(int*, int*, __less&); +template void __sort<__less&, unsigned*>(unsigned*, unsigned*, __less&); +template void __sort<__less&, long*>(long*, long*, __less&); +template void __sort<__less&, unsigned long*>(unsigned long*, unsigned long*, __less&); +template void __sort<__less&, long long*>(long long*, long long*, __less&); +template void __sort<__less&, unsigned long long*>(unsigned long long*, unsigned long long*, __less&); +template void __sort<__less&, float*>(float*, float*, __less&); +template void __sort<__less&, double*>(double*, double*, __less&); +template void __sort<__less&, long double*>(long double*, long double*, __less&); + +template bool __insertion_sort_incomplete<__less&, char*>(char*, char*, __less&); +template bool __insertion_sort_incomplete<__less&, wchar_t*>(wchar_t*, wchar_t*, __less&); +template bool __insertion_sort_incomplete<__less&, signed char*>(signed char*, signed char*, __less&); +template bool __insertion_sort_incomplete<__less&, unsigned char*>(unsigned char*, unsigned char*, __less&); +template bool __insertion_sort_incomplete<__less&, short*>(short*, short*, __less&); +template bool __insertion_sort_incomplete<__less&, unsigned short*>(unsigned short*, unsigned short*, __less&); +template bool __insertion_sort_incomplete<__less&, int*>(int*, int*, __less&); +template bool __insertion_sort_incomplete<__less&, unsigned*>(unsigned*, unsigned*, __less&); +template bool __insertion_sort_incomplete<__less&, long*>(long*, long*, __less&); +template bool __insertion_sort_incomplete<__less&, unsigned long*>(unsigned long*, unsigned long*, __less&); +template bool __insertion_sort_incomplete<__less&, long long*>(long long*, long long*, __less&); +template bool __insertion_sort_incomplete<__less&, unsigned long long*>(unsigned long long*, unsigned long long*, __less&); +template bool __insertion_sort_incomplete<__less&, float*>(float*, float*, __less&); +template bool __insertion_sort_incomplete<__less&, double*>(double*, double*, __less&); +template bool __insertion_sort_incomplete<__less&, long double*>(long double*, long double*, __less&); + +template unsigned __sort5<__less&, long double*>(long double*, long double*, long double*, long double*, long double*, __less&); + +static pthread_mutex_t __rs_mut = PTHREAD_MUTEX_INITIALIZER; +unsigned __rs_default::__c_ = 0; + +__rs_default::__rs_default() +{ + pthread_mutex_lock(&__rs_mut); + __c_ = 1; +} + +__rs_default::__rs_default(const __rs_default&) +{ + ++__c_; +} + +__rs_default::~__rs_default() +{ + if (--__c_ == 0) + pthread_mutex_unlock(&__rs_mut); +} + +__rs_default::result_type +__rs_default::operator()() +{ + static mt19937 __rs_g; + return __rs_g(); +} + +__rs_default +__rs_get() +{ + return __rs_default(); +} + +_LIBCPP_END_NAMESPACE_STD -- cgit v1.2.3-18-g5258