mirror of
https://github.com/status-im/nim-stint.git
synced 2025-02-20 10:58:21 +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"
|
||||
size = getSize(x.data) div 8
|
||||
|
||||
{.pragma: restrict, codegenDecl: "$# __restrict__ $#".}
|
||||
{.pragma: restrict, codegenDecl: "$# __restrict $#".}
|
||||
let bytes {.restrict.}= cast[ptr array[size, byte]](x.unsafeaddr)
|
||||
|
||||
result = newString(2*size)
|
||||
|
@ -133,7 +133,7 @@ macro asSignedWordsZip*[T](
|
||||
# if we have multiple iterations to do
|
||||
if system.cpuEndian == bigEndian:
|
||||
result = quote do:
|
||||
{.pragma: restrict, codegenDecl: "$# __restrict__ $#".}
|
||||
{.pragma: restrict, codegenDecl: "$# __restrict $#".}
|
||||
let
|
||||
`next_x`{.restrict.} = cast[ptr `optim_type`](`x`.unsafeaddr)
|
||||
`next_y`{.restrict.} = cast[ptr `optim_type`](`y`.unsafeaddr)
|
||||
@ -143,7 +143,7 @@ macro asSignedWordsZip*[T](
|
||||
else:
|
||||
# Little-Endian, iteration in reverse
|
||||
result = quote do:
|
||||
{.pragma: restrict, codegenDecl: "$# __restrict__ $#".}
|
||||
{.pragma: restrict, codegenDecl: "$# __restrict $#".}
|
||||
let
|
||||
`next_x`{.restrict.} = cast[ptr `optim_type`](`x`.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:
|
||||
if ignoreEndianness or system.cpuEndian == bigEndian:
|
||||
result = quote do:
|
||||
{.pragma: restrict, codegenDecl: "$# __restrict__ $#".}
|
||||
{.pragma: restrict, codegenDecl: "$# __restrict $#".}
|
||||
let
|
||||
`inner_x`{.restrict.} = cast[ptr `optim_type`](`x`.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:
|
||||
# Little-Endian, iteration in reverse
|
||||
result = quote do:
|
||||
{.pragma: restrict, codegenDecl: "$# __restrict__ $#".}
|
||||
{.pragma: restrict, codegenDecl: "$# __restrict $#".}
|
||||
let
|
||||
`inner_x`{.restrict.} = cast[ptr `optim_type`](`x`.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:
|
||||
if ignoreEndianness or system.cpuEndian == bigEndian:
|
||||
result = quote do:
|
||||
{.pragma: restrict, codegenDecl: "$# __restrict__ $#".}
|
||||
{.pragma: restrict, codegenDecl: "$# __restrict $#".}
|
||||
let
|
||||
`inner_m`{.restrict.} = cast[ptr `optim_type`](`m`.addr)
|
||||
`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:
|
||||
# Little-Endian, iteration in reverse
|
||||
result = quote do:
|
||||
{.pragma: restrict, codegenDecl: "$# __restrict__ $#".}
|
||||
{.pragma: restrict, codegenDecl: "$# __restrict $#".}
|
||||
let
|
||||
`inner_m`{.restrict.} = cast[ptr `optim_type`](`m`.addr)
|
||||
`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:
|
||||
if ignoreEndianness or system.cpuEndian == bigEndian:
|
||||
result = quote do:
|
||||
{.pragma: restrict, codegenDecl: "$# __restrict__ $#".}
|
||||
{.pragma: restrict, codegenDecl: "$# __restrict $#".}
|
||||
let
|
||||
`inner_m`{.restrict.} = cast[ptr `optim_type`](`m`.addr)
|
||||
`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:
|
||||
# Little-Endian, iteration in reverse
|
||||
result = quote do:
|
||||
{.pragma: restrict, codegenDecl: "$# __restrict__ $#".}
|
||||
{.pragma: restrict, codegenDecl: "$# __restrict $#".}
|
||||
let
|
||||
`inner_m`{.restrict.} = cast[ptr `optim_type`](`m`.addr)
|
||||
`inner_x`{.restrict.} = cast[ptr `optim_type`](`x`.unsafeaddr)
|
||||
|
Loading…
x
Reference in New Issue
Block a user