moderate system cleanup & refactor (#20355)
* system refactor, move out 600 lines * compilation, slice, backwardsindex, misc_num moved out of system * some procs/types moved into arithmetics, basic_types * system no longer depends on syncio * some procs moved around to fit with their surroundings * make exceptions an import, old ops to misc_num * move instantiationInfo back * move back nim version, fix windows echo * include compilation * better docs for imported modules, fix unsigned ops also remove ze, ze64, toU8, toU16, toU32 with nimPreviewSlimSystem * fix terminal * workaround IC test & weird csize bug, changelog * move NimMajor etc back to compilation, rebase for CI * try ic fix * form single `indices`, slim out TaintedString, try fix IC * fix CI, update changelog, addQuitProc * fix CI * try fix CI * actually fix CI finally hopefully * Update lib/system/compilation.nim Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> * update kochdocs * hopefully fix csize uses for slimsystem * fix tquit Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
This commit is contained in:
parent
b463c8aedf
commit
919a889ba8
37 changed files with 1167 additions and 1102 deletions
|
|
@ -317,9 +317,9 @@ when defined(posix) or defined(nimdoc):
|
|||
raiseOSError(osLastError())
|
||||
when defined(linux): #Maybe NetBSD, too?
|
||||
#On Linux this can be over 100 times faster than a munmap,mmap cycle.
|
||||
proc mremap(old: pointer; oldSize, newSize: csize; flags: cint):
|
||||
proc mremap(old: pointer; oldSize, newSize: csize_t; flags: cint):
|
||||
pointer {.importc: "mremap", header: "<sys/mman.h>".}
|
||||
let newAddr = mremap(f.mem, csize(f.size), csize(newFileSize), cint(1))
|
||||
let newAddr = mremap(f.mem, csize_t(f.size), csize_t(newFileSize), cint(1))
|
||||
if newAddr == cast[pointer](MAP_FAILED):
|
||||
raiseOSError(osLastError())
|
||||
else:
|
||||
|
|
@ -412,7 +412,7 @@ iterator memSlices*(mfile: MemFile, delim = '\l', eat = '\r'): MemSlice {.inline
|
|||
## inc(count)
|
||||
## echo count
|
||||
|
||||
proc c_memchr(cstr: pointer, c: char, n: csize): pointer {.
|
||||
proc c_memchr(cstr: pointer, c: char, n: csize_t): pointer {.
|
||||
importc: "memchr", header: "<string.h>".}
|
||||
proc `-!`(p, q: pointer): int {.inline.} = return cast[int](p) -% cast[int](q)
|
||||
var ms: MemSlice
|
||||
|
|
@ -420,7 +420,7 @@ iterator memSlices*(mfile: MemFile, delim = '\l', eat = '\r'): MemSlice {.inline
|
|||
ms.data = mfile.mem
|
||||
var remaining = mfile.size
|
||||
while remaining > 0:
|
||||
ending = c_memchr(ms.data, delim, remaining)
|
||||
ending = c_memchr(ms.data, delim, csize_t(remaining))
|
||||
if ending == nil: # unterminated final slice
|
||||
ms.size = remaining # Weird case..check eat?
|
||||
yield ms
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ when not useWinVersion:
|
|||
|
||||
else:
|
||||
proc toInt(domain: Domain): cint =
|
||||
result = toU32(ord(domain)).cint
|
||||
result = cast[cint](uint32(ord(domain)))
|
||||
|
||||
proc toKnownDomain*(family: cint): Option[Domain] =
|
||||
## Converts the platform-dependent `cint` to the Domain or none(),
|
||||
|
|
@ -375,9 +375,9 @@ when not useNimNetLite:
|
|||
##
|
||||
## On posix this will search through the `/etc/services` file.
|
||||
when useWinVersion:
|
||||
var s = winlean.getservbyport(ze(int16(port)).cint, proto)
|
||||
var s = winlean.getservbyport(uint16(port).cint, proto)
|
||||
else:
|
||||
var s = posix.getservbyport(ze(int16(port)).cint, proto)
|
||||
var s = posix.getservbyport(uint16(port).cint, proto)
|
||||
if s == nil: raiseOSError(osLastError(), "Service not found.")
|
||||
result.name = $s.s_name
|
||||
result.aliases = cstringArrayToSeq(s.s_aliases)
|
||||
|
|
|
|||
|
|
@ -3121,7 +3121,7 @@ when defined(haiku):
|
|||
B_FIND_PATH_IMAGE_PATH = 1000
|
||||
|
||||
proc find_path(codePointer: pointer, baseDirectory: cint, subPath: cstring,
|
||||
pathBuffer: cstring, bufferSize: csize): int32
|
||||
pathBuffer: cstring, bufferSize: csize_t): int32
|
||||
{.importc, header: "<FindDirectory.h>".}
|
||||
|
||||
proc getApplHaiku(): string =
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ when defined(haiku):
|
|||
proc find_paths_etc(architecture: cstring, baseDirectory: cint,
|
||||
subPath: cstring, flags: uint32,
|
||||
paths: var ptr UncheckedArray[cstring],
|
||||
pathCount: var csize): int32
|
||||
pathCount: var csize_t): int32
|
||||
{.importc, header: "<FindDirectory.h>".}
|
||||
proc free(p: pointer) {.importc, header: "<stdlib.h>".}
|
||||
|
||||
|
|
@ -137,7 +137,7 @@ iterator scanSSLCertificates*(useEnvVars = false): string =
|
|||
else:
|
||||
var
|
||||
paths: ptr UncheckedArray[cstring]
|
||||
size: csize
|
||||
size: csize_t
|
||||
let err = find_paths_etc(
|
||||
nil, B_FIND_PATH_DATA_DIRECTORY, "ssl/CARootCertificates.pem",
|
||||
B_FIND_PATH_EXISTING_ONLY, paths, size
|
||||
|
|
|
|||
|
|
@ -644,9 +644,9 @@ proc setForegroundColor*(f: File, fg: ForegroundColor, bright = false) =
|
|||
0, # fg8Bit not supported, see `enableTrueColors` instead.
|
||||
0] # unused
|
||||
if fg == fgDefault:
|
||||
discard setConsoleTextAttribute(h, toU16(old or defaultForegroundColor))
|
||||
discard setConsoleTextAttribute(h, cast[int16](cast[uint16](old) or cast[uint16](defaultForegroundColor)))
|
||||
else:
|
||||
discard setConsoleTextAttribute(h, toU16(old or lookup[fg]))
|
||||
discard setConsoleTextAttribute(h, cast[int16](cast[uint16](old) or cast[uint16](lookup[fg])))
|
||||
else:
|
||||
gFG = ord(fg)
|
||||
if bright: inc(gFG, 60)
|
||||
|
|
@ -673,9 +673,9 @@ proc setBackgroundColor*(f: File, bg: BackgroundColor, bright = false) =
|
|||
0, # bg8Bit not supported, see `enableTrueColors` instead.
|
||||
0] # unused
|
||||
if bg == bgDefault:
|
||||
discard setConsoleTextAttribute(h, toU16(old or defaultBackgroundColor))
|
||||
discard setConsoleTextAttribute(h, cast[int16](cast[uint16](old) or cast[uint16](defaultBackgroundColor)))
|
||||
else:
|
||||
discard setConsoleTextAttribute(h, toU16(old or lookup[bg]))
|
||||
discard setConsoleTextAttribute(h, cast[int16](cast[uint16](old) or cast[uint16](lookup[bg])))
|
||||
else:
|
||||
gBG = ord(bg)
|
||||
if bright: inc(gBG, 60)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue