blob: 28e452f52df1252b46fed633e7e3e4123883a452 [file] [log] [blame]
Howard Hinnantc51e1022010-05-11 19:42:16 +00001//===----------------------- algorithm.cpp --------------------------------===//
2//
Chandler Carruthd2012102019-01-19 10:56:40 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Howard Hinnantc51e1022010-05-11 19:42:16 +00006//
7//===----------------------------------------------------------------------===//
8
9#include "algorithm"
Howard Hinnant578ac0f2010-05-26 17:49:34 +000010#include "random"
11#include "mutex"
Howard Hinnantc51e1022010-05-11 19:42:16 +000012
13_LIBCPP_BEGIN_NAMESPACE_STD
14
15template void __sort<__less<char>&, char*>(char*, char*, __less<char>&);
16template void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
17template void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&);
18template void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&);
19template void __sort<__less<short>&, short*>(short*, short*, __less<short>&);
20template void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&);
21template void __sort<__less<int>&, int*>(int*, int*, __less<int>&);
22template void __sort<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&);
23template void __sort<__less<long>&, long*>(long*, long*, __less<long>&);
24template void __sort<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&);
25template void __sort<__less<long long>&, long long*>(long long*, long long*, __less<long long>&);
26template void __sort<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&);
27template void __sort<__less<float>&, float*>(float*, float*, __less<float>&);
28template void __sort<__less<double>&, double*>(double*, double*, __less<double>&);
29template void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&);
30
31template bool __insertion_sort_incomplete<__less<char>&, char*>(char*, char*, __less<char>&);
32template bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
33template bool __insertion_sort_incomplete<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&);
34template bool __insertion_sort_incomplete<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&);
35template bool __insertion_sort_incomplete<__less<short>&, short*>(short*, short*, __less<short>&);
36template bool __insertion_sort_incomplete<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&);
37template bool __insertion_sort_incomplete<__less<int>&, int*>(int*, int*, __less<int>&);
38template bool __insertion_sort_incomplete<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&);
39template bool __insertion_sort_incomplete<__less<long>&, long*>(long*, long*, __less<long>&);
40template bool __insertion_sort_incomplete<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&);
41template bool __insertion_sort_incomplete<__less<long long>&, long long*>(long long*, long long*, __less<long long>&);
42template bool __insertion_sort_incomplete<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&);
43template bool __insertion_sort_incomplete<__less<float>&, float*>(float*, float*, __less<float>&);
44template bool __insertion_sort_incomplete<__less<double>&, double*>(double*, double*, __less<double>&);
45template bool __insertion_sort_incomplete<__less<long double>&, long double*>(long double*, long double*, __less<long double>&);
46
47template unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&);
48
Jonathan Roelofs39cb6bf2014-09-05 19:45:05 +000049#ifndef _LIBCPP_HAS_NO_THREADS
Eric Fiselier637dd952016-09-28 22:08:13 +000050_LIBCPP_SAFE_STATIC static __libcpp_mutex_t __rs_mut = _LIBCPP_MUTEX_INITIALIZER;
Jonathan Roelofs39cb6bf2014-09-05 19:45:05 +000051#endif
Howard Hinnant578ac0f2010-05-26 17:49:34 +000052unsigned __rs_default::__c_ = 0;
53
54__rs_default::__rs_default()
55{
Jonathan Roelofs39cb6bf2014-09-05 19:45:05 +000056#ifndef _LIBCPP_HAS_NO_THREADS
Asiri Rathnayakefa2e2032016-05-06 14:06:29 +000057 __libcpp_mutex_lock(&__rs_mut);
Jonathan Roelofs39cb6bf2014-09-05 19:45:05 +000058#endif
Howard Hinnant578ac0f2010-05-26 17:49:34 +000059 __c_ = 1;
60}
61
62__rs_default::__rs_default(const __rs_default&)
63{
64 ++__c_;
65}
66
67__rs_default::~__rs_default()
68{
Jonathan Roelofs39cb6bf2014-09-05 19:45:05 +000069#ifndef _LIBCPP_HAS_NO_THREADS
Howard Hinnant578ac0f2010-05-26 17:49:34 +000070 if (--__c_ == 0)
Asiri Rathnayakefa2e2032016-05-06 14:06:29 +000071 __libcpp_mutex_unlock(&__rs_mut);
Jonathan Roelofs39cb6bf2014-09-05 19:45:05 +000072#else
73 --__c_;
74#endif
Howard Hinnant578ac0f2010-05-26 17:49:34 +000075}
76
77__rs_default::result_type
78__rs_default::operator()()
79{
80 static mt19937 __rs_g;
81 return __rs_g();
82}
83
84__rs_default
85__rs_get()
86{
87 return __rs_default();
88}
89
Howard Hinnantc51e1022010-05-11 19:42:16 +000090_LIBCPP_END_NAMESPACE_STD