mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-01 10:12:27 +00:00
Release Cosmopolitan v3.6.0
This release is an atomic upgrade to GCC 14.1.0 with C23 and C++23
This commit is contained in:
parent
62ace3623a
commit
5660ec4741
1585 changed files with 117353 additions and 271644 deletions
51
third_party/libcxx/random_shuffle.cpp
vendored
Normal file
51
third_party/libcxx/random_shuffle.cpp
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <algorithm>
|
||||
#include <random>
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
# include <mutex>
|
||||
# if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
|
||||
# pragma comment(lib, "pthread")
|
||||
# endif
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
static constinit __libcpp_mutex_t __rs_mut = _LIBCPP_MUTEX_INITIALIZER;
|
||||
#endif
|
||||
unsigned __rs_default::__c_ = 0;
|
||||
|
||||
__rs_default::__rs_default() {
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
__libcpp_mutex_lock(&__rs_mut);
|
||||
#endif
|
||||
__c_ = 1;
|
||||
}
|
||||
|
||||
__rs_default::__rs_default(const __rs_default&) { ++__c_; }
|
||||
|
||||
__rs_default::~__rs_default() {
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
if (--__c_ == 0)
|
||||
__libcpp_mutex_unlock(&__rs_mut);
|
||||
#else
|
||||
--__c_;
|
||||
#endif
|
||||
}
|
||||
|
||||
__rs_default::result_type __rs_default::operator()() {
|
||||
static mt19937 __rs_g;
|
||||
return __rs_g();
|
||||
}
|
||||
|
||||
__rs_default __rs_get() { return __rs_default(); }
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
Loading…
Add table
Add a link
Reference in a new issue