Blob Blame History Raw
# HG changeset patch
# User Jon Ludlam <jonathan.ludlam@eu.citrix.com>
# Date 1318261276 -3600
# Node ID 187d59e32a586d65697ed46bef106b52e3fb5ab9
# Parent  51288f69523fcbbefa12cea5a761a6e957410151
tools/ocaml: Fix 2 bit-twiddling bugs and an off-by-one

The bit bugs are in ocaml vcpu affinity calls, and the off-by-one
error is in the ocaml console ring code

Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
Acked-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>

diff -r 51288f69523f -r 187d59e32a58 tools/ocaml/libs/xc/xenctrl_stubs.c
--- a/tools/ocaml/libs/xc/xenctrl_stubs.c	Mon Oct 10 16:41:16 2011 +0100
+++ b/tools/ocaml/libs/xc/xenctrl_stubs.c	Mon Oct 10 16:41:16 2011 +0100
@@ -430,7 +430,7 @@
 
 	for (i=0; i<len; i++) {
 		if (Bool_val(Field(cpumap, i)))
-			c_cpumap[i/8] |= i << (i&7);
+			c_cpumap[i/8] |= 1 << (i&7);
 	}
 	retval = xc_vcpu_setaffinity(_H(xch), _D(domid),
 	                             Int_val(vcpu), c_cpumap);
@@ -466,7 +466,7 @@
 	ret = caml_alloc(len, 0);
 
 	for (i=0; i<len; i++) {
-		if (c_cpumap[i%8] & 1 << (i&7))
+		if (c_cpumap[i/8] & 1 << (i&7))
 			Store_field(ret, i, Val_true);
 		else
 			Store_field(ret, i, Val_false);
@@ -523,7 +523,7 @@
 
 CAMLprim value stub_xc_readconsolering(value xch)
 {
-	unsigned int size = RING_SIZE;
+	unsigned int size = RING_SIZE - 1;
 	char *ring_ptr = ring;
 
 	CAMLparam1(xch);