ocaml-containers/src/domain/gen.ml
Simon Cruanes c1b13f1c7f
Some checks failed
format / format (push) Has been cancelled
Build and Test / build (push) Has been cancelled
feat: add CCAtomic.update_cas
2025-12-08 13:41:29 -05:00

28 lines
570 B
OCaml

let domain_4 =
{|
let is_main_domain () = true
let cpu_relax = ignore
let relax_loop : int -> unit = ignore
|}
let domain_5 =
{|
let is_main_domain = Domain.is_main_domain
let cpu_relax = Domain.cpu_relax
let relax_loop i =
for _j = 1 to i do cpu_relax () done
|}
let write_file file s =
let oc = open_out file in
output_string oc s;
close_out oc
let () =
let version = Scanf.sscanf Sys.ocaml_version "%d.%d.%s" (fun x y _ -> x, y) in
write_file "containers_domain.ml"
(if version >= (5, 0) then
domain_5
else
domain_4);
()