Skip to content

Commit c63acd3

Browse files
v0.17~preview.129.00+111
1 parent bc07769 commit c63acd3

File tree

19 files changed

+193
-92
lines changed

19 files changed

+193
-92
lines changed

core/src/bigstring_stubs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
3939
#include <sys/endian.h>
4040
#else
41-
#ifndef _MSC_VER
41+
#ifndef _WIN32
4242
#include <endian.h>
4343
#endif
4444
#endif

core/src/core.ml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,6 @@ module Percent = Percent
122122
module Perms = Perms
123123
module Pid = Pid
124124
module Poly = Poly
125-
126-
module Popcount = Base.Popcount
127-
[@@warning "-3"]
128-
[@@deprecated "[since 2018-10] use [popcount] functions in individual int modules"]
129-
130125
module Pretty_printer = Pretty_printer
131126
module Printexc = Printexc
132127
module Printf = Printf

core/src/dune

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@
1010
(c_flags :standard -D_LARGEFILE64_SOURCE)
1111
(c_names bigstring_stubs md5_stubs array_stubs gc_stubs time_ns_stubs)
1212
(ocamlopt_flags :standard (:include ocamlopt-flags))
13-
(preprocess (pps ppx_jane ppx_optcomp)) (preprocessor_deps config.h)
13+
(preprocess (pps ppx_jane ppx_optcomp))
14+
(preprocessor_deps config.h gc_stubs.h)
1415
(js_of_ocaml (javascript_files strftime.js runtime.js)))
1516

17+
(rule (targets gc_stubs.h) (deps)
18+
(action (bash "echo \"#define OCAML_5_HAS_OCAML_4_GC false\" > %{targets}")))
19+
1620
(documentation)
1721

1822
(rule (targets ocamlopt-flags) (deps)

core/src/gc.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,8 @@ external major_plus_minor_words : unit -> int = "core_gc_major_plus_minor_words"
408408
external allocated_words : unit -> int = "core_gc_allocated_words"
409409
external run_memprof_callbacks : unit -> unit = "core_gc_run_memprof_callbacks"
410410

411-
[%%if ocaml_version < (5, 0, 0)]
411+
[%%import "gc_stubs.h"]
412+
[%%if ocaml_version < (5, 0, 0) || OCAML_5_HAS_OCAML_4_GC]
412413

413414
external heap_words : unit -> int = "core_gc_heap_words" [@@noalloc]
414415
external heap_chunks : unit -> int = "core_gc_heap_chunks" [@@noalloc]

core/src/gc.mli

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ module Control : sig
335335
Default: 8192 bytes.
336336
@since 4.08.0 *)
337337
}
338-
[@@deriving sexp_of]
338+
[@@deriving sexp_of, fields ~iterators:to_list]
339339

340340
[%%endif]
341341

@@ -384,7 +384,8 @@ external minor_collections : unit -> int = "core_gc_minor_collections" [@@noallo
384384
external major_collections : unit -> int = "core_gc_major_collections" [@@noalloc]
385385
external compactions : unit -> int = "core_gc_compactions" [@@noalloc]
386386

387-
[%%if ocaml_version < (5, 0, 0)]
387+
[%%import "gc_stubs.h"]
388+
[%%if ocaml_version < (5, 0, 0) || OCAML_5_HAS_OCAML_4_GC]
388389

389390
external heap_words : unit -> int = "core_gc_heap_words" [@@noalloc]
390391
external heap_chunks : unit -> int = "core_gc_heap_chunks" [@@noalloc]

core/src/gc_stubs.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
#include <caml/memory.h>
55
#include <caml/memprof.h>
66
#include <caml/version.h>
7+
#include <stdbool.h>
8+
#include "gc_stubs.h"
9+
10+
#if OCAML_VERSION >= 50100 && !OCAML_5_HAS_OCAML_4_GC
11+
#define HAS_OCAML_5_GC
12+
#endif
713

814
static intnat minor_words(void) {
915
return (intnat)(caml_stat_minor_words +
@@ -35,9 +41,9 @@ CAMLprim value core_gc_promoted_words(value unit) {
3541

3642
CAMLprim value core_gc_minor_collections(value unit) {
3743
(void)unit;
38-
// In OCaml 5.1.0, the number of minor collections is an atomic global state
39-
// variable.
40-
#if OCAML_VERSION < 50100
44+
// In OCaml 5.1.0, the number of minor collections is an atomic global state
45+
// variable.
46+
#ifndef HAS_OCAML_5_GC
4147
return Val_long(caml_stat_minor_collections);
4248
#else
4349
return Val_long(atomic_load(&caml_minor_collections_count));
@@ -75,7 +81,7 @@ CAMLprim value core_gc_run_memprof_callbacks(value unit) {
7581
return Val_unit;
7682
}
7783

78-
#if OCAML_VERSION < 50000
84+
#if OCAML_VERSION < 50000 || OCAML_VERSION >= 50100 && OCAML_5_HAS_OCAML_4_GC
7985

8086
CAMLprim value core_gc_heap_words(value unit) {
8187
(void)unit;

core/src/import.ml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ module Int_math = Base.Int_math
1919
module Invariant = Base.Invariant
2020
module Monad = Base.Monad
2121
module Poly = Base.Poly
22-
23-
module Popcount = Base.Popcount
24-
[@@warning "-3"]
25-
[@@deprecated "[since 2018-10] use [popcount] functions in individual int modules"]
26-
2722
module Pretty_printer = Base.Pretty_printer
2823
module Random = Base.Random
2924
module Staged = Base.Staged

core/src/map.ml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,8 @@ module Merge_element = Base.Map.Merge_element
4747
module Continue_or_stop = Base.Map.Continue_or_stop
4848
module Finished_or_unfinished = Base.Map.Finished_or_unfinished
4949

50-
type ('k, 'cmp) comparator =
51-
(module Comparator.S with type t = 'k and type comparator_witness = 'cmp)
52-
53-
let to_comparator (type k cmp) ((module M) : (k, cmp) Comparator.Module.t) = M.comparator
54-
55-
let of_comparator (type k cmp) comparator : (k, cmp) Comparator.Module.t =
56-
(module struct
57-
type t = k
58-
type comparator_witness = cmp
59-
60-
let comparator = comparator
61-
end)
62-
;;
50+
let to_comparator = Comparator.of_module
51+
let of_comparator = Comparator.to_module
6352

6453
module For_quickcheck = struct
6554
let gen_tree ~comparator k_gen v_gen =

core/src/map.mli

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ open Map_intf
4343

4444
type (!'key, +!'value, !'cmp) t = ('key, 'value, 'cmp) Base.Map.t
4545

46-
type ('k, 'cmp) comparator = ('k, 'cmp) Comparator.Module.t
47-
[@@deprecated "[since 2022-07] use [Comparator.Module.t] instead"]
48-
4946
(** Test if invariants of internal AVL search tree hold. *)
5047
val invariants : (_, _, _) t -> bool
5148

core/src/set.ml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,8 @@ module type Elt_plain = Elt_plain
77
module type Elt = Elt
88
module type Elt_binable = Elt_binable
99

10-
let to_comparator (type k cmp) ((module M) : (k, cmp) Comparator.Module.t) = M.comparator
11-
12-
let of_comparator (type k cmp) comparator : (k, cmp) Comparator.Module.t =
13-
(module struct
14-
type t = k
15-
type comparator_witness = cmp
16-
17-
let comparator = comparator
18-
end)
19-
;;
10+
let to_comparator = Comparator.of_module
11+
let of_comparator = Comparator.to_module
2012

2113
module For_quickcheck = struct
2214
let quickcheck_generator ~comparator elt_gen =
@@ -101,9 +93,6 @@ include (
10193
with module Named = Set.Named
10294
end)
10395

104-
type ('k, 'cmp) comparator =
105-
(module Comparator.S with type t = 'k and type comparator_witness = 'cmp)
106-
10796
let compare _ _ t1 t2 = compare_direct t1 t2
10897

10998
module Using_comparator = struct

0 commit comments

Comments
 (0)