system.nim cleanup some exported constants which should never have be… (#17909)
* system.nim cleanup some exported constants which should never have been exported
This commit is contained in:
parent
a55c7e9679
commit
fb86271556
10 changed files with 32 additions and 29 deletions
|
|
@ -34,9 +34,6 @@ from ast import eqTypeFlags, tfGcSafe, tfNoSideEffect
|
||||||
|
|
||||||
# but some have deps to imported modules. Yay.
|
# but some have deps to imported modules. Yay.
|
||||||
bootSwitch(usedTinyC, hasTinyCBackend, "-d:tinyc")
|
bootSwitch(usedTinyC, hasTinyCBackend, "-d:tinyc")
|
||||||
bootSwitch(usedNativeStacktrace,
|
|
||||||
defined(nativeStackTrace) and nativeStackTraceSupported,
|
|
||||||
"-d:nativeStackTrace")
|
|
||||||
bootSwitch(usedFFI, hasFFI, "-d:nimHasLibFFI")
|
bootSwitch(usedFFI, hasFFI, "-d:nimHasLibFFI")
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
@ -101,7 +98,7 @@ proc writeVersionInfo(conf: ConfigRef; pass: TCmdLinePass) =
|
||||||
msgWriteln(conf, "git hash: " & gitHash, {msgStdout})
|
msgWriteln(conf, "git hash: " & gitHash, {msgStdout})
|
||||||
|
|
||||||
msgWriteln(conf, "active boot switches:" & usedRelease & usedDanger &
|
msgWriteln(conf, "active boot switches:" & usedRelease & usedDanger &
|
||||||
usedTinyC & useLinenoise & usedNativeStacktrace &
|
usedTinyC & useLinenoise &
|
||||||
usedFFI & usedBoehm & usedMarkAndSweep & usedGoGC & usedNoGC,
|
usedFFI & usedBoehm & usedMarkAndSweep & usedGoGC & usedNoGC,
|
||||||
{msgStdout})
|
{msgStdout})
|
||||||
msgQuit(0)
|
msgQuit(0)
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ const
|
||||||
hasFFI* = defined(nimHasLibFFI)
|
hasFFI* = defined(nimHasLibFFI)
|
||||||
copyrightYear* = "2021"
|
copyrightYear* = "2021"
|
||||||
|
|
||||||
|
nimEnableCovariance* = defined(nimEnableCovariance)
|
||||||
|
|
||||||
type # please make sure we have under 32 options
|
type # please make sure we have under 32 options
|
||||||
# (improves code efficiency a lot!)
|
# (improves code efficiency a lot!)
|
||||||
TOption* = enum # **keep binary compatible**
|
TOption* = enum # **keep binary compatible**
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@
|
||||||
##
|
##
|
||||||
## Unstable API.
|
## Unstable API.
|
||||||
|
|
||||||
|
import system/coro_detection
|
||||||
|
|
||||||
when not nimCoroutines and not defined(nimdoc):
|
when not nimCoroutines and not defined(nimdoc):
|
||||||
when defined(noNimCoroutines):
|
when defined(noNimCoroutines):
|
||||||
{.error: "Coroutines can not be used with -d:noNimCoroutines".}
|
{.error: "Coroutines can not be used with -d:noNimCoroutines".}
|
||||||
|
|
|
||||||
|
|
@ -1910,7 +1910,7 @@ proc copyFileToDir*(source, dir: string, options = {cfSymlinkFollow})
|
||||||
copyFile(source, dir / source.lastPathPart, options)
|
copyFile(source, dir / source.lastPathPart, options)
|
||||||
|
|
||||||
when not declared(ENOENT) and not defined(windows):
|
when not declared(ENOENT) and not defined(windows):
|
||||||
when NoFakeVars:
|
when defined(nimscript):
|
||||||
when not defined(haiku):
|
when not defined(haiku):
|
||||||
const ENOENT = cint(2) # 2 on most systems including Solaris
|
const ENOENT = cint(2) # 2 on most systems including Solaris
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -537,7 +537,7 @@ const
|
||||||
|
|
||||||
include "system/inclrtl"
|
include "system/inclrtl"
|
||||||
|
|
||||||
const NoFakeVars* = defined(nimscript) ## `true` if the backend doesn't support \
|
const NoFakeVars = defined(nimscript) ## `true` if the backend doesn't support \
|
||||||
## "fake variables" like `var EBADF {.importc.}: cint`.
|
## "fake variables" like `var EBADF {.importc.}: cint`.
|
||||||
|
|
||||||
const notJSnotNims = not defined(js) and not defined(nimscript)
|
const notJSnotNims = not defined(js) and not defined(nimscript)
|
||||||
|
|
@ -1132,7 +1132,6 @@ const
|
||||||
const
|
const
|
||||||
hasThreadSupport = compileOption("threads") and not defined(nimscript)
|
hasThreadSupport = compileOption("threads") and not defined(nimscript)
|
||||||
hasSharedHeap = defined(boehmgc) or defined(gogc) # don't share heaps; every thread has its own
|
hasSharedHeap = defined(boehmgc) or defined(gogc) # don't share heaps; every thread has its own
|
||||||
nimEnableCovariance* = defined(nimEnableCovariance) # or true
|
|
||||||
|
|
||||||
when hasThreadSupport and defined(tcc) and not compileOption("tlsEmulation"):
|
when hasThreadSupport and defined(tcc) and not compileOption("tlsEmulation"):
|
||||||
# tcc doesn't support TLS
|
# tcc doesn't support TLS
|
||||||
|
|
@ -1920,24 +1919,7 @@ include "system/gc_interface"
|
||||||
# we have to compute this here before turning it off in except.nim anyway ...
|
# we have to compute this here before turning it off in except.nim anyway ...
|
||||||
const NimStackTrace = compileOption("stacktrace")
|
const NimStackTrace = compileOption("stacktrace")
|
||||||
|
|
||||||
template coroutinesSupportedPlatform(): bool =
|
import system/coro_detection
|
||||||
when defined(sparc) or defined(ELATE) or defined(boehmgc) or defined(gogc) or
|
|
||||||
defined(nogc) or defined(gcRegions) or defined(gcMarkAndSweep):
|
|
||||||
false
|
|
||||||
else:
|
|
||||||
true
|
|
||||||
|
|
||||||
when defined(nimCoroutines):
|
|
||||||
# Explicit opt-in.
|
|
||||||
when not coroutinesSupportedPlatform():
|
|
||||||
{.error: "Coroutines are not supported on this architecture and/or garbage collector.".}
|
|
||||||
const nimCoroutines* = true
|
|
||||||
elif defined(noNimCoroutines):
|
|
||||||
# Explicit opt-out.
|
|
||||||
const nimCoroutines* = false
|
|
||||||
else:
|
|
||||||
# Autodetect coroutine support.
|
|
||||||
const nimCoroutines* = false
|
|
||||||
|
|
||||||
{.push checks: off.}
|
{.push checks: off.}
|
||||||
# obviously we cannot generate checking operations here :-)
|
# obviously we cannot generate checking operations here :-)
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ elif defined(haiku):
|
||||||
SIGPIPE* = cint(7)
|
SIGPIPE* = cint(7)
|
||||||
SIG_DFL* = cast[CSighandlerT](0)
|
SIG_DFL* = cast[CSighandlerT](0)
|
||||||
else:
|
else:
|
||||||
when NoFakeVars:
|
when defined(nimscript):
|
||||||
{.error: "SIGABRT not ported to your platform".}
|
{.error: "SIGABRT not ported to your platform".}
|
||||||
else:
|
else:
|
||||||
var
|
var
|
||||||
|
|
|
||||||
20
lib/system/coro_detection.nim
Normal file
20
lib/system/coro_detection.nim
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
## Coroutine detection logic
|
||||||
|
|
||||||
|
template coroutinesSupportedPlatform(): bool =
|
||||||
|
when defined(sparc) or defined(ELATE) or defined(boehmgc) or defined(gogc) or
|
||||||
|
defined(nogc) or defined(gcRegions) or defined(gcMarkAndSweep):
|
||||||
|
false
|
||||||
|
else:
|
||||||
|
true
|
||||||
|
|
||||||
|
when defined(nimCoroutines):
|
||||||
|
# Explicit opt-in.
|
||||||
|
when not coroutinesSupportedPlatform():
|
||||||
|
{.error: "Coroutines are not supported on this architecture and/or garbage collector.".}
|
||||||
|
const nimCoroutines* = true
|
||||||
|
elif defined(noNimCoroutines):
|
||||||
|
# Explicit opt-out.
|
||||||
|
const nimCoroutines* = false
|
||||||
|
else:
|
||||||
|
# Autodetect coroutine support.
|
||||||
|
const nimCoroutines* = false
|
||||||
|
|
@ -146,7 +146,7 @@ proc closureIterSetupExc(e: ref Exception) {.compilerproc, inline.} =
|
||||||
|
|
||||||
# some platforms have native support for stack traces:
|
# some platforms have native support for stack traces:
|
||||||
const
|
const
|
||||||
nativeStackTraceSupported* = (defined(macosx) or defined(linux)) and
|
nativeStackTraceSupported = (defined(macosx) or defined(linux)) and
|
||||||
not NimStackTrace
|
not NimStackTrace
|
||||||
hasSomeStackTrace = NimStackTrace or defined(nimStackTraceOverride) or
|
hasSomeStackTrace = NimStackTrace or defined(nimStackTraceOverride) or
|
||||||
(defined(nativeStackTrace) and nativeStackTraceSupported)
|
(defined(nativeStackTrace) and nativeStackTraceSupported)
|
||||||
|
|
|
||||||
|
|
@ -252,7 +252,7 @@ proc write*(f: File, s: string) {.tags: [WriteIOEffect], benign.} =
|
||||||
raiseEIO("cannot write string to file")
|
raiseEIO("cannot write string to file")
|
||||||
{.pop.}
|
{.pop.}
|
||||||
|
|
||||||
when NoFakeVars:
|
when defined(nimscript):
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
const
|
const
|
||||||
IOFBF = cint(0)
|
IOFBF = cint(0)
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ import macros
|
||||||
macro skipElse(n: untyped): untyped = n[0]
|
macro skipElse(n: untyped): untyped = n[0]
|
||||||
|
|
||||||
template acceptWithCovariance(x, otherwise): untyped =
|
template acceptWithCovariance(x, otherwise): untyped =
|
||||||
when nimEnableCovariance:
|
when defined nimEnableCovariance:
|
||||||
x
|
x
|
||||||
else:
|
else:
|
||||||
reject(x)
|
reject(x)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue