Skip to content

Commit

Permalink
Merge pull request #10 from samuelpowell/wordsize
Browse files Browse the repository at this point in the history
Guard C long definitions on platforms where these are 32-bit
  • Loading branch information
samuelpowell committed Oct 10, 2019
2 parents 49e763e + 198bd26 commit 14b3365
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 22 deletions.
42 changes: 28 additions & 14 deletions gen/liblsl_api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,10 @@ function lsl_push_sample_d(out, data)
ccall((:lsl_push_sample_d, liblsl), Int32, (lsl_outlet, Ptr{Cdouble}), out, data)
end

function lsl_push_sample_l(out, data)
ccall((:lsl_push_sample_l, liblsl), Int32, (lsl_outlet, Ptr{Clong}), out, data)
@static if !Sys.iswindows() && Sys.WORD_SIZE == 64
function lsl_push_sample_l(out, data)
ccall((:lsl_push_sample_l, liblsl), Int32, (lsl_outlet, Ptr{Clong}), out, data)
end
end

function lsl_push_sample_i(out, data)
Expand All @@ -161,8 +163,10 @@ function lsl_push_sample_dt(out, data, timestamp)
ccall((:lsl_push_sample_dt, liblsl), Int32, (lsl_outlet, Ptr{Cdouble}, Cdouble), out, data, timestamp)
end

function lsl_push_sample_lt(out, data, timestamp)
ccall((:lsl_push_sample_lt, liblsl), Int32, (lsl_outlet, Ptr{Clong}, Cdouble), out, data, timestamp)
@static if !Sys.iswindows() && Sys.WORD_SIZE == 64
function lsl_push_sample_lt(out, data, timestamp)
ccall((:lsl_push_sample_lt, liblsl), Int32, (lsl_outlet, Ptr{Clong}, Cdouble), out, data, timestamp)
end
end

function lsl_push_sample_it(out, data, timestamp)
Expand Down Expand Up @@ -233,8 +237,10 @@ function lsl_push_chunk_d(out, data, data_elements)
ccall((:lsl_push_chunk_d, liblsl), Int32, (lsl_outlet, Ptr{Cdouble}, Culong), out, data, data_elements)
end

function lsl_push_chunk_l(out, data, data_elements)
ccall((:lsl_push_chunk_l, liblsl), Int32, (lsl_outlet, Ptr{Clong}, Culong), out, data, data_elements)
@static if !Sys.iswindows() && Sys.WORD_SIZE == 64
function lsl_push_chunk_l(out, data, data_elements)
ccall((:lsl_push_chunk_l, liblsl), Int32, (lsl_outlet, Ptr{Clong}, Culong), out, data, data_elements)
end
end

function lsl_push_chunk_i(out, data, data_elements)
Expand Down Expand Up @@ -285,8 +291,10 @@ function lsl_push_chunk_dtp(out, data, data_elements, timestamp, pushthrough)
ccall((:lsl_push_chunk_dtp, liblsl), Int32, (lsl_outlet, Ptr{Cdouble}, Culong, Cdouble, Int32), out, data, data_elements, timestamp, pushthrough)
end

function lsl_push_chunk_ltp(out, data, data_elements, timestamp, pushthrough)
ccall((:lsl_push_chunk_ltp, liblsl), Int32, (lsl_outlet, Ptr{Clong}, Culong, Cdouble, Int32), out, data, data_elements, timestamp, pushthrough)
@static if !Sys.iswindows() && Sys.WORD_SIZE == 64
function lsl_push_chunk_ltp(out, data, data_elements, timestamp, pushthrough)
ccall((:lsl_push_chunk_ltp, liblsl), Int32, (lsl_outlet, Ptr{Clong}, Culong, Cdouble, Int32), out, data, data_elements, timestamp, pushthrough)
end
end

function lsl_push_chunk_itp(out, data, data_elements, timestamp, pushthrough)
Expand Down Expand Up @@ -341,8 +349,10 @@ function lsl_push_chunk_dtnp(out, data, data_elements, timestamps, pushthrough)
ccall((:lsl_push_chunk_dtnp, liblsl), Int32, (lsl_outlet, Ptr{Cdouble}, Culong, Ptr{Cdouble}, Int32), out, data, data_elements, timestamps, pushthrough)
end

function lsl_push_chunk_ltnp(out, data, data_elements, timestamps, pushthrough)
ccall((:lsl_push_chunk_ltnp, liblsl), Int32, (lsl_outlet, Ptr{Clong}, Culong, Ptr{Cdouble}, Int32), out, data, data_elements, timestamps, pushthrough)
@static if !Sys.iswindows() && Sys.WORD_SIZE == 64
function lsl_push_chunk_ltnp(out, data, data_elements, timestamps, pushthrough)
ccall((:lsl_push_chunk_ltnp, liblsl), Int32, (lsl_outlet, Ptr{Clong}, Culong, Ptr{Cdouble}, Int32), out, data, data_elements, timestamps, pushthrough)
end
end

function lsl_push_chunk_itnp(out, data, data_elements, timestamps, pushthrough)
Expand Down Expand Up @@ -433,8 +443,10 @@ function lsl_pull_sample_d(in, buffer, buffer_elements, timeout, ec)
ccall((:lsl_pull_sample_d, liblsl), Cdouble, (lsl_inlet, Ptr{Cdouble}, Int32, Cdouble, Ptr{Int32}), in, buffer, buffer_elements, timeout, ec)
end

function lsl_pull_sample_l(in, buffer, buffer_elements, timeout, ec)
ccall((:lsl_pull_sample_l, liblsl), Cdouble, (lsl_inlet, Ptr{Clong}, Int32, Cdouble, Ptr{Int32}), in, buffer, buffer_elements, timeout, ec)
@static if !Sys.iswindows() && Sys.WORD_SIZE == 64
function lsl_pull_sample_l(in, buffer, buffer_elements, timeout, ec)
ccall((:lsl_pull_sample_l, liblsl), Cdouble, (lsl_inlet, Ptr{Clong}, Int32, Cdouble, Ptr{Int32}), in, buffer, buffer_elements, timeout, ec)
end
end

function lsl_pull_sample_i(in, buffer, buffer_elements, timeout, ec)
Expand Down Expand Up @@ -469,8 +481,10 @@ function lsl_pull_chunk_d(in, data_buffer, timestamp_buffer, data_buffer_element
ccall((:lsl_pull_chunk_d, liblsl), Culong, (lsl_inlet, Ptr{Cdouble}, Ptr{Cdouble}, Culong, Culong, Cdouble, Ptr{Int32}), in, data_buffer, timestamp_buffer, data_buffer_elements, timestamp_buffer_elements, timeout, ec)
end

function lsl_pull_chunk_l(in, data_buffer, timestamp_buffer, data_buffer_elements, timestamp_buffer_elements, timeout, ec)
ccall((:lsl_pull_chunk_l, liblsl), Culong, (lsl_inlet, Ptr{Clong}, Ptr{Cdouble}, Culong, Culong, Cdouble, Ptr{Int32}), in, data_buffer, timestamp_buffer, data_buffer_elements, timestamp_buffer_elements, timeout, ec)
@static if !Sys.iswindows() && Sys.WORD_SIZE == 64
function lsl_pull_chunk_l(in, data_buffer, timestamp_buffer, data_buffer_elements, timestamp_buffer_elements, timeout, ec)
ccall((:lsl_pull_chunk_l, liblsl), Culong, (lsl_inlet, Ptr{Clong}, Ptr{Cdouble}, Culong, Culong, Cdouble, Ptr{Int32}), in, data_buffer, timestamp_buffer, data_buffer_elements, timestamp_buffer_elements, timeout, ec)
end
end

function lsl_pull_chunk_i(in, data_buffer, timestamp_buffer, data_buffer_elements, timestamp_buffer_elements, timeout, ec)
Expand Down
1 change: 1 addition & 0 deletions gen/wrap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# Note: in current wrap the following manual changes are made
# 1. Remove duplicate signature
# 2. Change signature of push/pull const *char to Cchar from Cstring
# 3. Guard Clong functions with @static if !Sys.iswindows() && Sys.WORD_SIZE == 64

@info("NOTE MANUAL CHANGES in deps/wrap.jl")

Expand Down
8 changes: 6 additions & 2 deletions src/StreamInlet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ end
# Type mapping
_lsl_pull_sample(i, d::Vector{Float32}, to, ec) = lsl_pull_sample_f(i, d, length(d), to, ec)
_lsl_pull_sample(i, d::Vector{Float64}, to, ec) = lsl_pull_sample_d(i, d, length(d), to, ec)
_lsl_pull_sample(i, d::Vector{Clong}, to, ec) = lsl_pull_sample_l(i, d, length(d), to, ec)
@static if !Sys.iswindows() && Sys.WORD_SIZE == 64
_lsl_pull_sample(i, d::Vector{Clong}, to, ec) = lsl_pull_sample_l(i, d, length(d), to, ec)
end
_lsl_pull_sample(i, d::Vector{Int32}, to, ec) = lsl_pull_sample_i(i, d, length(d), to, ec)
_lsl_pull_sample(i, d::Vector{Int16}, to, ec) = lsl_pull_sample_s(i, d, length(d), to, ec)
_lsl_pull_sample(i, d::Vector{Cchar}, to, ec) = lsl_pull_sample_c(i, d, length(d), to, ec)
Expand Down Expand Up @@ -222,7 +224,9 @@ end
# Type mapping
_lsl_pull_chunk(i, d::VecOrMat{Float32}, ts, to, ec) = lsl_pull_chunk_f(i, d, ts, length(d), length(ts), to, ec)
_lsl_pull_chunk(i, d::VecOrMat{Float64}, ts, to, ec) = lsl_pull_chunk_d(i, d, ts, length(d), length(ts), to, ec)
_lsl_pull_chunk(i, d::VecOrMat{Clong}, ts, to, ec) = lsl_pull_chunk_l(i, d, ts, length(d), length(ts), to, ec)
@static if !Sys.iswindows() && Sys.WORD_SIZE == 64
_lsl_pull_chunk(i, d::VecOrMat{Clong}, ts, to, ec) = lsl_pull_chunk_l(i, d, ts, length(d), length(ts), to, ec)
end
_lsl_pull_chunk(i, d::VecOrMat{Int32}, ts, to, ec) = lsl_pull_chunk_i(i, d, ts, length(d), length(ts), to, ec)
_lsl_pull_chunk(i, d::VecOrMat{Int16}, ts, to, ec) = lsl_pull_chunk_s(i, d, ts, length(d), length(ts), to, ec)
_lsl_pull_chunk(i, d::VecOrMat{Cchar}, ts, to, ec) = lsl_pull_chunk_c(i, d, ts, length(d), length(ts), to, ec)
Expand Down
12 changes: 9 additions & 3 deletions src/StreamOutlet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ const _lsl_typestring_map = Dict{DataType, String}(Float32 => "f",

_lsl_push_sample_tp(o, d::Vector{Float32}, ts, pt) = lsl_push_sample_ftp(o, d, ts, pt)
_lsl_push_sample_tp(o, d::Vector{Float64}, ts, pt) = lsl_push_sample_dtp(o, d, ts, pt)
_lsl_push_sample_tp(o, d::Vector{Clong}, ts, pt) = lsl_push_sample_ltp(o, d, ts, pt)
@static if !Sys.iswindows() && Sys.WORD_SIZE == 64
_lsl_push_sample_tp(o, d::Vector{Clong}, ts, pt) = lsl_push_sample_ltp(o, d, ts, pt)
end
_lsl_push_sample_tp(o, d::Vector{Int32}, ts, pt) = lsl_push_sample_itp(o, d, ts, pt)
_lsl_push_sample_tp(o, d::Vector{Int16}, ts, pt) = lsl_push_sample_stp(o, d, ts, pt)
_lsl_push_sample_tp(o, d::Vector{Cchar}, ts, pt) = lsl_push_sample_ctp(o, d, ts, pt)
Expand Down Expand Up @@ -119,7 +121,9 @@ end
# Type mappings
_lsl_push_chunk_tp(o, d::Matrix{Float32}, ts::Number, pt) = lsl_push_chunk_ftp(o, d, length(d), ts, pt)
_lsl_push_chunk_tp(o, d::Matrix{Float64}, ts::Number, pt) = lsl_push_chunk_dtp(o, d, length(d), ts, pt)
_lsl_push_chunk_tp(o, d::Matrix{Clong}, ts::Number, pt) = lsl_push_chunk_ltp(o, d, length(d), ts, pt)
@static if !Sys.iswindows() && Sys.WORD_SIZE == 64
_lsl_push_chunk_tp(o, d::Matrix{Clong}, ts::Number, pt) = lsl_push_chunk_ltp(o, d, length(d), ts, pt)
end
_lsl_push_chunk_tp(o, d::Matrix{Int32}, ts::Number, pt) = lsl_push_chunk_itp(o, d, length(d), ts, pt)
_lsl_push_chunk_tp(o, d::Matrix{Int16}, ts::Number, pt) = lsl_push_chunk_stp(o, d, length(d), ts, pt)
_lsl_push_chunk_tp(o, d::Matrix{Cchar}, ts::Number, pt) = lsl_push_chunk_ctp(o, d, length(d), ts, pt)
Expand All @@ -128,7 +132,9 @@ _lsl_push_chunk_tp(o, d::Matrix{Cvoid}, ts::Number, pt) = lsl_push_chunk_vtp(o

_lsl_push_chunk_tnp(o, d::Matrix{Float32}, ts::Vector, pt) = lsl_push_chunk_ftnp(o, d, length(d), ts, pt)
_lsl_push_chunk_tnp(o, d::Matrix{Float64}, ts::Vector, pt) = lsl_push_chunk_dtnp(o, d, length(d), ts, pt)
_lsl_push_chunk_tnp(o, d::Matrix{Clong}, ts::Vector, pt) = lsl_push_chunk_ltnp(o, d, length(d), ts, pt)
@static if !Sys.iswindows() && Sys.WORD_SIZE == 64
_lsl_push_chunk_tnp(o, d::Matrix{Clong}, ts::Vector, pt) = lsl_push_chunk_ltnp(o, d, length(d), ts, pt)
end
_lsl_push_chunk_tnp(o, d::Matrix{Int32}, ts::Vector, pt) = lsl_push_chunk_itnp(o, d, length(d), ts, pt)
_lsl_push_chunk_tnp(o, d::Matrix{Int16}, ts::Vector, pt) = lsl_push_chunk_stnp(o, d, length(d), ts, pt)
_lsl_push_chunk_tnp(o, d::Matrix{Cchar}, ts::Vector, pt) = lsl_push_chunk_ctnp(o, d, length(d), ts, pt)
Expand Down
10 changes: 8 additions & 2 deletions test/chunk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@

# test/chunk.jl: test sending and receiving of chunks of supported datatypes

@static if !Sys.iswindows() && Sys.WORD_SIZE == 64
testtypes = (Int8, Int16, Int32, Int64, Float32, Float64)
else
testtypes = (Int8, Int16, Int32, Float32, Float64)
end

@testset "Chunk (one timestamp)" begin
@testset "Datatype $T" for T in (Int8, Int16, Int32, Int64, Float32, Float64)
@testset "Datatype $T" for T in testtypes

# Create a stream outlet
count = 32
Expand Down Expand Up @@ -41,7 +47,7 @@
end

@testset "Chunk (multiple timestamp)" begin
@testset "Datatype $T" for T in (Int8, Int16, Int32, Int64, Float32, Float64)
@testset "Datatype $T" for T in testtypes

# Create a stream outlet
count = 32
Expand Down
8 changes: 7 additions & 1 deletion test/sample.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@

# test/sample.jl: test sending and receiving of samples supported datatypes

@static if !Sys.iswindows() && Sys.WORD_SIZE == 64
testtypes = (Int8, Int16, Int32, Int64, Float32, Float64)
else
testtypes = (Int8, Int16, Int32, Float32, Float64)
end

@testset "Samples" begin
@testset "Datatype $T" for T in (Int8, Int16, Int32, Int64, Float32, Float64)
@testset "Datatype $T" for T in testtypes

# Create a stream outlet
count = 8
Expand Down

0 comments on commit 14b3365

Please sign in to comment.