ct-clmsn/nofi

Mini-review on bindings.nim

Opened this issue · 0 comments

  1. Since you reuse the cname exaclty, you can use importc without specifying the C name. Combining with push pragmas you get
{.deadCodeElim: on.}
{.push cdecl, importc.}
proc rofi_init*(provider:cstring) : int
proc rofi_finit*() : int
proc rofi_get_size*() : uint32
proc rofi_get_id*() : uint32
proc rofi_put*[T : SomeNumber](dst : ptr UncheckedArray[T], src : ptr UncheckedArray[T], size : uint64, id : uint32, flags : uint64) : int
proc rofi_iput*[T : SomeNumber](dst : ptr UncheckedArray[T], src : ptr UncheckedArray[T], size : uint64, id : uint32, flags : uint64) : int
proc rofi_get*[T : SomeNumber](dst : ptr UncheckedArray[T], src : ptr UncheckedArray[T], size : uint64, id : uint32, flags : uint64) : int 
proc rofi_iget*[T : SomeNumber](dst : ptr UncheckedArray[T], src : ptr UncheckedArray[T], size : uint64, id : uint32, flags : uint64) : int
proc rofi_isend*[T : SomeNumber](id: uint32, address : ptr UncheckedArray[T], size : uint64, flags : uint64) : int
proc rofi_irecv*[T : SomeNumber](id : uint32, address : ptr UncheckedArray[T], size : uint64, flags : uint64) : int
proc rofi_alloc*[T : SomeNumber](size : uint64, flags : uint64, buf : ptr ptr UncheckedArray[T]) : int
proc rofi_release*[T : SomeNumber](address : ptr UncheckedArray[T]) : int
proc rofi_barrier*() 
proc rofi_wait*() : int
proc rofi_get_remote_address*(address : pointer, id : uint64) : pointer
proc rofi_get_local_address_from_remote_address*(address : pointer, id : uint64) : pointer 
  1. Can you confirm the return values of your proc? In Nim int is the same size as a pointer so int32 on 32-bit and int64 on 64 bit. In contrast C int are usually int32 (and maybe 16-bit on some embedded platforms?), for C compat Nim provides cint. This has seldom impact due to C integer promotion rules but still.