system refactorings (#10559)

* move IO subsystem into its own module; refs #10385
* make standalone test compile again
* make C++ examples compile again
* make more tests green
* make sysAssert and gcAssert work again
This commit is contained in:
Andreas Rumpf 2019-02-06 21:00:00 +01:00 • committed by GitHub
commit 0036014727
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 822 additions and 830 deletions

View file

@ -111,22 +111,27 @@ type c_sighandler_t = proc (a: cint) {.noconv.}
proc c_signal(sign: cint, handler: proc (a: cint) {.noconv.}): c_sighandler_t {.
importc: "signal", header: "<signal.h>", discardable.}
proc c_fprintf(f: File, frmt: cstring): cint {.
type
CFile {.importc: "FILE", header: "<stdio.h>",
incompletestruct.} = object
CFileStar* = ptr CFile ## The type representing a file handle.
var
cstderr* {.importc: "stderr", header: "<stdio.h>".}: CFileStar
cstdout* {.importc: "stdout", header: "<stdio.h>".}: CFileStar
proc c_fprintf(f: CFileStar, frmt: cstring): cint {.
importc: "fprintf", header: "<stdio.h>", varargs, discardable.}
proc c_printf(frmt: cstring): cint {.
importc: "printf", header: "<stdio.h>", varargs, discardable.}
proc c_fputs(c: cstring, f: CFileStar): cint {.
importc: "fputs", header: "<stdio.h>", discardable.}
proc c_sprintf(buf, frmt: cstring): cint {.
importc: "sprintf", header: "<stdio.h>", varargs, noSideEffect.}
# we use it only in a way that cannot lead to security issues
when defined(windows):
proc c_fileno(f: File): cint {.
importc: "_fileno", header: "<stdio.h>".}
else:
proc c_fileno(f: File): cint {.
importc: "fileno", header: "<fcntl.h>".}
proc c_malloc(size: csize): pointer {.
importc: "malloc", header: "<stdlib.h>".}
proc c_free(p: pointer) {.