summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2019-11-27 16:24:21 +0100
committerGitHub <noreply@github.com>2019-11-27 16:24:21 +0100
commitfd85a5ae054ece9a1954428b135b1da00e410229 (patch)
tree90a9e603ee06597841e2debcb798d19d76d3eacb
parent80b508d33727a5b2fd8a3abd49df004e7d5c5138 (diff)
downloadNim-fd85a5ae054ece9a1954428b135b1da00e410229.tar.gz
more fixes for --cpu:avr [backport] (#12748)
-rw-r--r--lib/system/alloc.nim4
-rw-r--r--lib/system/deepcopy.nim5
-rw-r--r--lib/system/repr.nim2
-rw-r--r--lib/system/sets.nim2
4 files changed, 8 insertions, 5 deletions
diff --git a/lib/system/alloc.nim b/lib/system/alloc.nim
index efbd95089..c65abe5c2 100644
--- a/lib/system/alloc.nim
+++ b/lib/system/alloc.nim
@@ -137,10 +137,10 @@ const
   ]
 
 proc msbit(x: uint32): int {.inline.} =
-  let a = if x <= 0xff_ff:
+  let a = if x <= 0xff_ff'u32:
             (if x <= 0xff: 0 else: 8)
           else:
-            (if x <= 0xff_ff_ff: 16 else: 24)
+            (if x <= 0xff_ff_ff'u32: 16 else: 24)
   result = int(fsLookupTable[byte(x shr a)]) + a
 
 proc lsbit(x: uint32): int {.inline.} =
diff --git a/lib/system/deepcopy.nim b/lib/system/deepcopy.nim
index ed6115e3e..66a65cd34 100644
--- a/lib/system/deepcopy.nim
+++ b/lib/system/deepcopy.nim
@@ -7,10 +7,13 @@
 #    distribution, for details about the copyright.
 #
 
+const
+  TableSize = when sizeof(int) <= 2: 0xff else: 0xff_ffff
+
 type
   PtrTable = ptr object
     counter, max: int
-    data: array[0xff_ffff, (pointer, pointer)]
+    data: array[TableSize, (pointer, pointer)]
 
 template hashPtr(key: pointer): int = cast[int](key) shr 8
 template allocPtrTable: untyped =
diff --git a/lib/system/repr.nim b/lib/system/repr.nim
index 43bbc8bb6..cc5ba2fee 100644
--- a/lib/system/repr.nim
+++ b/lib/system/repr.nim
@@ -78,7 +78,7 @@ proc reprEnum(e: int, typ: PNimType): string {.compilerRtl.} =
   result = $e & " (invalid data!)"
 
 type
-  PByteArray = ptr array[0xffff, byte]
+  PByteArray = ptr UncheckedArray[byte] # array[0xffff, byte]
 
 proc addSetElem(result: var string, elem: int, typ: PNimType) {.benign.} =
   case typ.kind
diff --git a/lib/system/sets.nim b/lib/system/sets.nim
index fe414dac7..0df50957d 100644
--- a/lib/system/sets.nim
+++ b/lib/system/sets.nim
@@ -19,7 +19,7 @@ proc countBits32(n: uint32): int {.compilerproc.} =
   var v = uint32(n)
   v = v - ((v shr 1'u32) and 0x55555555'u32)
   v = (v and 0x33333333'u32) + ((v shr 2'u32) and 0x33333333'u32)
-  result = (((v + (v shr 4'u32) and 0xF0F0F0F'u32) * 0x1010101) shr 24'u32).int
+  result = (((v + (v shr 4'u32) and 0xF0F0F0F'u32) * 0x1010101'u32) shr 24'u32).int
 
 proc countBits64(n: uint64): int {.compilerproc, inline.} =
   # generic formula is from: https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel