summary refs log tree commit diff stats
path: root/lib/system.nim
diff options
context:
space:
mode:
authorEmery Hemingway <githubjunk@spam.works>2017-03-31 16:13:06 -0500
committerAndreas Rumpf <rumpf_a@web.de>2017-03-31 23:13:06 +0200
commit7e351fc7fa96b4d560c5a51118bab22abb590585 (patch)
treee0f5dd4deb394e86d95244317b0a328bb970842d /lib/system.nim
parent57246cbcec2f747d5af33ebf4c8c0e0a531eba02 (diff)
downloadNim-7e351fc7fa96b4d560c5a51118bab22abb590585.tar.gz
support for the Genode OS framework (#5560)
Diffstat (limited to 'lib/system.nim')
-rw-r--r--lib/system.nim47
1 files changed, 28 insertions, 19 deletions
diff --git a/lib/system.nim b/lib/system.nim
index 371cf8544..f6133b741 100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -1384,25 +1384,34 @@ var programResult* {.exportc: "nim_program_result".}: int
   ## under normal circumstances. When the program is terminated
   ## prematurely using ``quit``, this value is ignored.
 
-proc quit*(errorcode: int = QuitSuccess) {.
-  magic: "Exit", importc: "exit", header: "<stdlib.h>", noreturn.}
-  ## Stops the program immediately with an exit code.
-  ##
-  ## Before stopping the program the "quit procedures" are called in the
-  ## opposite order they were added with `addQuitProc <#addQuitProc>`_.
-  ## ``quit`` never returns and ignores any exception that may have been raised
-  ## by the quit procedures.  It does *not* call the garbage collector to free
-  ## all the memory, unless a quit procedure calls `GC_fullCollect
-  ## <#GC_fullCollect>`_.
-  ##
-  ## The proc ``quit(QuitSuccess)`` is called implicitly when your nim
-  ## program finishes without incident. A raised unhandled exception is
-  ## equivalent to calling ``quit(QuitFailure)``.
-  ##
-  ## Note that this is a *runtime* call and using ``quit`` inside a macro won't
-  ## have any compile time effect. If you need to stop the compiler inside a
-  ## macro, use the `error <manual.html#error-pragma>`_ or `fatal
-  ## <manual.html#fatal-pragma>`_ pragmas.
+when defined(nimdoc):
+  proc quit*(errorcode: int = QuitSuccess) {.magic: "Exit", noreturn.}
+    ## Stops the program immediately with an exit code.
+    ##
+    ## Before stopping the program the "quit procedures" are called in the
+    ## opposite order they were added with `addQuitProc <#addQuitProc>`_.
+    ## ``quit`` never returns and ignores any exception that may have been raised
+    ## by the quit procedures.  It does *not* call the garbage collector to free
+    ## all the memory, unless a quit procedure calls `GC_fullCollect
+    ## <#GC_fullCollect>`_.
+    ##
+    ## The proc ``quit(QuitSuccess)`` is called implicitly when your nim
+    ## program finishes without incident. A raised unhandled exception is
+    ## equivalent to calling ``quit(QuitFailure)``.
+    ##
+    ## Note that this is a *runtime* call and using ``quit`` inside a macro won't
+    ## have any compile time effect. If you need to stop the compiler inside a
+    ## macro, use the `error <manual.html#error-pragma>`_ or `fatal
+    ## <manual.html#fatal-pragma>`_ pragmas.
+
+
+elif defined(genode):
+  proc quit*(errorcode: int = QuitSuccess) {.magic: "Exit", noreturn,
+    importcpp: "genodeEnv->parent().exit(@)", header: "<base/env.h>".}
+
+else:
+  proc quit*(errorcode: int = QuitSuccess) {.
+    magic: "Exit", importc: "exit", header: "<stdlib.h>", noreturn.}
 
 template sysAssert(cond: bool, msg: string) =
   when defined(useSysAssert):