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
<file:///D:/Jeremy/Documents/WorkTemp/UtraviewDigitizer/AD12_16-Aug03_16_r0_64bit/uvAPI%20documentation/classuv_a_p_i.html>
*uv = new uvAPI
<file:///D:/Jeremy/Documents/WorkTemp/UtraviewDigitizer/AD12_16-Aug03_16_r0_64bit/uvAPI%20documentation/classuv_a_p_i.html>
;
unsigned char * sysMem = NULL;
error = uv->X_MemAlloc
<file:///D:/Jeremy/Documents/WorkTemp/UtraviewDigitizer/AD12_16-Aug03_16_r0_64bit/uvAPI%20documentation/classuv_a_p_i.html#a2870ffe019c6ca884675453a086af03c>
((void**)&sysMem, DIG_BLOCK_SIZE
<file:///D:/Jeremy/Documents/WorkTemp/UtraviewDigitizer/AD12_16-Aug03_16_r0_64bit/uvAPI%20documentation/uv_a_p_i_8h.html#aa01f88c9f438e3f8b74ee35c7ffd1ca0>
);
if (error)
{
std::cout << "failed to allocate block buffer" << std::endl;
return -1;
}
Here is my julia code:
DIG_BLOCK_SIZE = 1024 * 1024
block = Array{Cuchar}(DIG_BLOCK_SIZE)
if ccall((:x_MemAlloc,AcqSynth),Cint,(Ptr{Ptr{Void}},Csize_t),pointer(block
),DIG_BLOCK_SIZE)==1
error("Failed to allocate block buffer!")
end
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