Skip to content

Commit

Permalink
Add the new wrappers with support of Int64
Browse files Browse the repository at this point in the history
  • Loading branch information
amontoison committed Nov 13, 2024
1 parent 6e4489b commit 3859f62
Show file tree
Hide file tree
Showing 39 changed files with 2,462 additions and 2 deletions.
50 changes: 48 additions & 2 deletions gen/analyzer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
using HSL_jll
using JuliaFormatter

release = "2023.11.7"
libhsl = "/home/alexis/Bureau/git/hsl/libhsl/libHSL-$release/"
release = "2024.11.8"
libhsl = "/home/alexis/Bureau/git/hsl/libhsl/libHSL.v$release/"

# Symbols of the shared library libhsl
symbols_path = "symbols.txt"
run(pipeline(`nm -D $(HSL_jll.libhsl_path)`, stdout=symbols_path))

# Symbols of the shared library libhsl_subset_64
symbols_64_path = "symbols_64.txt"
run(pipeline(`nm -D $(HSL_jll.libhsl_subset_64_path)`, stdout=symbols_64_path))

# Relation between the hsl precision and the name of the symbols
hsl_precision = Dict{Char, String}('i' => "integer",
'l' => "long_integer",
Expand Down Expand Up @@ -392,6 +396,11 @@ function main(name::String="all"; verbose::Bool=false)
symbols = split(symbols, "\n", keepempty=false)
symbols = [symbol[20:end] for symbol in symbols]

# Create a vector with all symbols exported by the shared library libhsl_subset_64
symbols_64 = read(symbols_64_path, String)
symbols_64 = split(symbols_64, "\n", keepempty=false)
symbols_64 = [symbol_64[20:end] for symbol_64 in symbols_64]

for (root, dirs, files) in walkdir(libhsl)

# We don't want to go inside "examples", metis" and "libhsl" folders
Expand Down Expand Up @@ -475,6 +484,43 @@ function main(name::String="all"; verbose::Bool=false)
end
write(file_wrapper, ")::$(output_type)\n")
write(file_wrapper, "end\n")

# Symbols with the suffix `64_`
if "$(fname)64_" in symbols_64
write(file_wrapper, "\n")
signature64 = replace(signature, fname[1:end-1] => "$(fname)64")
signature64 = replace(signature64, "Cint" => "Int64")
write(file_wrapper, "function $signature64\n")
write(file_wrapper, " @ccall libhsl_subset_64.$(fname)64_(")
for k = 1:narguments
if types[k] == ""
format = false
@warn "Unable to determine the type of $(arguments[k])"
else
type64 = replace(types[k], "Cint" => "Int64")
write(file_wrapper, "$(arguments[k])::$(type64)")
end
(k < narguments) && write(file_wrapper, ", ")
end

# Hidden arguments
if "Ref{UInt8}" types || "Ptr{UInt8}" types || "Ptr{Ptr{UInt8}}" types
verbose && @info "Hidden argument in $fname."
end
for k = 1:narguments
(types[k] == "Ref{UInt8}") && write(file_wrapper, ", 1::Csize_t")
(types[k] == "Ptr{UInt8}") && write(file_wrapper, ", $(strlen[arguments[k]])::Csize_t")
(types[k] == "Ptr{Ptr{UInt8}}") && write(file_wrapper, ", $(strlen[arguments[k]])::Csize_t")
end

if output_type == ""
format = false
@warn "Unable to determine the output type"
end
write(file_wrapper, ")::$(output_type)\n")
write(file_wrapper, "end\n")
end

index < num_fnames && write(file_wrapper, "\n")
end
end
Expand Down
32 changes: 32 additions & 0 deletions src/Fortran/fa01.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,62 @@ function fa01bd(max, nrand)
@ccall libhsl.fa01bd_(max::Ref{Cint}, nrand::Ref{Cint})::Cvoid
end

function fa01bd_64(max, nrand)
@ccall libhsl_subset_64.fa01bd_64_(max::Ref{Int64}, nrand::Ref{Int64})::Cvoid
end

function fa01cd(il, ir)
@ccall libhsl.fa01cd_(il::Ref{Cint}, ir::Ref{Cint})::Cvoid
end

function fa01cd_64(il, ir)
@ccall libhsl_subset_64.fa01cd_64_(il::Ref{Int64}, ir::Ref{Int64})::Cvoid
end

function fa01dd(il, ir)
@ccall libhsl.fa01dd_(il::Ref{Cint}, ir::Ref{Cint})::Cvoid
end

function fa01dd_64(il, ir)
@ccall libhsl_subset_64.fa01dd_64_(il::Ref{Int64}, ir::Ref{Int64})::Cvoid
end

function fa01ad(i)
@ccall libhsl.fa01ad_(i::Ref{Cint})::Float64
end

function fa01ad_64(i)
@ccall libhsl_subset_64.fa01ad_64_(i::Ref{Int64})::Float64
end

function fa01b(max, nrand)
@ccall libhsl.fa01b_(max::Ref{Cint}, nrand::Ref{Cint})::Cvoid
end

function fa01b_64(max, nrand)
@ccall libhsl_subset_64.fa01b_64_(max::Ref{Int64}, nrand::Ref{Int64})::Cvoid
end

function fa01c(il, ir)
@ccall libhsl.fa01c_(il::Ref{Cint}, ir::Ref{Cint})::Cvoid
end

function fa01c_64(il, ir)
@ccall libhsl_subset_64.fa01c_64_(il::Ref{Int64}, ir::Ref{Int64})::Cvoid
end

function fa01d(il, ir)
@ccall libhsl.fa01d_(il::Ref{Cint}, ir::Ref{Cint})::Cvoid
end

function fa01d_64(il, ir)
@ccall libhsl_subset_64.fa01d_64_(il::Ref{Int64}, ir::Ref{Int64})::Cvoid
end

function fa01a(i)
@ccall libhsl.fa01a_(i::Ref{Cint})::Float32
end

function fa01a_64(i)
@ccall libhsl_subset_64.fa01a_64_(i::Ref{Int64})::Float32
end
32 changes: 32 additions & 0 deletions src/Fortran/fa04.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,62 @@ function fa04bd(max, nrand)
@ccall libhsl.fa04bd_(max::Ref{Cint}, nrand::Ref{Cint})::Cvoid
end

function fa04bd_64(max, nrand)
@ccall libhsl_subset_64.fa04bd_64_(max::Ref{Int64}, nrand::Ref{Int64})::Cvoid
end

function fa04cd(igen)
@ccall libhsl.fa04cd_(igen::Ref{Cint})::Cvoid
end

function fa04cd_64(igen)
@ccall libhsl_subset_64.fa04cd_64_(igen::Ref{Int64})::Cvoid
end

function fa04dd(igen)
@ccall libhsl.fa04dd_(igen::Ref{Cint})::Cvoid
end

function fa04dd_64(igen)
@ccall libhsl_subset_64.fa04dd_64_(igen::Ref{Int64})::Cvoid
end

function fa04ad(i)
@ccall libhsl.fa04ad_(i::Ref{Cint})::Float64
end

function fa04ad_64(i)
@ccall libhsl_subset_64.fa04ad_64_(i::Ref{Int64})::Float64
end

function fa04b(max, nrand)
@ccall libhsl.fa04b_(max::Ref{Cint}, nrand::Ref{Cint})::Cvoid
end

function fa04b_64(max, nrand)
@ccall libhsl_subset_64.fa04b_64_(max::Ref{Int64}, nrand::Ref{Int64})::Cvoid
end

function fa04c(igen)
@ccall libhsl.fa04c_(igen::Ref{Cint})::Cvoid
end

function fa04c_64(igen)
@ccall libhsl_subset_64.fa04c_64_(igen::Ref{Int64})::Cvoid
end

function fa04d(igen)
@ccall libhsl.fa04d_(igen::Ref{Cint})::Cvoid
end

function fa04d_64(igen)
@ccall libhsl_subset_64.fa04d_64_(igen::Ref{Int64})::Cvoid
end

function fa04a(i)
@ccall libhsl.fa04a_(i::Ref{Cint})::Float32
end

function fa04a_64(i)
@ccall libhsl_subset_64.fa04a_64_(i::Ref{Int64})::Float32
end
40 changes: 40 additions & 0 deletions src/Fortran/fa14.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,78 @@ function fa14bd(ix, max, nrand)
@ccall libhsl.fa14bd_(ix::Ref{Cint}, max::Ref{Cint}, nrand::Ref{Cint})::Cvoid
end

function fa14bd_64(ix, max, nrand)
@ccall libhsl_subset_64.fa14bd_64_(ix::Ref{Int64}, max::Ref{Int64}, nrand::Ref{Int64})::Cvoid
end

function fa14cd(ix, igen)
@ccall libhsl.fa14cd_(ix::Ref{Cint}, igen::Ref{Cint})::Cvoid
end

function fa14cd_64(ix, igen)
@ccall libhsl_subset_64.fa14cd_64_(ix::Ref{Int64}, igen::Ref{Int64})::Cvoid
end

function fa14dd(ix, igen)
@ccall libhsl.fa14dd_(ix::Ref{Cint}, igen::Ref{Cint})::Cvoid
end

function fa14dd_64(ix, igen)
@ccall libhsl_subset_64.fa14dd_64_(ix::Ref{Int64}, igen::Ref{Int64})::Cvoid
end

function fa14id(ix)
@ccall libhsl.fa14id_(ix::Ref{Cint})::Cvoid
end

function fa14id_64(ix)
@ccall libhsl_subset_64.fa14id_64_(ix::Ref{Int64})::Cvoid
end

function fa14ad(ix, i)
@ccall libhsl.fa14ad_(ix::Ref{Cint}, i::Ref{Cint})::Float64
end

function fa14ad_64(ix, i)
@ccall libhsl_subset_64.fa14ad_64_(ix::Ref{Int64}, i::Ref{Int64})::Float64
end

function fa14b(ix, max, nrand)
@ccall libhsl.fa14b_(ix::Ref{Cint}, max::Ref{Cint}, nrand::Ref{Cint})::Cvoid
end

function fa14b_64(ix, max, nrand)
@ccall libhsl_subset_64.fa14b_64_(ix::Ref{Int64}, max::Ref{Int64}, nrand::Ref{Int64})::Cvoid
end

function fa14c(ix, igen)
@ccall libhsl.fa14c_(ix::Ref{Cint}, igen::Ref{Cint})::Cvoid
end

function fa14c_64(ix, igen)
@ccall libhsl_subset_64.fa14c_64_(ix::Ref{Int64}, igen::Ref{Int64})::Cvoid
end

function fa14d(ix, igen)
@ccall libhsl.fa14d_(ix::Ref{Cint}, igen::Ref{Cint})::Cvoid
end

function fa14d_64(ix, igen)
@ccall libhsl_subset_64.fa14d_64_(ix::Ref{Int64}, igen::Ref{Int64})::Cvoid
end

function fa14i(ix)
@ccall libhsl.fa14i_(ix::Ref{Cint})::Cvoid
end

function fa14i_64(ix)
@ccall libhsl_subset_64.fa14i_64_(ix::Ref{Int64})::Cvoid
end

function fa14a(ix, i)
@ccall libhsl.fa14a_(ix::Ref{Cint}, i::Ref{Cint})::Float32
end

function fa14a_64(ix, i)
@ccall libhsl_subset_64.fa14a_64_(ix::Ref{Int64}, i::Ref{Int64})::Float32
end
8 changes: 8 additions & 0 deletions src/Fortran/fd15.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ function fd15ad(t)
@ccall libhsl.fd15ad_(t::Ref{UInt8}, 1::Csize_t)::Float64
end

function fd15ad_64(t)
@ccall libhsl_subset_64.fd15ad_64_(t::Ref{UInt8}, 1::Csize_t)::Float64
end

function fd15a(t)
@ccall libhsl.fd15a_(t::Ref{UInt8}, 1::Csize_t)::Float32
end

function fd15a_64(t)
@ccall libhsl_subset_64.fd15a_64_(t::Ref{UInt8}, 1::Csize_t)::Float32
end
12 changes: 12 additions & 0 deletions src/Fortran/kb07.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@ function kb07ad(count, n, index)
@ccall libhsl.kb07ad_(count::Ptr{Float64}, n::Ref{Cint}, index::Ptr{Cint})::Cvoid
end

function kb07ad_64(count, n, index)
@ccall libhsl_subset_64.kb07ad_64_(count::Ptr{Float64}, n::Ref{Int64}, index::Ptr{Int64})::Cvoid
end

function kb07ai(count, n, index)
@ccall libhsl.kb07ai_(count::Ptr{Cint}, n::Ref{Cint}, index::Ptr{Cint})::Cvoid
end

function kb07ai_64(count, n, index)
@ccall libhsl_subset_64.kb07ai_64_(count::Ptr{Int64}, n::Ref{Int64}, index::Ptr{Int64})::Cvoid
end

function kb07a(count, n, index)
@ccall libhsl.kb07a_(count::Ptr{Float32}, n::Ref{Cint}, index::Ptr{Cint})::Cvoid
end

function kb07a_64(count, n, index)
@ccall libhsl_subset_64.kb07a_64_(count::Ptr{Float32}, n::Ref{Int64}, index::Ptr{Int64})::Cvoid
end
Loading

0 comments on commit 3859f62

Please sign in to comment.