Created
April 9, 2018 01:57
-
-
Save regonn/a91ebf6ef8c856d51dfd9a1380220cd5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fiddle' | |
require 'fiddle/import' | |
module Julia | |
extend Fiddle::Importer | |
# Linux | |
dlload Fiddle.dlopen('libjulia.so.0.6') | |
typealias "uint8_t", "unsigned char" | |
extern 'int jl_cpu_cores(void)' | |
extern 'void jl_init(void)' | |
extern 'jl_value_t *jl_eval_string(const char *str)' | |
extern 'void jl_atexit_hook(int status)' | |
extern 'uint8_t jl_unbox_uint8(jl_value_t *v)' | |
end | |
Julia.jl_init | |
puts "CPU: #{Julia.jl_cpu_cores}" | |
eval = Julia.jl_eval_string("1+1") | |
puts Julia.jl_unbox_uint8(eval) | |
Julia.jl_atexit_hook(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment