17a984708SDavid Chisnall //===----------------------- algorithm.cpp --------------------------------===//
27a984708SDavid Chisnall //
37a984708SDavid Chisnall //                     The LLVM Compiler Infrastructure
47a984708SDavid Chisnall //
57a984708SDavid Chisnall // This file is dual licensed under the MIT and the University of Illinois Open
67a984708SDavid Chisnall // Source Licenses. See LICENSE.TXT for details.
77a984708SDavid Chisnall //
87a984708SDavid Chisnall //===----------------------------------------------------------------------===//
97a984708SDavid Chisnall 
107a984708SDavid Chisnall #include "algorithm"
117a984708SDavid Chisnall #include "random"
127a984708SDavid Chisnall #include "mutex"
137a984708SDavid Chisnall 
147a984708SDavid Chisnall _LIBCPP_BEGIN_NAMESPACE_STD
157a984708SDavid Chisnall 
167a984708SDavid Chisnall template void __sort<__less<char>&, char*>(char*, char*, __less<char>&);
177a984708SDavid Chisnall template void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
187a984708SDavid Chisnall template void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&);
197a984708SDavid Chisnall template void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&);
207a984708SDavid Chisnall template void __sort<__less<short>&, short*>(short*, short*, __less<short>&);
217a984708SDavid Chisnall template void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&);
227a984708SDavid Chisnall template void __sort<__less<int>&, int*>(int*, int*, __less<int>&);
237a984708SDavid Chisnall template void __sort<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&);
247a984708SDavid Chisnall template void __sort<__less<long>&, long*>(long*, long*, __less<long>&);
257a984708SDavid Chisnall template void __sort<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&);
267a984708SDavid Chisnall template void __sort<__less<long long>&, long long*>(long long*, long long*, __less<long long>&);
277a984708SDavid Chisnall template void __sort<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&);
287a984708SDavid Chisnall template void __sort<__less<float>&, float*>(float*, float*, __less<float>&);
297a984708SDavid Chisnall template void __sort<__less<double>&, double*>(double*, double*, __less<double>&);
307a984708SDavid Chisnall template void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&);
317a984708SDavid Chisnall 
327a984708SDavid Chisnall template bool __insertion_sort_incomplete<__less<char>&, char*>(char*, char*, __less<char>&);
337a984708SDavid Chisnall template bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
347a984708SDavid Chisnall template bool __insertion_sort_incomplete<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&);
357a984708SDavid Chisnall template bool __insertion_sort_incomplete<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&);
367a984708SDavid Chisnall template bool __insertion_sort_incomplete<__less<short>&, short*>(short*, short*, __less<short>&);
377a984708SDavid Chisnall template bool __insertion_sort_incomplete<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&);
387a984708SDavid Chisnall template bool __insertion_sort_incomplete<__less<int>&, int*>(int*, int*, __less<int>&);
397a984708SDavid Chisnall template bool __insertion_sort_incomplete<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&);
407a984708SDavid Chisnall template bool __insertion_sort_incomplete<__less<long>&, long*>(long*, long*, __less<long>&);
417a984708SDavid Chisnall template bool __insertion_sort_incomplete<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&);
427a984708SDavid Chisnall template bool __insertion_sort_incomplete<__less<long long>&, long long*>(long long*, long long*, __less<long long>&);
437a984708SDavid Chisnall template bool __insertion_sort_incomplete<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&);
447a984708SDavid Chisnall template bool __insertion_sort_incomplete<__less<float>&, float*>(float*, float*, __less<float>&);
457a984708SDavid Chisnall template bool __insertion_sort_incomplete<__less<double>&, double*>(double*, double*, __less<double>&);
467a984708SDavid Chisnall template bool __insertion_sort_incomplete<__less<long double>&, long double*>(long double*, long double*, __less<long double>&);
477a984708SDavid Chisnall 
487a984708SDavid Chisnall template unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&);
497a984708SDavid Chisnall 
50d72607e9SDimitry Andric #ifndef _LIBCPP_HAS_NO_THREADS
51*aed8d94eSDimitry Andric _LIBCPP_SAFE_STATIC static __libcpp_mutex_t __rs_mut = _LIBCPP_MUTEX_INITIALIZER;
52d72607e9SDimitry Andric #endif
537a984708SDavid Chisnall unsigned __rs_default::__c_ = 0;
547a984708SDavid Chisnall 
__rs_default()557a984708SDavid Chisnall __rs_default::__rs_default()
567a984708SDavid Chisnall {
57d72607e9SDimitry Andric #ifndef _LIBCPP_HAS_NO_THREADS
587c82a1ecSDimitry Andric     __libcpp_mutex_lock(&__rs_mut);
59d72607e9SDimitry Andric #endif
607a984708SDavid Chisnall     __c_ = 1;
617a984708SDavid Chisnall }
627a984708SDavid Chisnall 
__rs_default(const __rs_default &)637a984708SDavid Chisnall __rs_default::__rs_default(const __rs_default&)
647a984708SDavid Chisnall {
657a984708SDavid Chisnall     ++__c_;
667a984708SDavid Chisnall }
677a984708SDavid Chisnall 
~__rs_default()687a984708SDavid Chisnall __rs_default::~__rs_default()
697a984708SDavid Chisnall {
70d72607e9SDimitry Andric #ifndef _LIBCPP_HAS_NO_THREADS
717a984708SDavid Chisnall     if (--__c_ == 0)
727c82a1ecSDimitry Andric        __libcpp_mutex_unlock(&__rs_mut);
73d72607e9SDimitry Andric #else
74d72607e9SDimitry Andric     --__c_;
75d72607e9SDimitry Andric #endif
767a984708SDavid Chisnall }
777a984708SDavid Chisnall 
787a984708SDavid Chisnall __rs_default::result_type
operator ()()797a984708SDavid Chisnall __rs_default::operator()()
807a984708SDavid Chisnall {
817a984708SDavid Chisnall     static mt19937 __rs_g;
827a984708SDavid Chisnall     return __rs_g();
837a984708SDavid Chisnall }
847a984708SDavid Chisnall 
857a984708SDavid Chisnall __rs_default
__rs_get()867a984708SDavid Chisnall __rs_get()
877a984708SDavid Chisnall {
887a984708SDavid Chisnall     return __rs_default();
897a984708SDavid Chisnall }
907a984708SDavid Chisnall 
917a984708SDavid Chisnall _LIBCPP_END_NAMESPACE_STD
92