Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------- algorithm.cpp --------------------------------===// |
| 2 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
Dan Albert | 75746a3 | 2015-11-09 12:34:21 -0800 | [diff] [blame] | 10 | #undef _LIBCPP_EXTERN_TEMPLATE |
| 11 | #define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 12 | #include "algorithm" |
Howard Hinnant | c326721 | 2010-05-26 17:49:34 +0000 | [diff] [blame] | 13 | #include "random" |
| 14 | #include "mutex" |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 15 | |
| 16 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 17 | |
| 18 | template void __sort<__less<char>&, char*>(char*, char*, __less<char>&); |
| 19 | template void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&); |
| 20 | template void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&); |
| 21 | template void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&); |
| 22 | template void __sort<__less<short>&, short*>(short*, short*, __less<short>&); |
| 23 | template void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&); |
| 24 | template void __sort<__less<int>&, int*>(int*, int*, __less<int>&); |
| 25 | template void __sort<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&); |
| 26 | template void __sort<__less<long>&, long*>(long*, long*, __less<long>&); |
| 27 | template void __sort<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&); |
| 28 | template void __sort<__less<long long>&, long long*>(long long*, long long*, __less<long long>&); |
| 29 | template void __sort<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&); |
| 30 | template void __sort<__less<float>&, float*>(float*, float*, __less<float>&); |
| 31 | template void __sort<__less<double>&, double*>(double*, double*, __less<double>&); |
| 32 | template void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&); |
| 33 | |
| 34 | template bool __insertion_sort_incomplete<__less<char>&, char*>(char*, char*, __less<char>&); |
| 35 | template bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&); |
| 36 | template bool __insertion_sort_incomplete<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&); |
| 37 | template bool __insertion_sort_incomplete<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&); |
| 38 | template bool __insertion_sort_incomplete<__less<short>&, short*>(short*, short*, __less<short>&); |
| 39 | template bool __insertion_sort_incomplete<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&); |
| 40 | template bool __insertion_sort_incomplete<__less<int>&, int*>(int*, int*, __less<int>&); |
| 41 | template bool __insertion_sort_incomplete<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&); |
| 42 | template bool __insertion_sort_incomplete<__less<long>&, long*>(long*, long*, __less<long>&); |
| 43 | template bool __insertion_sort_incomplete<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&); |
| 44 | template bool __insertion_sort_incomplete<__less<long long>&, long long*>(long long*, long long*, __less<long long>&); |
| 45 | template bool __insertion_sort_incomplete<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&); |
| 46 | template bool __insertion_sort_incomplete<__less<float>&, float*>(float*, float*, __less<float>&); |
| 47 | template bool __insertion_sort_incomplete<__less<double>&, double*>(double*, double*, __less<double>&); |
| 48 | template bool __insertion_sort_incomplete<__less<long double>&, long double*>(long double*, long double*, __less<long double>&); |
| 49 | |
| 50 | template unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&); |
| 51 | |
Jonathan Roelofs | 8d86b2e | 2014-09-05 19:45:05 +0000 | [diff] [blame] | 52 | #ifndef _LIBCPP_HAS_NO_THREADS |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 53 | static pthread_mutex_t __rs_mut = PTHREAD_MUTEX_INITIALIZER; |
Jonathan Roelofs | 8d86b2e | 2014-09-05 19:45:05 +0000 | [diff] [blame] | 54 | #endif |
Howard Hinnant | c326721 | 2010-05-26 17:49:34 +0000 | [diff] [blame] | 55 | unsigned __rs_default::__c_ = 0; |
| 56 | |
| 57 | __rs_default::__rs_default() |
| 58 | { |
Jonathan Roelofs | 8d86b2e | 2014-09-05 19:45:05 +0000 | [diff] [blame] | 59 | #ifndef _LIBCPP_HAS_NO_THREADS |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 60 | pthread_mutex_lock(&__rs_mut); |
Jonathan Roelofs | 8d86b2e | 2014-09-05 19:45:05 +0000 | [diff] [blame] | 61 | #endif |
Howard Hinnant | c326721 | 2010-05-26 17:49:34 +0000 | [diff] [blame] | 62 | __c_ = 1; |
| 63 | } |
| 64 | |
| 65 | __rs_default::__rs_default(const __rs_default&) |
| 66 | { |
| 67 | ++__c_; |
| 68 | } |
| 69 | |
| 70 | __rs_default::~__rs_default() |
| 71 | { |
Jonathan Roelofs | 8d86b2e | 2014-09-05 19:45:05 +0000 | [diff] [blame] | 72 | #ifndef _LIBCPP_HAS_NO_THREADS |
Howard Hinnant | c326721 | 2010-05-26 17:49:34 +0000 | [diff] [blame] | 73 | if (--__c_ == 0) |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 74 | pthread_mutex_unlock(&__rs_mut); |
Jonathan Roelofs | 8d86b2e | 2014-09-05 19:45:05 +0000 | [diff] [blame] | 75 | #else |
| 76 | --__c_; |
| 77 | #endif |
Howard Hinnant | c326721 | 2010-05-26 17:49:34 +0000 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | __rs_default::result_type |
| 81 | __rs_default::operator()() |
| 82 | { |
| 83 | static mt19937 __rs_g; |
| 84 | return __rs_g(); |
| 85 | } |
| 86 | |
| 87 | __rs_default |
| 88 | __rs_get() |
| 89 | { |
| 90 | return __rs_default(); |
| 91 | } |
| 92 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 93 | _LIBCPP_END_NAMESPACE_STD |