On Oct 5, 2016 12:51 PM, "Jérémy Béjanin" <[email protected]> wrote:
>
> Hello,
>
> I am trying to call a DLL function to allocate a page aligned array from
julia. Here is a C++ example using that function. Note that the DLL
function is wrapped into this uvAPI api, but is otherwise the same except
for the name. The DLL function is called x_MemAlloc, while the API function
is called X_MemAlloc. The function should return 0 on success, or 1 on
failure.
>
> #define DIG_BLOCK_SIZE 1024 * 1024
>
> uvAPI *uv = new uvAPI;
> unsigned char * sysMem = NULL;
> error = uv->X_MemAlloc((void**)&sysMem, DIG_BLOCK_SIZE);
> if (error)
> {
>  std::cout << "failed to allocate block buffer" << std::endl;
>  return  -1;
> }
>
> Here is my julia code:
>
> DIG_BLOCK_SIZE = 1024 * 1024
out = Ref{Ptr{Cuchar}}()
if
ccall((:x_MemAlloc,AcqSynth),Cint,(Ptr{Ptr{Cuchar}},Csize_t),out,DIG_BLOCK_SIZE)==1
>     error("Failed to allocate block buffer!")
> end

block = pointer_to_array(out[], DIG_BLOCK_SIZE)

# add finalizer

>
> However, the function returns 1 whether I use Ptr{Void} and block, or
Ptr{Ptr{Void}} and pointer(block). Is this the proper translation?
>
> I am trying the acquire data with a PCIe digitizer and currently reading
out the data into the buffer does not work. I am wondering if this is
because the buffer is not allocated properly.
>
> Note that other DLL functions I've tried work properly.
>
> Thanks,
> Jeremy

Reply via email to