algorithm.cpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //===----------------------- algorithm.cpp --------------------------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is dual licensed under the MIT and the University of Illinois Open
  6. // Source Licenses. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #include "algorithm"
  10. // SGX compatible. Partial support. Priority 1.
  11. #if defined(_LIBCPP_SGX_CONFIG)
  12. #include "vector"
  13. #endif // defined(_LIBCPP_SGX_CONFIG)
  14. #include "random"
  15. #include "mutex"
  16. _LIBCPP_BEGIN_NAMESPACE_STD
  17. #if defined(_LIBCPP_SGX_CONFIG)
  18. template class __vector_base_common<true>;
  19. #endif // defined(_LIBCPP_SGX_CONFIG)
  20. template void __sort<__less<char>&, char*>(char*, char*, __less<char>&);
  21. template void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
  22. template void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&);
  23. template void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&);
  24. template void __sort<__less<short>&, short*>(short*, short*, __less<short>&);
  25. template void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&);
  26. template void __sort<__less<int>&, int*>(int*, int*, __less<int>&);
  27. template void __sort<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&);
  28. template void __sort<__less<long>&, long*>(long*, long*, __less<long>&);
  29. template void __sort<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&);
  30. template void __sort<__less<long long>&, long long*>(long long*, long long*, __less<long long>&);
  31. template void __sort<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&);
  32. template void __sort<__less<float>&, float*>(float*, float*, __less<float>&);
  33. template void __sort<__less<double>&, double*>(double*, double*, __less<double>&);
  34. template void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&);
  35. template bool __insertion_sort_incomplete<__less<char>&, char*>(char*, char*, __less<char>&);
  36. template bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
  37. template bool __insertion_sort_incomplete<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&);
  38. template bool __insertion_sort_incomplete<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&);
  39. template bool __insertion_sort_incomplete<__less<short>&, short*>(short*, short*, __less<short>&);
  40. template bool __insertion_sort_incomplete<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&);
  41. template bool __insertion_sort_incomplete<__less<int>&, int*>(int*, int*, __less<int>&);
  42. template bool __insertion_sort_incomplete<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&);
  43. template bool __insertion_sort_incomplete<__less<long>&, long*>(long*, long*, __less<long>&);
  44. template bool __insertion_sort_incomplete<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&);
  45. template bool __insertion_sort_incomplete<__less<long long>&, long long*>(long long*, long long*, __less<long long>&);
  46. template bool __insertion_sort_incomplete<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&);
  47. template bool __insertion_sort_incomplete<__less<float>&, float*>(float*, float*, __less<float>&);
  48. template bool __insertion_sort_incomplete<__less<double>&, double*>(double*, double*, __less<double>&);
  49. template bool __insertion_sort_incomplete<__less<long double>&, long double*>(long double*, long double*, __less<long double>&);
  50. template unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&);
  51. #if !defined(_LIBCPP_SGX_CONFIG)
  52. #ifndef _LIBCPP_HAS_NO_THREADS
  53. static __libcpp_mutex_t __rs_mut = _LIBCPP_MUTEX_INITIALIZER;
  54. #endif
  55. unsigned __rs_default::__c_ = 0;
  56. __rs_default::__rs_default()
  57. {
  58. #ifndef _LIBCPP_HAS_NO_THREADS
  59. __libcpp_mutex_lock(&__rs_mut);
  60. #endif
  61. __c_ = 1;
  62. }
  63. __rs_default::__rs_default(const __rs_default&)
  64. {
  65. ++__c_;
  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. __rs_default::result_type
  77. __rs_default::operator()()
  78. {
  79. static mt19937 __rs_g;
  80. return __rs_g();
  81. }
  82. __rs_default
  83. __rs_get()
  84. {
  85. return __rs_default();
  86. }
  87. #endif // !defined(_LIBCPP_SGX_CONFIG)
  88. _LIBCPP_END_NAMESPACE_STD