summary refs log tree commit diff stats
path: root/lib/system.nim
diff options
context:
space:
mode:
Diffstat (limited to 'lib/system.nim')
-rw-r--r--lib/system.nim20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/system.nim b/lib/system.nim
index 4371f0000..74dca461a 100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -2462,6 +2462,26 @@ template accumulateResult*(iter: untyped) =
 # we have to compute this here before turning it off in except.nim anyway ...
 const NimStackTrace = compileOption("stacktrace")
 
+template coroutinesSupportedPlatform(): bool =
+  when defined(sparc) or defined(ELATE) or compileOption("gc", "v2") or 
+    defined(boehmgc) or defined(gogc) or defined(nogc) or defined(gcStack) 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.}
 # obviously we cannot generate checking operations here :-)
 # because it would yield into an endless recursion