coro_detection.nim 623 B

123456789101112131415161718192021
  1. ## Coroutine detection logic
  2. template coroutinesSupportedPlatform(): bool =
  3. when defined(sparc) or defined(ELATE) or defined(boehmgc) or defined(gogc) or
  4. defined(nogc) or defined(gcRegions) or defined(gcMarkAndSweep):
  5. false
  6. else:
  7. true
  8. when defined(nimCoroutines):
  9. # Explicit opt-in.
  10. when not coroutinesSupportedPlatform():
  11. {.error: "Coroutines are not supported on this architecture and/or garbage collector.".}
  12. const nimCoroutines* = true
  13. elif defined(noNimCoroutines):
  14. # Explicit opt-out.
  15. const nimCoroutines* = false
  16. else:
  17. # Autodetect coroutine support.
  18. const nimCoroutines* = false