Skip to content

Commit a370a46

Browse files
committed
Misc: fix for OCaml 5.4
1 parent ec95d1c commit a370a46

File tree

10 files changed

+520
-8
lines changed

10 files changed

+520
-8
lines changed

compiler/lib/magic_number.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,12 @@ let v =
7373
| 5 :: 01 :: _ -> 33
7474
| 5 :: 02 :: _ -> 34
7575
| 5 :: 03 :: _ -> 35
76+
| 5 :: 04 :: _ -> 36
7677
| _ ->
7778
if Ocaml_version.compare current [ 4; 13 ] < 0
7879
then failwith "OCaml version unsupported. Upgrade to OCaml 4.13 or newer."
7980
else (
80-
assert (Ocaml_version.compare current [ 5; 4 ] >= 0);
81+
assert (Ocaml_version.compare current [ 5; 5 ] >= 0);
8182
failwith "OCaml version unsupported. Upgrade js_of_ocaml.")
8283

8384
let current_exe = "Caml1999X", v

lib/js_of_ocaml/dom.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ class type event_listener_options = object
333333
method passive : bool t writeonly_prop
334334
end
335335

336-
let addEventListenerWithOptions (e : (< .. > as 'a) t) typ ?capture ?once ?passive h =
336+
let addEventListenerWithOptions (e : < .. > t) typ ?capture ?once ?passive h =
337337
if not (Js.Optdef.test (Js.Unsafe.coerce e)##.addEventListener)
338338
then
339339
let ev = (Js.string "on")##concat typ in
@@ -353,7 +353,7 @@ let addEventListenerWithOptions (e : (< .. > as 'a) t) typ ?capture ?once ?passi
353353
let () = (Js.Unsafe.coerce e)##addEventListener typ h opts in
354354
fun () -> (Js.Unsafe.coerce e)##removeEventListener typ h opts
355355

356-
let addEventListener (e : (< .. > as 'a) t) typ h capt =
356+
let addEventListener (e : < .. > t) typ h capt =
357357
addEventListenerWithOptions e typ ~capture:capt h
358358

359359
let removeEventListener id = id ()

lib/js_of_ocaml/dom_html.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2593,7 +2593,7 @@ val removeEventListener : event_listener_id -> unit
25932593
(** Remove the given event listener. *)
25942594

25952595
val addMousewheelEventListenerWithOptions :
2596-
(#eventTarget t as 'a)
2596+
#eventTarget t
25972597
-> ?capture:bool t
25982598
-> ?once:bool t
25992599
-> ?passive:bool t
@@ -2605,7 +2605,7 @@ val addMousewheelEventListenerWithOptions :
26052605
means down / right. *)
26062606

26072607
val addMousewheelEventListener :
2608-
(#eventTarget t as 'a)
2608+
#eventTarget t
26092609
-> (mouseEvent t -> dx:int -> dy:int -> bool t)
26102610
-> bool t
26112611
-> event_listener_id

runtime/js/array.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@ function caml_array_concat(l) {
8080
return a;
8181
}
8282

83+
//Provides: caml_floatarray_concat mutable
84+
//Version: >= 5.4
85+
function caml_floatarray_concat(l) {
86+
var a = [0];
87+
while (l !== 0) {
88+
var b = l[1];
89+
for (var i = 1; i < b.length; i++) a.push(b[i]);
90+
l = l[2];
91+
}
92+
return a;
93+
}
94+
8395
//Provides: caml_array_blit
8496
function caml_array_blit(a1, i1, a2, i2, len) {
8597
if (i2 <= i1) {

runtime/js/domain.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ function caml_atomic_load(ref) {
3131
return ref[1];
3232
}
3333

34+
//Provides: caml_atomic_load_field
35+
//Version: >= 5.4
36+
function caml_atomic_load_field(b,i) {
37+
return b[i + 1];
38+
}
39+
40+
3441
//Provides: caml_atomic_cas
3542
//Version: >= 5
3643
function caml_atomic_cas(ref, o, n) {
@@ -41,6 +48,16 @@ function caml_atomic_cas(ref, o, n) {
4148
return 0;
4249
}
4350

51+
//Provides: caml_atomic_cas_field
52+
//Version: >= 5.4
53+
function caml_atomic_cas_field(b, i, o, n) {
54+
if (b[i + 1] === o) {
55+
b[i + 1] = n;
56+
return 1;
57+
}
58+
return 0;
59+
}
60+
4461
//Provides: caml_atomic_fetch_add
4562
//Version: >= 5
4663
function caml_atomic_fetch_add(ref, i) {
@@ -49,6 +66,14 @@ function caml_atomic_fetch_add(ref, i) {
4966
return old;
5067
}
5168

69+
//Provides: caml_atomic_fetch_add_field
70+
//Version: >= 5.4
71+
function caml_atomic_fetch_add_field(b, i, n) {
72+
var old = b[i+1];
73+
b[i + 1] += n;
74+
return old;
75+
}
76+
5277
//Provides: caml_atomic_exchange
5378
//Version: >= 5
5479
function caml_atomic_exchange(ref, v) {
@@ -57,6 +82,14 @@ function caml_atomic_exchange(ref, v) {
5782
return r;
5883
}
5984

85+
//Provides: caml_atomic_exchange_field
86+
//Version: >= 5.4
87+
function caml_atomic_exchange_field(b, i, v) {
88+
var r = b[i + 1];
89+
b[i + 1] = v;
90+
return r;
91+
}
92+
6093
//Provides: caml_atomic_make_contended
6194
//Version: >= 5.2
6295
function caml_atomic_make_contended(a) {

runtime/js/io.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ function caml_ml_out_channels_list() {
194194
//Requires: caml_ml_channels, caml_sys_fds
195195
//Requires: caml_raise_sys_error
196196
//Requires: caml_sys_open
197+
//Requires: caml_io_buffer_size
197198
function caml_ml_open_descriptor_out(fd) {
198199
var fd_desc = caml_sys_fds[fd];
199200
if (fd_desc === undefined)
@@ -208,7 +209,7 @@ function caml_ml_open_descriptor_out(fd) {
208209
opened: true,
209210
out: true,
210211
buffer_curr: 0,
211-
buffer: new Uint8Array(65536),
212+
buffer: new Uint8Array(caml_io_buffer_size),
212213
buffered: buffered,
213214
};
214215
caml_ml_channels.set(chanid, channel);
@@ -219,6 +220,7 @@ function caml_ml_open_descriptor_out(fd) {
219220
//Requires: caml_ml_channels, caml_sys_fds
220221
//Requires: caml_raise_sys_error
221222
//Requires: caml_sys_open
223+
//Requires: caml_io_buffer_size
222224
function caml_ml_open_descriptor_in(fd) {
223225
var fd_desc = caml_sys_fds[fd];
224226
if (fd_desc === undefined)
@@ -234,7 +236,7 @@ function caml_ml_open_descriptor_in(fd) {
234236
out: false,
235237
buffer_curr: 0,
236238
buffer_max: 0,
237-
buffer: new Uint8Array(65536),
239+
buffer: new Uint8Array(caml_io_buffer_size),
238240
refill: refill,
239241
};
240242
caml_ml_channels.set(chanid, channel);

runtime/js/obj.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,33 @@ function caml_alloc_dummy_infix() {
3838
};
3939
}
4040

41+
//Provides: caml_alloc_dummy_lazy
42+
//Version: >= 5.4
43+
function caml_alloc_dummy_lazy(_unit) {
44+
return [0, 0]
45+
}
46+
47+
//Provides: caml_update_dummy_lazy
48+
//Requires: caml_obj_tag
49+
//Requires: caml_update_dummy
50+
//Version: >= 5.4
51+
function caml_update_dummy_lazy(dummy, newval){
52+
switch(caml_obj_tag(newval)){
53+
case 246: // Lazy
54+
case 244: // Forcing
55+
case 250: // Forward
56+
caml_update_dummy(dummy, newval);
57+
break;
58+
default:
59+
dummy[1] = newval;
60+
dummy[0] = 250;
61+
break;
62+
}
63+
return 0
64+
}
65+
66+
67+
4168
//Provides: caml_obj_tag
4269
//Requires: caml_is_ml_bytes, caml_is_ml_string
4370
function caml_obj_tag(x) {

runtime/js/sys.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,17 @@ function caml_sys_getenv(name) {
133133
return caml_string_of_jsstring(r);
134134
}
135135

136+
//Provides: caml_sys_getenv_opt (const)
137+
//Requires: caml_string_of_jsstring
138+
//Requires: caml_jsstring_of_string
139+
//Requires: jsoo_sys_getenv
140+
//Version: >= 5.4
141+
function caml_sys_getenv_opt(name) {
142+
var r = jsoo_sys_getenv(caml_jsstring_of_string(name));
143+
if (r === undefined) return 0;
144+
return [0, caml_string_of_jsstring(r)];
145+
}
146+
136147
//Provides: caml_sys_unsafe_getenv
137148
//Requires: caml_sys_getenv
138149
function caml_sys_unsafe_getenv(name) {
@@ -350,6 +361,41 @@ function caml_sys_is_regular_file(name) {
350361
var root = resolve_fs_device(name);
351362
return root.device.isFile(root.rest);
352363
}
364+
365+
//Provides: caml_io_buffer_size
366+
var caml_io_buffer_size = 65536
367+
368+
//Provides: caml_sys_io_buffer_size
369+
//Requires: caml_io_buffer_size
370+
//Version: >= 5.4
371+
function caml_sys_io_buffer_size(_unit) { return caml_io_buffer_size; }
372+
373+
//Provides: caml_sys_temp_dir_name
374+
//Requires: os_type
375+
//Requires: caml_string_of_jsstring
376+
//Version: >= 5.4
377+
function caml_sys_temp_dir_name(_unit) {
378+
if(os_type === "Win32" && globalThis.os.tmpdir){
379+
return caml_string_of_jsstring(globalThis.os.tmpdir())
380+
}
381+
else {
382+
return caml_string_of_jsstring("")
383+
}
384+
}
385+
386+
//Provides: caml_sys_convert_signal_number
387+
//Version: >= 5.4
388+
function caml_sys_convert_signal_number(signo) {
389+
return signo;
390+
}
391+
392+
//Provides: caml_sys_rev_convert_signal_number
393+
//Version: >= 5.4
394+
function caml_sys_rev_convert_signal_number(signo)
395+
{
396+
return signo
397+
}
398+
353399
//Always
354400
//Requires: caml_fatal_uncaught_exception
355401
//If: !wasm

tools/toplevel_expect/gen.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,6 @@ let () =
5353
assert (min >= 11);
5454
dump_file "toplevel_expect_test.ml-4.11"
5555
| 5, 0 | 5, 1 | 5, 2 -> dump_file "toplevel_expect_test.ml-4.11"
56-
| 5, _ -> dump_file "toplevel_expect_test.ml-5.3"
56+
| 5, 3 -> dump_file "toplevel_expect_test.ml-5.3"
57+
| 5, 4 -> dump_file "toplevel_expect_test.ml-5.4"
5758
| _ -> failwith ("unsupported version " ^ Sys.ocaml_version)

0 commit comments

Comments
 (0)