rawquits.nim 850 B

123456789101112131415161718192021222324252627
  1. import system/ctypes
  2. when defined(nimNoQuit):
  3. proc rawQuit(errorcode: int = QuitSuccess) = discard "ignoring quit"
  4. elif defined(genode):
  5. import genode/env
  6. var systemEnv {.exportc: runtimeEnvSym.}: GenodeEnvPtr
  7. type GenodeEnv = GenodeEnvPtr
  8. ## Opaque type representing Genode environment.
  9. proc rawQuit(env: GenodeEnv; errorcode: int) {.magic: "Exit", noreturn,
  10. importcpp: "#->parent().exit(@); Genode::sleep_forever()", header: "<base/sleep.h>".}
  11. proc rawQuit(errorcode: int = QuitSuccess) {.inline, noreturn.} =
  12. systemEnv.rawQuit(errorcode)
  13. elif defined(js) and defined(nodejs) and not defined(nimscript):
  14. proc rawQuit(errorcode: int = QuitSuccess) {.magic: "Exit",
  15. importc: "process.exit", noreturn.}
  16. else:
  17. proc rawQuit(errorcode: cint) {.
  18. magic: "Exit", importc: "exit", header: "<stdlib.h>", noreturn.}