fix #15617(fix compilation failure on -d:useMalloc --gc:none) (#17555)

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
This commit is contained in:
flywind 2021-03-31 02:15:14 +08:00 • committed by GitHub
commit 7c09e0c757
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View file

@ -57,6 +57,16 @@ elif defined(gogc):
elif (defined(nogc) or defined(gcDestructors)) and defined(useMalloc):
include system / mm / malloc
when defined(nogc):
proc GC_getStatistics(): string = ""
proc newObj(typ: PNimType, size: int): pointer {.compilerproc.} =
result = alloc0(size)
proc newSeq(typ: PNimType, len: int): pointer {.compilerproc.} =
result = newObj(typ, align(GenericSeqSize, typ.align) + len * typ.base.size)
cast[PGenericSeq](result).len = len
cast[PGenericSeq](result).reserved = len
elif defined(nogc):
include system / mm / none

6
tests/system/tgcnone.nim Normal file
View file

@ -0,0 +1,6 @@
discard """
matrix: "--gc:none -d:useMalloc"
"""
# bug #15617
let x = 4
doAssert x == 4