Merge branch 'devel' of https://github.com/nim-lang/Nim into devel
This commit is contained in:
commit
1fbeedaba2
18 changed files with 325 additions and 222 deletions
|
|
@ -12,7 +12,7 @@
|
|||
## report at program exit.
|
||||
|
||||
when not defined(profiler) and not defined(memProfiler):
|
||||
{.warning: "Profiling support is turned off!".}
|
||||
{.error: "Profiling support is turned off! Enable profiling by passing `--profiler:on --stackTrace:on` to the compiler (see the Nim Compiler User Guide for more options).".}
|
||||
|
||||
# We don't want to profile the profiling code ...
|
||||
{.push profiler: off.}
|
||||
|
|
|
|||
|
|
@ -886,7 +886,7 @@ elif not defined(useNimRtl):
|
|||
discard write(data.pErrorPipe[writeIdx], addr error, sizeof(error))
|
||||
exitnow(1)
|
||||
|
||||
when defined(macosx) or defined(freebsd) or defined(netbsd) or defined(android):
|
||||
when not defined(uClibc) and (not defined(linux) or defined(android)):
|
||||
var environ {.importc.}: cstringArray
|
||||
|
||||
proc startProcessAfterFork(data: ptr StartProcessData) =
|
||||
|
|
@ -916,17 +916,16 @@ elif not defined(useNimRtl):
|
|||
discard fcntl(data.pErrorPipe[writeIdx], F_SETFD, FD_CLOEXEC)
|
||||
|
||||
if data.optionPoUsePath:
|
||||
when defined(macosx) or defined(freebsd) or defined(netbsd) or defined(android):
|
||||
when defined(uClibc):
|
||||
# uClibc environment (OpenWrt included) doesn't have the full execvpe
|
||||
discard execve(data.sysCommand, data.sysArgs, data.sysEnv)
|
||||
elif defined(linux) and not defined(android):
|
||||
discard execvpe(data.sysCommand, data.sysArgs, data.sysEnv)
|
||||
else:
|
||||
# MacOSX doesn't have execvpe, so we need workaround.
|
||||
# On MacOSX we can arrive here only from fork, so this is safe:
|
||||
environ = data.sysEnv
|
||||
discard execvp(data.sysCommand, data.sysArgs)
|
||||
else:
|
||||
when defined(uClibc):
|
||||
# uClibc environment (OpenWrt included) doesn't have the full execvpe
|
||||
discard execve(data.sysCommand, data.sysArgs, data.sysEnv)
|
||||
else:
|
||||
discard execvpe(data.sysCommand, data.sysArgs, data.sysEnv)
|
||||
else:
|
||||
discard execve(data.sysCommand, data.sysArgs, data.sysEnv)
|
||||
|
||||
|
|
|
|||
|
|
@ -148,7 +148,10 @@ proc write*[T](s: Stream, x: T) =
|
|||
proc write*(s: Stream, x: string) =
|
||||
## writes the string `x` to the the stream `s`. No length field or
|
||||
## terminating zero is written.
|
||||
writeData(s, cstring(x), x.len)
|
||||
when nimvm:
|
||||
writeData(s, cstring(x), x.len)
|
||||
else:
|
||||
if x.len > 0: writeData(s, unsafeAddr x[0], x.len)
|
||||
|
||||
proc writeLn*(s: Stream, args: varargs[string, `$`]) {.deprecated.} =
|
||||
## **Deprecated since version 0.11.4:** Use **writeLine** instead.
|
||||
|
|
|
|||
|
|
@ -688,7 +688,7 @@ proc rawDealloc(a: var MemRegion, p: pointer) =
|
|||
sysAssert(((cast[ByteAddress](p) and PageMask) - smallChunkOverhead()) %%
|
||||
s == 0, "rawDealloc 3")
|
||||
var f = cast[ptr FreeCell](p)
|
||||
#echo("setting to nil: ", $cast[TAddress](addr(f.zeroField)))
|
||||
#echo("setting to nil: ", $cast[ByteAddress](addr(f.zeroField)))
|
||||
sysAssert(f.zeroField != 0, "rawDealloc 1")
|
||||
f.zeroField = 0
|
||||
f.next = c.freeList
|
||||
|
|
|
|||
|
|
@ -659,7 +659,7 @@ when useMarkForDebug or useBackupGc:
|
|||
proc stackMarkS(gch: var GcHeap, p: pointer) {.inline.} =
|
||||
# the addresses are not as cells on the stack, so turn them to cells:
|
||||
var cell = usrToCell(p)
|
||||
var c = cast[TAddress](cell)
|
||||
var c = cast[ByteAddress](cell)
|
||||
if c >% PageSize:
|
||||
# fast check: does it look like a cell?
|
||||
var objStart = cast[PCell](interiorAllocatedPtr(gch.region, cell))
|
||||
|
|
@ -805,8 +805,8 @@ proc markThreadStacks(gch: var GcHeap) =
|
|||
while it != nil:
|
||||
# mark registers:
|
||||
for i in 0 .. high(it.registers): gcMark(gch, it.registers[i])
|
||||
var sp = cast[TAddress](it.stackBottom)
|
||||
var max = cast[TAddress](it.stackTop)
|
||||
var sp = cast[ByteAddress](it.stackBottom)
|
||||
var max = cast[ByteAddress](it.stackTop)
|
||||
# XXX stack direction?
|
||||
# XXX unroll this loop:
|
||||
while sp <=% max:
|
||||
|
|
|
|||
|
|
@ -131,9 +131,9 @@ when defined(sparc): # For SPARC architecture.
|
|||
proc isOnStack(p: pointer): bool =
|
||||
var stackTop {.volatile.}: pointer
|
||||
stackTop = addr(stackTop)
|
||||
var b = cast[TAddress](gch.stackBottom)
|
||||
var a = cast[TAddress](stackTop)
|
||||
var x = cast[TAddress](p)
|
||||
var b = cast[ByteAddress](gch.stackBottom)
|
||||
var a = cast[ByteAddress](stackTop)
|
||||
var x = cast[ByteAddress](p)
|
||||
result = a <=% x and x <=% b
|
||||
|
||||
template forEachStackSlot(gch, gcMark: expr) {.immediate, dirty.} =
|
||||
|
|
@ -150,7 +150,7 @@ when defined(sparc): # For SPARC architecture.
|
|||
# Addresses decrease as the stack grows.
|
||||
while sp <= max:
|
||||
gcMark(gch, sp[])
|
||||
sp = cast[PPointer](cast[TAddress](sp) +% sizeof(pointer))
|
||||
sp = cast[PPointer](cast[ByteAddress](sp) +% sizeof(pointer))
|
||||
|
||||
elif defined(ELATE):
|
||||
{.error: "stack marking code is to be written for this architecture".}
|
||||
|
|
|
|||
|
|
@ -165,15 +165,46 @@ proc SetConstr() {.varargs, asmNoStackFrame, compilerproc.} =
|
|||
return result;
|
||||
"""
|
||||
|
||||
proc makeNimstrLit(c: cstring): string {.asmNoStackFrame, compilerproc.} =
|
||||
{.emit: """
|
||||
var ln = `c`.length;
|
||||
var result = new Array(ln + 1);
|
||||
var i = 0;
|
||||
for (; i < ln; ++i) {
|
||||
result[i] = `c`.charCodeAt(i);
|
||||
}
|
||||
result[i] = 0; // terminating zero
|
||||
return result;
|
||||
""".}
|
||||
|
||||
proc cstrToNimstr(c: cstring): string {.asmNoStackFrame, compilerproc.} =
|
||||
asm """
|
||||
var result = [];
|
||||
for (var i = 0; i < `c`.length; ++i) {
|
||||
result[i] = `c`.charCodeAt(i);
|
||||
{.emit: """
|
||||
var ln = `c`.length;
|
||||
var result = new Array(ln);
|
||||
var r = 0;
|
||||
for (var i = 0; i < ln; ++i) {
|
||||
var ch = `c`.charCodeAt(i);
|
||||
|
||||
if (ch < 128) {
|
||||
result[r] = ch;
|
||||
}
|
||||
result[result.length] = 0; // terminating zero
|
||||
return result;
|
||||
"""
|
||||
else if((ch > 127) && (ch < 2048)) {
|
||||
result[r] = (ch >> 6) | 192;
|
||||
++r;
|
||||
result[r] = (ch & 63) | 128;
|
||||
}
|
||||
else {
|
||||
result[r] = (ch >> 12) | 224;
|
||||
++r;
|
||||
result[r] = ((ch >> 6) & 63) | 128;
|
||||
++r;
|
||||
result[r] = (ch & 63) | 128;
|
||||
}
|
||||
++r;
|
||||
}
|
||||
result[r] = 0; // terminating zero
|
||||
return result;
|
||||
""".}
|
||||
|
||||
proc toJSStr(s: string): cstring {.asmNoStackFrame, compilerproc.} =
|
||||
asm """
|
||||
|
|
@ -417,42 +448,6 @@ proc absInt(a: int): int {.compilerproc.} =
|
|||
proc absInt64(a: int64): int64 {.compilerproc.} =
|
||||
result = if a < 0: a*(-1) else: a
|
||||
|
||||
proc leU(a, b: int): bool {.compilerproc.} =
|
||||
result = abs(a) <= abs(b)
|
||||
|
||||
proc ltU(a, b: int): bool {.compilerproc.} =
|
||||
result = abs(a) < abs(b)
|
||||
|
||||
proc leU64(a, b: int64): bool {.compilerproc.} =
|
||||
result = abs(a) <= abs(b)
|
||||
proc ltU64(a, b: int64): bool {.compilerproc.} =
|
||||
result = abs(a) < abs(b)
|
||||
|
||||
proc addU(a, b: int): int {.compilerproc.} =
|
||||
result = abs(a) + abs(b)
|
||||
proc addU64(a, b: int64): int64 {.compilerproc.} =
|
||||
result = abs(a) + abs(b)
|
||||
|
||||
proc subU(a, b: int): int {.compilerproc.} =
|
||||
result = abs(a) - abs(b)
|
||||
proc subU64(a, b: int64): int64 {.compilerproc.} =
|
||||
result = abs(a) - abs(b)
|
||||
|
||||
proc mulU(a, b: int): int {.compilerproc.} =
|
||||
result = abs(a) * abs(b)
|
||||
proc mulU64(a, b: int64): int64 {.compilerproc.} =
|
||||
result = abs(a) * abs(b)
|
||||
|
||||
proc divU(a, b: int): int {.compilerproc.} =
|
||||
result = abs(a) div abs(b)
|
||||
proc divU64(a, b: int64): int64 {.compilerproc.} =
|
||||
result = abs(a) div abs(b)
|
||||
|
||||
proc modU(a, b: int): int {.compilerproc.} =
|
||||
result = abs(a) mod abs(b)
|
||||
proc modU64(a, b: int64): int64 {.compilerproc.} =
|
||||
result = abs(a) mod abs(b)
|
||||
|
||||
proc ze*(a: int): int {.compilerproc.} =
|
||||
result = a
|
||||
|
||||
|
|
|
|||
|
|
@ -496,13 +496,12 @@ type
|
|||
data: array[MD5_LBLOCK, MD5_LONG]
|
||||
num: cuint
|
||||
|
||||
{.pragma: ic, importc: "$1".}
|
||||
{.push callconv:cdecl, dynlib:DLLUtilName.}
|
||||
proc md5_Init*(c: var MD5_CTX): cint{.ic.}
|
||||
proc md5_Update*(c: var MD5_CTX; data: pointer; len: csize): cint{.ic.}
|
||||
proc md5_Final*(md: cstring; c: var MD5_CTX): cint{.ic.}
|
||||
proc md5*(d: ptr cuchar; n: csize; md: ptr cuchar): ptr cuchar{.ic.}
|
||||
proc md5_Transform*(c: var MD5_CTX; b: ptr cuchar){.ic.}
|
||||
proc md5_Init*(c: var MD5_CTX): cint{.importc: "MD5_Init".}
|
||||
proc md5_Update*(c: var MD5_CTX; data: pointer; len: csize): cint{.importc: "MD5_Update".}
|
||||
proc md5_Final*(md: cstring; c: var MD5_CTX): cint{.importc: "MD5_Final".}
|
||||
proc md5*(d: ptr cuchar; n: csize; md: ptr cuchar): ptr cuchar{.importc: "MD5".}
|
||||
proc md5_Transform*(c: var MD5_CTX; b: ptr cuchar){.importc: "MD5_Transform".}
|
||||
{.pop.}
|
||||
|
||||
from strutils import toHex,toLower
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue