From f455e03028850d45aebca5396189b1a498f9af95 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Wed, 17 Feb 2021 22:00:51 -0800 Subject: [PATCH] fix #17078 csources generation (#17079) * fix #17078 csources generation * fixup --- lib/pure/concurrency/cpuinfo.nim | 2 +- lib/std/sysrand.nim | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/pure/concurrency/cpuinfo.nim b/lib/pure/concurrency/cpuinfo.nim index dab5a2447c7a..ee43b8e11faa 100644 --- a/lib/pure/concurrency/cpuinfo.nim +++ b/lib/pure/concurrency/cpuinfo.nim @@ -15,7 +15,7 @@ runnableExamples: include "system/inclrtl" -when defined(linux): +when defined(posix) and not (defined(macosx) or defined(bsd)): import posix when defined(freebsd) or defined(macosx): diff --git a/lib/std/sysrand.nim b/lib/std/sysrand.nim index 75a1af5a9518..5ccbd21be5c2 100644 --- a/lib/std/sysrand.nim +++ b/lib/std/sysrand.nim @@ -53,11 +53,11 @@ when not defined(js): when defined(posix): import std/posix -const batchImplOS = defined(freebsd) or defined(openbsd) or (defined(macosx) and not defined(ios)) +const + batchImplOS = defined(freebsd) or defined(openbsd) or (defined(macosx) and not defined(ios)) + batchSize {.used.} = 256 when batchImplOS: - const batchSize = 256 - template batchImpl(result: var int, dest: var openArray[byte], getRandomImpl) = let size = dest.len if size == 0: @@ -94,8 +94,6 @@ when defined(js): dest[i] = src[i] else: - const batchSize = 256 - proc getRandomValues(p: Uint8Array) {.importjs: "window.crypto.getRandomValues(#)".} # The requested length of `p` must not be more than 65536.