File tree Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -171,10 +171,18 @@ let _ =
171
171
let preset = Lang. to_valued_option Lang. to_string preset_val in
172
172
let handler =
173
173
let library = Utils. check_readable ~pos: (Lang. pos p) library in
174
- try Stereotool. init ?license_key ~filename: library ()
175
- with Stereotool. Library_not_found ->
176
- Runtime_error. raise ~pos: (Lang. pos p)
177
- ~message: " Invalid stereotool library" " invalid"
174
+ try Stereotool. init ?license_key ~filename: library () with
175
+ | Stereotool. Library_not_found ->
176
+ Runtime_error. raise ~pos: (Lang. pos p)
177
+ ~message: " Invalid stereotool library" " invalid"
178
+ | Stereotool. Library_initialized f ->
179
+ Runtime_error. raise ~pos: (Lang. pos p)
180
+ ~message:
181
+ (Printf. sprintf
182
+ " Stereotool already initialized with a different library: \
183
+ %s"
184
+ (Lang_string. quote_string f))
185
+ " invalid"
178
186
in
179
187
(match preset with
180
188
| None -> ()
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ module type Config = sig
10
10
end
11
11
12
12
exception Library_not_found
13
+ exception Library_initialized of string
13
14
14
15
let strnlen = foreign " strnlen" (ocaml_bytes @-> int @-> returning int )
15
16
@@ -78,7 +79,12 @@ let int_of_load_type = function
78
79
| `Repair_no_pnr -> 11069
79
80
| `Sublevel_pnr -> 10699
80
81
82
+ let initialized = Atomic. make None
83
+
81
84
let init ?license_key ~filename () =
85
+ (match Atomic. get initialized with
86
+ | Some f when f <> filename -> raise (Library_initialized f)
87
+ | _ -> Atomic. set initialized (Some filename));
82
88
try
83
89
let module C = C (struct
84
90
let filename = filename
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ type load_type =
15
15
| `Sublevel_pnr ]
16
16
17
17
exception Library_not_found
18
+ exception Library_initialized of string
18
19
19
20
val init : ?license_key : string -> filename :string -> unit -> t
20
21
val software_version : t -> int
You can’t perform that action at this time.
0 commit comments