Skip to contentSkip to conversation

ocaml: fix ocaml xc compilation on 32 bit

PATCH In review Ian Campbell 3 participants 4 messages May 20, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ocaml: fix ocaml xc compilation on 32 bit

cc1: warnings being treated as errors
xc_lib.c: In function 'xc_domain_get_pfn_list':
xc_lib.c:1217: error: assignment from incompatible pointer type

The XEN_DOMCTL_getmemlist interface has been 32/64 invariante since 13594:30af6cfdb05c and uint64_t is now the correct type for the PFN list on all word sizes.

tools/ocaml/libs/xc/xc.h +1 -1
diff -r df369d08f429 -r df09eb0ada11 tools/ocaml/libs/xc/xc.h
@@ -141,7 +141,7 @@
 int xc_shadow_allocation_set(int handle, unsigned int domid,
 			     uint32_t mb);
 int xc_domain_get_pfn_list(int handle, unsigned int domid,
-                           xen_pfn_t *pfn_array, unsigned long max_pfns);
+                           uint64_t *pfn_array, unsigned long max_pfns);
 int xc_hvm_check_pvdriver(int handle, unsigned int domid);
 
 int xc_domain_assign_device(int handle, unsigned int domid,
tools/ocaml/libs/xc/xc_lib.c +1 -1
diff -r df369d08f429 -r df09eb0ada11 tools/ocaml/libs/xc/xc_lib.c
@@ -1208,7 +1208,7 @@
 }
 
 int xc_domain_get_pfn_list(int handle, unsigned int domid,
-                           xen_pfn_t *pfn_array, unsigned long max_pfns)
+                           uint64_t *pfn_array, unsigned long max_pfns)
 {
 	int ret;
 	DECLARE_DOMCTL(XEN_DOMCTL_getmemlist, domid);
tools/ocaml/libs/xc/xc_stubs.c +2 -2
diff -r df369d08f429 -r df09eb0ada11 tools/ocaml/libs/xc/xc_stubs.c
@@ -952,11 +952,11 @@
 	CAMLlocal2(array, v);
 	unsigned long c_nr_pfns;
 	long ret, i;
-	xen_pfn_t *c_array;
+	uint64_t *c_array;
 
 	c_nr_pfns = Nativeint_val(nr_pfns);
 
-	c_array = malloc(sizeof(xen_pfn_t) * c_nr_pfns);
+	c_array = malloc(sizeof(uint64_t) * c_nr_pfns);
 	if (!c_array)
 		caml_raise_out_of_memory();
#1 lore raw
Quoted 38 lines · On Thursday 20 May 2010 14:13:06 Ian Campbell wrote:

cc1: warnings being treated as errors
xc_lib.c: In function 'xc_domain_get_pfn_list':
xc_lib.c:1217: error: assignment from incompatible pointer type

The XEN_DOMCTL_getmemlist interface has been 32/64 invariante since 13594:30af6cfdb05c and uint64_t is now the correct type for the PFN list on all word sizes.

diff -r df369d08f429 -r df09eb0ada11 tools/ocaml/libs/xc/xc.h

tools/ocaml/libs/xc/xc.h +1 -1
@@ -141,7 +141,7 @@
 int xc_shadow_allocation_set(int handle, unsigned int domid,
 			     uint32_t mb);
 int xc_domain_get_pfn_list(int handle, unsigned int domid,
-                           xen_pfn_t *pfn_array, unsigned long max_pfns);
+                           uint64_t *pfn_array, unsigned long max_pfns);
 int xc_hvm_check_pvdriver(int handle, unsigned int domid);
 
 int xc_domain_assign_device(int handle, unsigned int domid,

diff -r df369d08f429 -r df09eb0ada11 tools/ocaml/libs/xc/xc_lib.c

tools/ocaml/libs/xc/xc_lib.c +1 -1
@@ -1208,7 +1208,7 @@
 }
 
 int xc_domain_get_pfn_list(int handle, unsigned int domid,
-                           xen_pfn_t *pfn_array, unsigned long max_pfns)
+                           uint64_t *pfn_array, unsigned long max_pfns)
 {
 	int ret;
 	DECLARE_DOMCTL(XEN_DOMCTL_getmemlist, domid);

diff -r df369d08f429 -r df09eb0ada11 tools/ocaml/libs/xc/xc_stubs.c

tools/ocaml/libs/xc/xc_stubs.c line 959

Quoted 10 lines
tools/ocaml/libs/xc/xc_stubs.c +2 -2
@@ -952,11 +952,11 @@
 	CAMLlocal2(array, v);
 	unsigned long c_nr_pfns;
 	long ret, i;
-	xen_pfn_t *c_array;
+	uint64_t *c_array;
 
 	c_nr_pfns = Nativeint_val(nr_pfns);
 
-	c_array = malloc(sizeof(xen_pfn_t) * c_nr_pfns);
+	c_array = malloc(sizeof(uint64_t) * c_nr_pfns);

Wouldn't it be better to have here

+ c_array = calloc(c_nr_pfns, sizeof(uint64_t));

?

Quoted 8 lines
tools/ocaml/libs/xc/xc_stubs.c +0 -0
 	if (!c_array)
 		caml_raise_out_of_memory();
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Andrew Bowd, Thomas M. McCoy, Giuliano Meroni
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
#2 lore raw

Review

Quoted 8 lines · Christoph Egger

tools/ocaml/libs/xc/xc_stubs.c line 959

Quoted 2 lines · On Thursday 20 May 2010 14:13:06 Ian Campbell wrote:
tools/ocaml/libs/xc/xc_stubs.c +1 -1
-	c_array = malloc(sizeof(xen_pfn_t) * c_nr_pfns);
+	c_array = malloc(sizeof(uint64_t) * c_nr_pfns);

Wouldn't it be better to have here

(quoted diff) +1 -0
+	c_array = calloc(c_nr_pfns, sizeof(uint64_t));

I suppose so but that would be an unrelated change, please post a patch if you think it is worth it.

Ian.

#3 lore raw
Quoted 9 lines · Ian Campbell
Quoted 6 lines
Quoted 2 lines

- c_array = malloc(sizeof(xen_pfn_t) * c_nr_pfns);
+ c_array = malloc(sizeof(uint64_t) * c_nr_pfns);

Wouldn't it be better to have here

+ c_array = calloc(c_nr_pfns, sizeof(uint64_t));

I suppose so but that would be an unrelated change, please post a patch if you think it is worth it.

Who cares either way. calloc() has potential extra overhead for clearing the memory, which is presumably not required in this case.

K.