Commit a892fb04 authored by Richard W.M. Jones's avatar Richard W.M. Jones

Use -safe-string and fix the library.

Note this changes the type of the cpumap from string to bytes,
since (by the design of the API) it must be mutated.
parent bb88153b
......@@ -31,11 +31,11 @@ OCAMLMKLIB = @OCAMLMKLIB@
ifneq ($(OCAMLFIND),)
OCAMLCPACKAGES := -package unix
OCAMLCFLAGS := -g -warn-error CDEFLMPSUVYZX-3
OCAMLCFLAGS := -g -warn-error CDEFLMPSUVYZX-3 -safe-string
OCAMLCLIBS := -linkpkg
else
OCAMLCINCS :=
OCAMLCFLAGS := -g -warn-error CDEFLMPSUVYZX-3
OCAMLCFLAGS := -g -warn-error CDEFLMPSUVYZX-3 -safe-string
OCAMLCLIBS := unix.cma
endif
......
......@@ -92,13 +92,13 @@ struct
(* See VIR_USE_CPU, VIR_UNUSE_CPU, VIR_CPU_USABLE macros defined in <libvirt.h>. *)
let use_cpu cpumap cpu =
cpumap.[cpu/8] <-
Char.chr (Char.code cpumap.[cpu/8] lor (1 lsl (cpu mod 8)))
Bytes.set cpumap (cpu/8)
(Char.chr (Char.code (Bytes.get cpumap (cpu/8)) lor (1 lsl (cpu mod 8))))
let unuse_cpu cpumap cpu =
cpumap.[cpu/8] <-
Char.chr (Char.code cpumap.[cpu/8] land (lnot (1 lsl (cpu mod 8))))
Bytes.set cpumap (cpu/8)
(Char.chr (Char.code (Bytes.get cpumap (cpu/8)) land (lnot (1 lsl (cpu mod 8)))))
let cpu_usable cpumaps maplen vcpu cpu =
Char.code cpumaps.[vcpu*maplen + cpu/8] land (1 lsl (cpu mod 8)) <> 0
Char.code (Bytes.get cpumaps (vcpu*maplen + cpu/8)) land (1 lsl (cpu mod 8)) <> 0
external set_keep_alive : [>`R] t -> int -> int -> unit = "ocaml_libvirt_connect_set_keep_alive"
......
......@@ -376,11 +376,11 @@ sig
CPU map between a single virtual and all physical CPUs of a domain.
*)
val use_cpu : string -> int -> unit
val use_cpu : bytes -> int -> unit
(** [use_cpu cpumap cpu] marks [cpu] as usable in [cpumap]. *)
val unuse_cpu : string -> int -> unit
val unuse_cpu : bytes -> int -> unit
(** [unuse_cpu cpumap cpu] marks [cpu] as not usable in [cpumap]. *)
val cpu_usable : string -> int -> int -> int -> bool
val cpu_usable : bytes -> int -> int -> int -> bool
(** [cpu_usable cpumaps maplen vcpu cpu] checks returns true iff the
[cpu] is usable by [vcpu]. *)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment