1 //===----------------------- algorithm.cpp --------------------------------===// 2 // 3 // 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 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "algorithm" 10 #include "random" 11 #include "mutex" 12 13 _LIBCPP_BEGIN_NAMESPACE_STD 14 15 template void __sort<__less<char>&, char*>(char*, char*, __less<char>&); 16 template void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&); 17 template void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&); 18 template void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&); 19 template void __sort<__less<short>&, short*>(short*, short*, __less<short>&); 20 template void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&); 21 template void __sort<__less<int>&, int*>(int*, int*, __less<int>&); 22 template void __sort<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&); 23 template void __sort<__less<long>&, long*>(long*, long*, __less<long>&); 24 template void __sort<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&); 25 template void __sort<__less<long long>&, long long*>(long long*, long long*, __less<long long>&); 26 template void __sort<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&); 27 template void __sort<__less<float>&, float*>(float*, float*, __less<float>&); 28 template void __sort<__less<double>&, double*>(double*, double*, __less<double>&); 29 template void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&); 30 31 template bool __insertion_sort_incomplete<__less<char>&, char*>(char*, char*, __less<char>&); 32 template bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&); 33 template bool __insertion_sort_incomplete<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&); 34 template bool __insertion_sort_incomplete<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&); 35 template bool __insertion_sort_incomplete<__less<short>&, short*>(short*, short*, __less<short>&); 36 template bool __insertion_sort_incomplete<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&); 37 template bool __insertion_sort_incomplete<__less<int>&, int*>(int*, int*, __less<int>&); 38 template bool __insertion_sort_incomplete<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&); 39 template bool __insertion_sort_incomplete<__less<long>&, long*>(long*, long*, __less<long>&); 40 template bool __insertion_sort_incomplete<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&); 41 template bool __insertion_sort_incomplete<__less<long long>&, long long*>(long long*, long long*, __less<long long>&); 42 template bool __insertion_sort_incomplete<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&); 43 template bool __insertion_sort_incomplete<__less<float>&, float*>(float*, float*, __less<float>&); 44 template bool __insertion_sort_incomplete<__less<double>&, double*>(double*, double*, __less<double>&); 45 template bool __insertion_sort_incomplete<__less<long double>&, long double*>(long double*, long double*, __less<long double>&); 46 47 template unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&); 48 49 #ifndef _LIBCPP_HAS_NO_THREADS 50 _LIBCPP_SAFE_STATIC static __libcpp_mutex_t __rs_mut = _LIBCPP_MUTEX_INITIALIZER; 51 #endif 52 unsigned __rs_default::__c_ = 0; 53 54 __rs_default::__rs_default() 55 { 56 #ifndef _LIBCPP_HAS_NO_THREADS 57 __libcpp_mutex_lock(&__rs_mut); 58 #endif 59 __c_ = 1; 60 } 61 62 __rs_default::__rs_default(const __rs_default&) 63 { 64 ++__c_; 65 } 66 67 __rs_default::~__rs_default() 68 { 69 #ifndef _LIBCPP_HAS_NO_THREADS 70 if (--__c_ == 0) 71 __libcpp_mutex_unlock(&__rs_mut); 72 #else 73 --__c_; 74 #endif 75 } 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 90 _LIBCPP_END_NAMESPACE_STD 91