mirror of
https://github.com/janet-lang/janet
synced 2025-01-13 17:10:27 +00:00
Merge branch 'master' of github.com:janet-lang/janet
This commit is contained in:
commit
dea4906144
@ -141,8 +141,7 @@ JANET_CORE_FN(cfun_rng_make,
|
|||||||
|
|
||||||
JANET_CORE_FN(cfun_rng_uniform,
|
JANET_CORE_FN(cfun_rng_uniform,
|
||||||
"(math/rng-uniform rng)",
|
"(math/rng-uniform rng)",
|
||||||
"Extract a random random integer in the range [0, max] from the RNG. If "
|
"Extract a random number in the range [0, 1) from the RNG."
|
||||||
"no max is given, the default is 2^31 - 1."
|
|
||||||
) {
|
) {
|
||||||
janet_fixarity(argc, 1);
|
janet_fixarity(argc, 1);
|
||||||
JanetRNG *rng = janet_getabstract(argv, 0, &janet_rng_type);
|
JanetRNG *rng = janet_getabstract(argv, 0, &janet_rng_type);
|
||||||
|
@ -84,7 +84,6 @@ time_t timegm(struct tm *tm);
|
|||||||
* setenv/getenv are not thread safe. */
|
* setenv/getenv are not thread safe. */
|
||||||
#ifdef JANET_THREADS
|
#ifdef JANET_THREADS
|
||||||
# ifdef JANET_WINDOWS
|
# ifdef JANET_WINDOWS
|
||||||
static int env_lock_initialized = 0;
|
|
||||||
static CRITICAL_SECTION env_lock;
|
static CRITICAL_SECTION env_lock;
|
||||||
static void janet_lock_environ(void) {
|
static void janet_lock_environ(void) {
|
||||||
EnterCriticalSection(&env_lock);
|
EnterCriticalSection(&env_lock);
|
||||||
@ -2146,10 +2145,17 @@ void janet_lib_os(JanetTable *env) {
|
|||||||
#if !defined(JANET_REDUCED_OS) && defined(JANET_WINDOWS) && defined(JANET_THREADS)
|
#if !defined(JANET_REDUCED_OS) && defined(JANET_WINDOWS) && defined(JANET_THREADS)
|
||||||
/* During start up, the top-most abstract machine (thread)
|
/* During start up, the top-most abstract machine (thread)
|
||||||
* in the thread tree sets up the critical section. */
|
* in the thread tree sets up the critical section. */
|
||||||
if (!env_lock_initialized) {
|
static volatile long env_lock_initializing = 0;
|
||||||
InitializeCriticalSection(&env_lock);
|
static volatile long env_lock_initialized = 0;
|
||||||
env_lock_initialized = 1;
|
if(!InterlockedExchange(&env_lock_initializing, 1)){
|
||||||
|
InitializeCriticalSection(&env_lock);
|
||||||
|
InterlockedOr(&env_lock_initialized, 1);
|
||||||
|
} else {
|
||||||
|
while (!InterlockedOr(&env_lock_initialized, 0)) {
|
||||||
|
Sleep(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#ifndef JANET_NO_PROCESSES
|
#ifndef JANET_NO_PROCESSES
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user