segfaults

This modules registers a signal handler that turns access violations / segfaults into a NilAccessDefect exception. To be able to catch a NilAccessDefect all you have to do is to import this module.

Tested on these OSes: Linux, Windows, OSX

Types

C_JmpBuf {...}{.importc: "jmp_buf", header: "<setjmp.h>".} = object
  Source Edit
CFilePtr = ptr CFile
The type representing a file handle.   Source Edit

Consts

SIGABRT = 22'i32
  Source Edit
SIGFPE = 8'i32
  Source Edit
SIGILL = 4'i32
  Source Edit
SIGINT = 2'i32
  Source Edit
SIGSEGV = 11'i32
  Source Edit

Procs

proc c_memchr(s: pointer; c: cint; n: csize_t): pointer {...}{.importc: "memchr",
    header: "<string.h>".}
  Source Edit
proc c_memcmp(a, b: pointer; size: csize_t): cint {...}{.importc: "memcmp",
    header: "<string.h>", noSideEffect.}
  Source Edit
proc c_memcpy(a, b: pointer; size: csize_t): pointer {...}{.importc: "memcpy",
    header: "<string.h>", discardable.}
  Source Edit
proc c_memmove(a, b: pointer; size: csize_t): pointer {...}{.importc: "memmove",
    header: "<string.h>", discardable.}
  Source Edit
proc c_memset(p: pointer; value: cint; size: csize_t): pointer {...}{.
    importc: "memset", header: "<string.h>", discardable.}
  Source Edit
proc c_strcmp(a, b: cstring): cint {...}{.importc: "strcmp", header: "<string.h>",
                                     noSideEffect.}
  Source Edit
proc c_strlen(a: cstring): csize_t {...}{.importc: "strlen", header: "<string.h>",
                                     noSideEffect.}
  Source Edit
proc c_abort() {...}{.importc: "abort", header: "<stdlib.h>", noSideEffect, noreturn.}
  Source Edit
proc c_longjmp(jmpb: C_JmpBuf; retval: cint) {...}{.header: "<setjmp.h>",
    importc: "longjmp".}
  Source Edit
proc c_setjmp(jmpb: C_JmpBuf): cint {...}{.header: "<setjmp.h>", importc: "setjmp".}
  Source Edit
proc c_signal(sign: cint; handler: proc (a: cint) {...}{.noconv.}): CSighandlerT {...}{.
    importc: "signal", header: "<signal.h>", discardable.}
  Source Edit
proc c_fprintf(f: CFilePtr; frmt: cstring): cint {...}{.importc: "fprintf",
    header: "<stdio.h>", varargs, discardable.}
  Source Edit
proc c_printf(frmt: cstring): cint {...}{.importc: "printf", header: "<stdio.h>",
                                     varargs, discardable.}
  Source Edit
proc c_fputs(c: cstring; f: CFilePtr): cint {...}{.importc: "fputs",
    header: "<stdio.h>", discardable.}
  Source Edit
proc c_sprintf(buf, frmt: cstring): cint {...}{.importc: "sprintf",
    header: "<stdio.h>", varargs, noSideEffect.}
  Source Edit
proc c_malloc(size: csize_t): pointer {...}{.importc: "malloc", header: "<stdlib.h>".}
  Source Edit
proc c_calloc(nmemb, size: csize_t): pointer {...}{.importc: "calloc",
    header: "<stdlib.h>".}
  Source Edit
proc c_free(p: pointer) {...}{.importc: "free", header: "<stdlib.h>".}
  Source Edit
proc c_realloc(p: pointer; newsize: csize_t): pointer {...}{.importc: "realloc",
    header: "<stdlib.h>".}
  Source Edit
proc c_fwrite(buf: pointer; size, n: csize_t; f: CFilePtr): cint {...}{.
    importc: "fwrite", header: "<stdio.h>".}
  Source Edit
proc rawWrite(f: CFilePtr; s: cstring) {...}{.compilerproc, nonReloadable, inline,
    raises: [], tags: [].}
  Source Edit