Skip to content

Commit

Permalink
adjust addr for Nim 1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Vindaar committed Mar 4, 2024
1 parent 371c8f4 commit e5d708b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions impulse/fft/c_pocketfft/pocketfft.nim
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,12 @@ proc init*(_: typedesc[FFTPlanComplex], length: int): FFTPlanComplex =
func isOdd*(i: int): bool = (i and 1) == 1

type MemoryView*[T] = ptr UncheckedArray[T]
func toPtr*[T](ar: openArray[T]): MemoryView[T] = cast[ptr UncheckedArray[T]](ar[0].addr)
template address(arg: untyped): untyped =
when (NimMajor, NimMinor, NimPatch) >= (2, 0, 0):
arg.addr
else:
arg.unsafeAddr
func toPtr*[T](ar: openArray[T]): MemoryView[T] = cast[ptr UncheckedArray[T]](ar[0].address)

proc unpackFFT*(data: MemoryView[float]; outDat: MemoryView[Complex64], inLen: int) =
## 'Unpacks' a given FFT result from a call to `rfft_forward/backward` as returned
Expand Down Expand Up @@ -200,11 +205,11 @@ proc initNormalize*(kind: NormalizeKind, forward: bool, value: float, length: in

template callFFT(plan, fwd, bck, data, length, forward, norm: untyped): untyped =
if forward:
let err = fwd(plan.pocket, data[0].addr, norm.value)
let err = fwd(plan.pocket, data[0].address, norm.value)
if err != 0:
raise newException(Exception, "Forward FFT calculation failed.")
else:
let err = bck(plan.pocket, data[0].addr, norm.value)
let err = bck(plan.pocket, data[0].address, norm.value)
if err != 0:
raise newException(Exception, "Backward FFT calculation failed.")

Expand Down

0 comments on commit e5d708b

Please sign in to comment.