mirror of
https://github.com/status-im/nim-stint.git
synced 2025-02-22 11:58:18 +00:00
Restrict pragma: use C, C++, VCC + GCC + LLVM compatible syntax (#41)
This commit is contained in:
parent
1b7423eacd
commit
1653a8815f
@ -262,7 +262,7 @@ func dumpHex*(x: Stint or StUint, order: static[Endianness]): string =
|
|||||||
hexChars = "0123456789abcdef"
|
hexChars = "0123456789abcdef"
|
||||||
size = getSize(x.data) div 8
|
size = getSize(x.data) div 8
|
||||||
|
|
||||||
{.pragma: restrict, codegenDecl: "$# __restrict__ $#".}
|
{.pragma: restrict, codegenDecl: "$# __restrict $#".}
|
||||||
let bytes {.restrict.}= cast[ptr array[size, byte]](x.unsafeaddr)
|
let bytes {.restrict.}= cast[ptr array[size, byte]](x.unsafeaddr)
|
||||||
|
|
||||||
result = newString(2*size)
|
result = newString(2*size)
|
||||||
|
@ -133,7 +133,7 @@ macro asSignedWordsZip*[T](
|
|||||||
# if we have multiple iterations to do
|
# if we have multiple iterations to do
|
||||||
if system.cpuEndian == bigEndian:
|
if system.cpuEndian == bigEndian:
|
||||||
result = quote do:
|
result = quote do:
|
||||||
{.pragma: restrict, codegenDecl: "$# __restrict__ $#".}
|
{.pragma: restrict, codegenDecl: "$# __restrict $#".}
|
||||||
let
|
let
|
||||||
`next_x`{.restrict.} = cast[ptr `optim_type`](`x`.unsafeaddr)
|
`next_x`{.restrict.} = cast[ptr `optim_type`](`x`.unsafeaddr)
|
||||||
`next_y`{.restrict.} = cast[ptr `optim_type`](`y`.unsafeaddr)
|
`next_y`{.restrict.} = cast[ptr `optim_type`](`y`.unsafeaddr)
|
||||||
@ -143,7 +143,7 @@ macro asSignedWordsZip*[T](
|
|||||||
else:
|
else:
|
||||||
# Little-Endian, iteration in reverse
|
# Little-Endian, iteration in reverse
|
||||||
result = quote do:
|
result = quote do:
|
||||||
{.pragma: restrict, codegenDecl: "$# __restrict__ $#".}
|
{.pragma: restrict, codegenDecl: "$# __restrict $#".}
|
||||||
let
|
let
|
||||||
`next_x`{.restrict.} = cast[ptr `optim_type`](`x`.unsafeaddr)
|
`next_x`{.restrict.} = cast[ptr `optim_type`](`x`.unsafeaddr)
|
||||||
`next_y`{.restrict.} = cast[ptr `optim_type`](`y`.unsafeaddr)
|
`next_y`{.restrict.} = cast[ptr `optim_type`](`y`.unsafeaddr)
|
||||||
|
@ -159,7 +159,7 @@ macro asWordsZip*(x, y: UintImpl or IntImpl, ignoreEndianness: static[bool], loo
|
|||||||
else:
|
else:
|
||||||
if ignoreEndianness or system.cpuEndian == bigEndian:
|
if ignoreEndianness or system.cpuEndian == bigEndian:
|
||||||
result = quote do:
|
result = quote do:
|
||||||
{.pragma: restrict, codegenDecl: "$# __restrict__ $#".}
|
{.pragma: restrict, codegenDecl: "$# __restrict $#".}
|
||||||
let
|
let
|
||||||
`inner_x`{.restrict.} = cast[ptr `optim_type`](`x`.unsafeaddr)
|
`inner_x`{.restrict.} = cast[ptr `optim_type`](`x`.unsafeaddr)
|
||||||
`inner_y`{.restrict.} = cast[ptr `optim_type`](`y`.unsafeaddr)
|
`inner_y`{.restrict.} = cast[ptr `optim_type`](`y`.unsafeaddr)
|
||||||
@ -168,7 +168,7 @@ macro asWordsZip*(x, y: UintImpl or IntImpl, ignoreEndianness: static[bool], loo
|
|||||||
else:
|
else:
|
||||||
# Little-Endian, iteration in reverse
|
# Little-Endian, iteration in reverse
|
||||||
result = quote do:
|
result = quote do:
|
||||||
{.pragma: restrict, codegenDecl: "$# __restrict__ $#".}
|
{.pragma: restrict, codegenDecl: "$# __restrict $#".}
|
||||||
let
|
let
|
||||||
`inner_x`{.restrict.} = cast[ptr `optim_type`](`x`.unsafeaddr)
|
`inner_x`{.restrict.} = cast[ptr `optim_type`](`x`.unsafeaddr)
|
||||||
`inner_y`{.restrict.} = cast[ptr `optim_type`](`y`.unsafeaddr)
|
`inner_y`{.restrict.} = cast[ptr `optim_type`](`y`.unsafeaddr)
|
||||||
@ -224,7 +224,7 @@ macro m_asWordsZip*[T: UintImpl or IntImpl](m: var T, x: T,
|
|||||||
else:
|
else:
|
||||||
if ignoreEndianness or system.cpuEndian == bigEndian:
|
if ignoreEndianness or system.cpuEndian == bigEndian:
|
||||||
result = quote do:
|
result = quote do:
|
||||||
{.pragma: restrict, codegenDecl: "$# __restrict__ $#".}
|
{.pragma: restrict, codegenDecl: "$# __restrict $#".}
|
||||||
let
|
let
|
||||||
`inner_m`{.restrict.} = cast[ptr `optim_type`](`m`.addr)
|
`inner_m`{.restrict.} = cast[ptr `optim_type`](`m`.addr)
|
||||||
`inner_x`{.restrict.} = cast[ptr `optim_type`](`x`.unsafeaddr)
|
`inner_x`{.restrict.} = cast[ptr `optim_type`](`x`.unsafeaddr)
|
||||||
@ -233,7 +233,7 @@ macro m_asWordsZip*[T: UintImpl or IntImpl](m: var T, x: T,
|
|||||||
else:
|
else:
|
||||||
# Little-Endian, iteration in reverse
|
# Little-Endian, iteration in reverse
|
||||||
result = quote do:
|
result = quote do:
|
||||||
{.pragma: restrict, codegenDecl: "$# __restrict__ $#".}
|
{.pragma: restrict, codegenDecl: "$# __restrict $#".}
|
||||||
let
|
let
|
||||||
`inner_m`{.restrict.} = cast[ptr `optim_type`](`m`.addr)
|
`inner_m`{.restrict.} = cast[ptr `optim_type`](`m`.addr)
|
||||||
`inner_x`{.restrict.} = cast[ptr `optim_type`](`x`.unsafeaddr)
|
`inner_x`{.restrict.} = cast[ptr `optim_type`](`x`.unsafeaddr)
|
||||||
@ -298,7 +298,7 @@ macro m_asWordsZip*[T: UintImpl or IntImpl](m: var T, x, y: T,
|
|||||||
else:
|
else:
|
||||||
if ignoreEndianness or system.cpuEndian == bigEndian:
|
if ignoreEndianness or system.cpuEndian == bigEndian:
|
||||||
result = quote do:
|
result = quote do:
|
||||||
{.pragma: restrict, codegenDecl: "$# __restrict__ $#".}
|
{.pragma: restrict, codegenDecl: "$# __restrict $#".}
|
||||||
let
|
let
|
||||||
`inner_m`{.restrict.} = cast[ptr `optim_type`](`m`.addr)
|
`inner_m`{.restrict.} = cast[ptr `optim_type`](`m`.addr)
|
||||||
`inner_x`{.restrict.} = cast[ptr `optim_type`](`x`.unsafeaddr)
|
`inner_x`{.restrict.} = cast[ptr `optim_type`](`x`.unsafeaddr)
|
||||||
@ -308,7 +308,7 @@ macro m_asWordsZip*[T: UintImpl or IntImpl](m: var T, x, y: T,
|
|||||||
else:
|
else:
|
||||||
# Little-Endian, iteration in reverse
|
# Little-Endian, iteration in reverse
|
||||||
result = quote do:
|
result = quote do:
|
||||||
{.pragma: restrict, codegenDecl: "$# __restrict__ $#".}
|
{.pragma: restrict, codegenDecl: "$# __restrict $#".}
|
||||||
let
|
let
|
||||||
`inner_m`{.restrict.} = cast[ptr `optim_type`](`m`.addr)
|
`inner_m`{.restrict.} = cast[ptr `optim_type`](`m`.addr)
|
||||||
`inner_x`{.restrict.} = cast[ptr `optim_type`](`x`.unsafeaddr)
|
`inner_x`{.restrict.} = cast[ptr `optim_type`](`x`.unsafeaddr)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user