Skip to content

Commit

Permalink
Distinctly Bettergit status Called init then System/gc...no crash!
Browse files Browse the repository at this point in the history
  • Loading branch information
cnuernber committed Nov 23, 2020
1 parent 34d97bf commit cf720be
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ pom.xml.asc
/.nrepl-port
.hgignore
.hg/
julia-1.5.3*
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "julia"]
path = julia
url = [email protected]:JuliaLang/julia.git
10 changes: 5 additions & 5 deletions dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ USER $USERNAME

WORKDIR /home/$USERNAME

RUN wget https://julialang-s3.julialang.org/bin/linux/x64/1.4/julia-1.4.2-linux-x86_64.tar.gz \
&& tar -xvzf julia-1.4.2-linux-x86_64.tar.gz
RUN wget https://julialang-s3.julialang.org/bin/linux/x64/1.5/julia-1.5.3-linux-x86_64.tar.gz \
&& tar -xvzf julia-1.5.3-linux-x86_64.tar.gz

ENV PATH /home/$USERNAME/julia-1.4.2/bin:$PATH
ENV JULIA_HOME /home/$USERNAME/julia-1.4.2
ENV LD_LIBRARY_PATH /home/$USERNAME/julia-1.4.2/lib
ENV PATH /home/$USERNAME/julia-1.5.3/bin:$PATH
ENV JULIA_HOME /home/$USERNAME/julia-1.5.3
ENV LD_LIBRARY_PATH /home/$USERNAME/julia-1.5.3/lib
ENV JULIA_COPY_STACKS=yes

RUN lein -v
100 changes: 100 additions & 0 deletions java/julia_clj/JLOptions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package julia_clj;


import com.sun.jna.*;
import java.util.*;

public class JLOptions extends Structure {
public byte quiet;
public byte banner;
public Pointer julia_bindir;
public Pointer julia_bin;
public Pointer cmds;
public Pointer image_file;
public Pointer cpu_target;
public int nthreads;
public int nprocs;
public Pointer machine_file;
public Pointer project;
public byte isinteractive;
public byte color;
public byte historyfile;
public byte startupfile;
public byte compile_enabled;
public byte code_coverage;
public byte malloc_log;
public byte opt_level;
public byte debug_level;
public byte check_bounds;
public byte depwarn;
public byte warn_overwrite;
public byte can_inline;
public byte polly;
public Pointer trace_compile;
public byte fast_math;
public byte worker;
public Pointer cookie;
public byte handle_signals;
public byte use_sysimage_native_code;
public byte use_compiled_modules;
public Pointer bindto;
public Pointer outputbc;
public Pointer outputunoptbc;
public Pointer outputo;
public Pointer outputasm;
public Pointer outputji;
public Pointer output_code_coverage;
public byte incremental;
public byte image_file_specified;
public byte warn_scope;
public static class ByReference extends JLOptions implements Structure.ByReference {}
public static class ByValue extends JLOptions implements Structure.ByValue {}
public JLOptions () {}
public JLOptions (Pointer p) { super(p); read(); }
protected List getFieldOrder() { return Arrays.asList(new String[]
{
"quiet",
"banner",
"julia_bindir",
"julia_bin",
"cmds",
"image_file",
"cpu_target",
"nthreads",
"nprocs",
"machine_file",
"project",
"isinteractive",
"color",
"historyfile",
"startupfile",
"compile_enabled",
"code_coverage",
"malloc_log",
"opt_level",
"debug_level",
"check_bounds",
"depwarn",
"warn_overwrite",
"can_inline",
"polly",
"trace_compile",
"fast_math",
"worker",
"cookie",
"handle_signals",
"use_sysimage_native_code",
"use_compiled_modules",
"bindto",
"outputbc",
"outputunoptbc",
"outputo",
"outputasm",
"outputji",
"output_code_coverage",
"incremental",
"image_file_specified",
"warn_scope"
});
}
}
1 change: 1 addition & 0 deletions julia
Submodule julia added at 788b2c
1 change: 1 addition & 0 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
:url "https://www.eclipse.org/legal/epl-2.0/"}
:dependencies [[org.clojure/clojure "1.10.1"]
[techascent/tech.datatype "5.0-beta-37"]]
:java-source-paths ["java"]
:aot [julia-clj.main]
:main julia-clj.main)
24 changes: 22 additions & 2 deletions src/julia_clj/core.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
(ns julia-clj.core
(:require [tech.jna :as jna])
(:import [com.sun.jna Pointer]))
(:require [tech.jna :as jna]
[tech.jna.base :as jna-base])
(:import [com.sun.jna Pointer NativeLibrary]
[julia_clj JLOptions]))


(jna/def-jna-fn "julia" jl_init__threading
Expand All @@ -20,3 +22,21 @@
"Shutdown julia gracefully"
nil
[status int])


(defn find-julia-symbol
^Pointer [sym-name]
(.getGlobalVariableAddress ^NativeLibrary (jna-base/load-library "julia")
sym-name))


(defn julia-options
^JLOptions []
(JLOptions. (find-julia-symbol "jl_options")))


(defn disable-julia-signals!
[]
(let [opts (julia-options)]
(set! (.handle_signals opts) 0)
(.writeField opts "handle_signals")))

1 comment on commit cf720be

@cnuernber
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.