fixes merge conflict
This commit is contained in:
commit
696c0c48c7
195 changed files with 2049 additions and 1344 deletions
|
|
@ -454,10 +454,10 @@ proc requestOsChunks(a: var MemRegion, size: int): PBigChunk =
|
|||
a.addHeapLink(result, size)
|
||||
when defined(debugHeapLinks):
|
||||
cprintf("owner: %p; result: %p; next pointer %p; size: %ld\n", addr(a),
|
||||
result, result.heapLink, result.origSize)
|
||||
result, result.heapLink, result.size)
|
||||
|
||||
when defined(memtracker):
|
||||
trackLocation(addr result.origSize, sizeof(int))
|
||||
trackLocation(addr result.size, sizeof(int))
|
||||
|
||||
sysAssert((cast[ByteAddress](result) and PageMask) == 0, "requestOsChunks 1")
|
||||
#zeroMem(result, size)
|
||||
|
|
@ -527,7 +527,7 @@ proc updatePrevSize(a: var MemRegion, c: PBigChunk,
|
|||
proc splitChunk2(a: var MemRegion, c: PBigChunk, size: int): PBigChunk =
|
||||
result = cast[PBigChunk](cast[ByteAddress](c) +% size)
|
||||
result.size = c.size - size
|
||||
track("result.origSize", addr result.origSize, sizeof(int))
|
||||
track("result.size", addr result.size, sizeof(int))
|
||||
# XXX check if these two nil assignments are dead code given
|
||||
# addChunkToMatrix's implementation:
|
||||
result.next = nil
|
||||
|
|
@ -602,7 +602,7 @@ proc getBigChunk(a: var MemRegion, size: int): PBigChunk =
|
|||
splitChunk(a, result, size)
|
||||
# set 'used' to to true:
|
||||
result.prevSize = 1
|
||||
track("setUsedToFalse", addr result.origSize, sizeof(int))
|
||||
track("setUsedToFalse", addr result.size, sizeof(int))
|
||||
|
||||
incl(a, a.chunkStarts, pageIndex(result))
|
||||
dec(a.freeMem, size)
|
||||
|
|
@ -968,7 +968,7 @@ proc deallocOsPages(a: var MemRegion) =
|
|||
let (p, size) = it.chunks[i]
|
||||
when defined(debugHeapLinks):
|
||||
cprintf("owner %p; dealloc A: %p size: %ld; next: %p\n", addr(a),
|
||||
it, it.origSize, next)
|
||||
it, it.size, next)
|
||||
sysAssert size >= PageSize, "origSize too small"
|
||||
osDeallocPages(p, size)
|
||||
it = next
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ when defined(windows):
|
|||
SIGTERM = cint(15)
|
||||
elif defined(macosx) or defined(linux) or defined(freebsd) or
|
||||
defined(openbsd) or defined(netbsd) or defined(solaris) or
|
||||
defined(dragonfly) or defined(nintendoswitch):
|
||||
defined(dragonfly) or defined(nintendoswitch) or defined(genode):
|
||||
const
|
||||
SIGABRT = cint(6)
|
||||
SIGFPE = cint(8)
|
||||
|
|
@ -59,6 +59,15 @@ elif defined(macosx) or defined(linux) or defined(freebsd) or
|
|||
SIGSEGV = cint(11)
|
||||
SIGTERM = cint(15)
|
||||
SIGPIPE = cint(13)
|
||||
elif defined(haiku):
|
||||
const
|
||||
SIGABRT = cint(6)
|
||||
SIGFPE = cint(8)
|
||||
SIGILL = cint(4)
|
||||
SIGINT = cint(2)
|
||||
SIGSEGV = cint(11)
|
||||
SIGTERM = cint(15)
|
||||
SIGPIPE = cint(7)
|
||||
else:
|
||||
when NoFakeVars:
|
||||
{.error: "SIGABRT not ported to your platform".}
|
||||
|
|
@ -74,6 +83,8 @@ else:
|
|||
|
||||
when defined(macosx):
|
||||
const SIGBUS = cint(10)
|
||||
elif defined(haiku):
|
||||
const SIGBUS = cint(30)
|
||||
else:
|
||||
template SIGBUS: untyped = SIGSEGV
|
||||
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ proc send*[TMsg](c: var Channel[TMsg], msg: TMsg) {.inline.} =
|
|||
proc trySend*[TMsg](c: var Channel[TMsg], msg: TMsg): bool {.inline.} =
|
||||
## Tries to send a message to a thread. `msg` is deeply copied. Doesn't block.
|
||||
## Returns `false` if the message was not sent because number of pending items
|
||||
## in the cannel exceeded `maxItems`.
|
||||
## in the channel exceeded `maxItems`.
|
||||
sendImpl(cast[PRawChannel](addr c), cast[PNimType](getTypeInfo(msg)), unsafeAddr(msg), true)
|
||||
|
||||
proc llRecv(q: PRawChannel, res: pointer, typ: PNimType) =
|
||||
|
|
|
|||
|
|
@ -31,7 +31,11 @@ proc showErrorMessage(data: cstring) {.gcsafe.} =
|
|||
if errorMessageWriter != nil:
|
||||
errorMessageWriter($data)
|
||||
else:
|
||||
writeToStdErr(data)
|
||||
when defined(genode):
|
||||
# stderr not available by default, use the LOG session
|
||||
echo data
|
||||
else:
|
||||
writeToStdErr(data)
|
||||
|
||||
proc quitOrDebug() {.inline.} =
|
||||
when not defined(endb):
|
||||
|
|
|
|||
|
|
@ -37,22 +37,28 @@ when defined(nimTypeNames):
|
|||
a[j] = v
|
||||
if h == 1: break
|
||||
|
||||
proc dumpNumberOfInstances* =
|
||||
# also add the allocated strings to the list of known types:
|
||||
iterator dumpHeapInstances*(): tuple[name: cstring; count: int; sizes: int] =
|
||||
## Iterate over summaries of types on heaps.
|
||||
## This data may be inaccurate if allocations
|
||||
## are made by the iterator body.
|
||||
if strDesc.nextType == nil:
|
||||
strDesc.nextType = nimTypeRoot
|
||||
strDesc.name = "string"
|
||||
nimTypeRoot = addr strDesc
|
||||
var it = nimTypeRoot
|
||||
while it != nil:
|
||||
if (it.instances > 0 or it.sizes != 0):
|
||||
yield (it.name, it.instances, it.sizes)
|
||||
it = it.nextType
|
||||
|
||||
proc dumpNumberOfInstances* =
|
||||
var a: InstancesInfo
|
||||
var n = 0
|
||||
var it = nimTypeRoot
|
||||
var totalAllocated = 0
|
||||
while it != nil:
|
||||
if (it.instances > 0 or it.sizes != 0) and n < a.len:
|
||||
a[n] = (it.name, it.instances, it.sizes)
|
||||
inc n
|
||||
for it in dumpHeapInstances():
|
||||
a[n] = it
|
||||
inc n
|
||||
inc totalAllocated, it.sizes
|
||||
it = it.nextType
|
||||
sortInstances(a, n)
|
||||
for i in 0 .. n-1:
|
||||
c_fprintf(stdout, "[Heap] %s: #%ld; bytes: %ld\n", a[i][0], a[i][1], a[i][2])
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ proc getStackTrace*(e: ref Exception): string = e.trace
|
|||
proc unhandledException(e: ref Exception) {.
|
||||
compilerproc, asmNoStackFrame.} =
|
||||
var buf = ""
|
||||
if e.msg != nil and e.msg[0] != '\0':
|
||||
if e.msg.len != 0:
|
||||
add(buf, "Error: unhandled exception: ")
|
||||
add(buf, e.msg)
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -73,12 +73,12 @@ proc addEntry(entry: LogEntry) =
|
|||
let x = cast[proc() {.nimcall, tags: [], gcsafe, locks: 0.}](writeStackTrace)
|
||||
x()
|
||||
quit 1
|
||||
if gLog.count > high(gLog.data):
|
||||
gLogger(gLog)
|
||||
gLog.count = 0
|
||||
gLog.data[gLog.count] = entry
|
||||
inc gLog.count
|
||||
gLog.disabled = false
|
||||
#if gLog.count > high(gLog.data):
|
||||
# gLogger(gLog)
|
||||
# gLog.count = 0
|
||||
#gLog.data[gLog.count] = entry
|
||||
#inc gLog.count
|
||||
#gLog.disabled = false
|
||||
|
||||
proc memTrackerWrite(address: pointer; size: int; file: cstring; line: int) {.compilerProc.} =
|
||||
addEntry LogEntry(op: "write", address: address,
|
||||
|
|
|
|||
|
|
@ -207,6 +207,9 @@ elif defined(posix):
|
|||
# some arches like mips and alpha use different values
|
||||
const MAP_ANONYMOUS = 0x20
|
||||
const MAP_PRIVATE = 0x02 # Changes are private
|
||||
elif defined(haiku):
|
||||
const MAP_ANONYMOUS = 0x08
|
||||
const MAP_PRIVATE = 0x02
|
||||
else:
|
||||
var
|
||||
MAP_ANONYMOUS {.importc: "MAP_ANONYMOUS", header: "<sys/mman.h>".}: cint
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ proc copyStrLast(s: NimString, start, last: int): NimString {.compilerProc.} =
|
|||
# This is not used by most recent versions of the compiler anymore, but
|
||||
# required for bootstrapping purposes.
|
||||
let start = max(start, 0)
|
||||
if s == nil: return nil
|
||||
let len = min(last, s.len-1) - start + 1
|
||||
if len > 0:
|
||||
result = rawNewStringNoInit(len)
|
||||
|
|
@ -78,6 +79,7 @@ proc copyStrLast(s: NimString, start, last: int): NimString {.compilerProc.} =
|
|||
proc copyStr(s: NimString, start: int): NimString {.compilerProc.} =
|
||||
# This is not used by most recent versions of the compiler anymore, but
|
||||
# required for bootstrapping purposes.
|
||||
if s == nil: return nil
|
||||
result = copyStrLast(s, start, s.len-1)
|
||||
|
||||
proc nimToCStringConv(s: NimString): cstring {.compilerProc, inline.} =
|
||||
|
|
|
|||
|
|
@ -162,10 +162,12 @@ elif defined(genode):
|
|||
mainTls
|
||||
|
||||
else:
|
||||
when not defined(macosx):
|
||||
when not (defined(macosx) or defined(haiku)):
|
||||
{.passL: "-pthread".}
|
||||
|
||||
{.passC: "-pthread".}
|
||||
when not defined(haiku):
|
||||
{.passC: "-pthread".}
|
||||
|
||||
const
|
||||
schedh = "#define _GNU_SOURCE\n#include <sched.h>"
|
||||
pthreadh = "#define _GNU_SOURCE\n#include <pthread.h>"
|
||||
|
|
@ -714,3 +716,13 @@ elif defined(solaris):
|
|||
if threadId == 0:
|
||||
threadId = int(thr_self())
|
||||
result = threadId
|
||||
|
||||
elif defined(haiku):
|
||||
type thr_id {.importc: "thread_id", header: "<OS.h>".} = distinct int32
|
||||
proc find_thread(name: cstring): thr_id {.importc, header: "<OS.h>".}
|
||||
|
||||
proc getThreadId*(): int =
|
||||
## get the ID of the currently running thread.
|
||||
if threadId == 0:
|
||||
threadId = int(find_thread(nil))
|
||||
result = threadId
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue