blob: f036eb7abe1c5ee80576a9a5d0f9effc85af7518 [file] [log] [blame]
Howard Hinnantc51e1022010-05-11 19:42:16 +00001//===----------------------- algorithm.cpp --------------------------------===//
2//
Howard Hinnantc566dc32010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnantc51e1022010-05-11 19:42:16 +00004//
Howard Hinnantee11c312010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantc51e1022010-05-11 19:42:16 +00007//
8//===----------------------------------------------------------------------===//
9
10#include "algorithm"
Howard Hinnant578ac0f2010-05-26 17:49:34 +000011#include "random"
12#include "mutex"
Howard Hinnantc51e1022010-05-11 19:42:16 +000013
14_LIBCPP_BEGIN_NAMESPACE_STD
15
16template void __sort<__less<char>&, char*>(char*, char*, __less<char>&);
17template void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
18template void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&);
19template void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&);
20template void __sort<__less<short>&, short*>(short*, short*, __less<short>&);
21template void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&);
22template void __sort<__less<int>&, int*>(int*, int*, __less<int>&);
23template void __sort<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&);
24template void __sort<__less<long>&, long*>(long*, long*, __less<long>&);
25template void __sort<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&);
26template void __sort<__less<long long>&, long long*>(long long*, long long*, __less<long long>&);
27template void __sort<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&);
28template void __sort<__less<float>&, float*>(float*, float*, __less<float>&);
29template void __sort<__less<double>&, double*>(double*, double*, __less<double>&);
30template void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&);
31
32template bool __insertion_sort_incomplete<__less<char>&, char*>(char*, char*, __less<char>&);
33template bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
34template bool __insertion_sort_incomplete<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&);
35template bool __insertion_sort_incomplete<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&);
36template bool __insertion_sort_incomplete<__less<short>&, short*>(short*, short*, __less<short>&);
37template bool __insertion_sort_incomplete<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&);
38template bool __insertion_sort_incomplete<__less<int>&, int*>(int*, int*, __less<int>&);
39template bool __insertion_sort_incomplete<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&);
40template bool __insertion_sort_incomplete<__less<long>&, long*>(long*, long*, __less<long>&);
41template bool __insertion_sort_incomplete<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&);
42template bool __insertion_sort_incomplete<__less<long long>&, long long*>(long long*, long long*, __less<long long>&);
43template bool __insertion_sort_incomplete<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&);
44template bool __insertion_sort_incomplete<__less<float>&, float*>(float*, float*, __less<float>&);
45template bool __insertion_sort_incomplete<__less<double>&, double*>(double*, double*, __less<double>&);
46template bool __insertion_sort_incomplete<__less<long double>&, long double*>(long double*, long double*, __less<long double>&);
47
48template unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&);
49
Jonathan Roelofs39cb6bf2014-09-05 19:45:05 +000050#ifndef _LIBCPP_HAS_NO_THREADS
Eric Fiselier637dd952016-09-28 22:08:13 +000051_LIBCPP_SAFE_STATIC static __libcpp_mutex_t __rs_mut = _LIBCPP_MUTEX_INITIALIZER;
Jonathan Roelofs39cb6bf2014-09-05 19:45:05 +000052#endif
Howard Hinnant578ac0f2010-05-26 17:49:34 +000053unsigned __rs_default::__c_ = 0;
54
55__rs_default::__rs_default()
56{
Jonathan Roelofs39cb6bf2014-09-05 19:45:05 +000057#ifndef _LIBCPP_HAS_NO_THREADS
Asiri Rathnayakefa2e2032016-05-06 14:06:29 +000058 __libcpp_mutex_lock(&__rs_mut);
Jonathan Roelofs39cb6bf2014-09-05 19:45:05 +000059#endif
Howard Hinnant578ac0f2010-05-26 17:49:34 +000060 __c_ = 1;
61}
62
63__rs_default::__rs_default(const __rs_default&)
64{
65 ++__c_;
66}
67
68__rs_default::~__rs_default()
69{
Jonathan Roelofs39cb6bf2014-09-05 19:45:05 +000070#ifndef _LIBCPP_HAS_NO_THREADS
Howard Hinnant578ac0f2010-05-26 17:49:34 +000071 if (--__c_ == 0)
Asiri Rathnayakefa2e2032016-05-06 14:06:29 +000072 __libcpp_mutex_unlock(&__rs_mut);
Jonathan Roelofs39cb6bf2014-09-05 19:45:05 +000073#else
74 --__c_;
75#endif
Howard Hinnant578ac0f2010-05-26 17:49:34 +000076}
77
78__rs_default::result_type
79__rs_default::operator()()
80{
81 static mt19937 __rs_g;
82 return __rs_g();
83}
84
85__rs_default
86__rs_get()
87{
88 return __rs_default();
89}
90
Howard Hinnantc51e1022010-05-11 19:42:16 +000091_LIBCPP_END_NAMESPACE_STD