parent
0b4f502393
commit
66b0c843c3
1 changed files with 7 additions and 8 deletions
|
|
@ -1078,6 +1078,8 @@ when not defined(js) and hostOS != "standalone":
|
||||||
## deprecated, prefer `quit` or `exitprocs.getProgramResult`, `exitprocs.setProgramResult`.
|
## deprecated, prefer `quit` or `exitprocs.getProgramResult`, `exitprocs.setProgramResult`.
|
||||||
|
|
||||||
import std/private/since
|
import std/private/since
|
||||||
|
import system/ctypes
|
||||||
|
export ctypes
|
||||||
|
|
||||||
proc align(address, alignment: int): int =
|
proc align(address, alignment: int): int =
|
||||||
if alignment == 0: # Actually, this is illegal. This branch exists to actively
|
if alignment == 0: # Actually, this is illegal. This branch exists to actively
|
||||||
|
|
@ -1109,7 +1111,7 @@ elif defined(js) and defined(nodejs) and not defined(nimscript):
|
||||||
importc: "process.exit", noreturn.}
|
importc: "process.exit", noreturn.}
|
||||||
|
|
||||||
else:
|
else:
|
||||||
proc rawQuit(errorcode: int = QuitSuccess) {.
|
proc rawQuit(errorcode: cint) {.
|
||||||
magic: "Exit", importc: "exit", header: "<stdlib.h>", noreturn.}
|
magic: "Exit", importc: "exit", header: "<stdlib.h>", noreturn.}
|
||||||
|
|
||||||
template sysAssert(cond: bool, msg: string) =
|
template sysAssert(cond: bool, msg: string) =
|
||||||
|
|
@ -1244,9 +1246,6 @@ when not defined(nimV2):
|
||||||
## echo repr(i) # => 0x1055ed050[1, 2, 3, 4, 5]
|
## echo repr(i) # => 0x1055ed050[1, 2, 3, 4, 5]
|
||||||
## ```
|
## ```
|
||||||
|
|
||||||
import system/ctypes
|
|
||||||
export ctypes
|
|
||||||
|
|
||||||
when not defined(nimPreviewSlimSystem):
|
when not defined(nimPreviewSlimSystem):
|
||||||
type
|
type
|
||||||
csize* {.importc: "size_t", nodecl, deprecated: "use `csize_t` instead".} = int
|
csize* {.importc: "size_t", nodecl, deprecated: "use `csize_t` instead".} = int
|
||||||
|
|
@ -2302,14 +2301,14 @@ else:
|
||||||
when defined(posix): # posix uses low 8 bits
|
when defined(posix): # posix uses low 8 bits
|
||||||
type ExitCodeRange = int8
|
type ExitCodeRange = int8
|
||||||
else: # win32 uses low 32 bits
|
else: # win32 uses low 32 bits
|
||||||
type ExitCodeRange = int32
|
type ExitCodeRange = cint
|
||||||
|
|
||||||
if errorcode < low(ExitCodeRange):
|
if errorcode < low(ExitCodeRange):
|
||||||
rawQuit(low(ExitCodeRange).int)
|
rawQuit(low(ExitCodeRange).cint)
|
||||||
elif errorcode > high(ExitCodeRange):
|
elif errorcode > high(ExitCodeRange):
|
||||||
rawQuit(high(ExitCodeRange).int)
|
rawQuit(high(ExitCodeRange).cint)
|
||||||
else:
|
else:
|
||||||
rawQuit(errorcode)
|
rawQuit(errorcode.cint)
|
||||||
|
|
||||||
proc quit*(errormsg: string, errorcode = QuitFailure) {.noreturn.} =
|
proc quit*(errormsg: string, errorcode = QuitFailure) {.noreturn.} =
|
||||||
## A shorthand for `echo(errormsg); quit(errorcode)`.
|
## A shorthand for `echo(errormsg); quit(errorcode)`.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue