From: Keir Fraser Date: Fri, 7 May 2010 18:08:55 +0000 (+0100) Subject: ocaml: NetBSD support and general CFLAGS cleanup X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~12213 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=eb8d759136ca98b053c1fe9bb7e72aecb5a0a80d;p=xen.git ocaml: NetBSD support and general CFLAGS cleanup Signed-off-by: Christoph Egger Signed-off-by: Keir Fraser --- diff --git a/Config.mk b/Config.mk index 903f015924..da9276f9cf 100644 --- a/Config.mk +++ b/Config.mk @@ -168,11 +168,7 @@ CONFIG_MINITERM ?= n CONFIG_LOMOUNT ?= n ifeq ($(OCAML_TOOLS),y) -ifeq ($(CONFIG_Linux),y) OCAML_TOOLS := $(shell ocamlopt -v > /dev/null 2>&1 && echo "y" || echo "n") -else -OCAML_TOOLS := n -endif endif -include $(XEN_ROOT)/.config diff --git a/tools/ocaml/common.make b/tools/ocaml/common.make index cb95104582..63b6b2ee24 100644 --- a/tools/ocaml/common.make +++ b/tools/ocaml/common.make @@ -1,3 +1,5 @@ +include $(XEN_ROOT)/tools/Rules.mk + CC ?= gcc OCAMLOPT ?= ocamlopt OCAMLC ?= ocamlc @@ -6,10 +8,10 @@ OCAMLDEP ?= ocamldep OCAMLLEX ?= ocamllex OCAMLYACC ?= ocamlyacc -CFLAGS ?= -Wall -fPIC -O2 -Werror - +CFLAGS += -fPIC -Werror CFLAGS += -I$(TOPLEVEL)/../include -I$(TOPLEVEL)/../libxc -CFLAGS += -I/usr/lib64/ocaml -I/usr/lib/ocaml +CFLAGS-$(CONFIG_Linux) += -I/usr/lib64/ocaml -I/usr/lib/ocaml +CFLAGS-$(CONFIG_NetBSD) += -I/usr/pkg/lib/ocaml -fPIC OCAMLOPTFLAG_G := $(shell $(OCAMLOPT) -h 2>&1 | sed -n 's/^ *\(-g\) .*/\1/p') OCAMLOPTFLAGS = $(OCAMLOPTFLAG_G) -ccopt "$(LDFLAGS)" -dtypes $(OCAMLINCLUDE) -cc $(CC) -w F -warn-error F diff --git a/tools/ocaml/libs/eventchn/Makefile b/tools/ocaml/libs/eventchn/Makefile index 9d6ef31ffe..60b66f2847 100644 --- a/tools/ocaml/libs/eventchn/Makefile +++ b/tools/ocaml/libs/eventchn/Makefile @@ -1,4 +1,5 @@ TOPLEVEL=../.. +XEN_ROOT=$(TOPLEVEL)/../.. include $(TOPLEVEL)/common.make OBJS = eventchn diff --git a/tools/ocaml/libs/eventchn/eventchn_stubs.c b/tools/ocaml/libs/eventchn/eventchn_stubs.c index ab61b0a227..210aa30afa 100644 --- a/tools/ocaml/libs/eventchn/eventchn_stubs.c +++ b/tools/ocaml/libs/eventchn/eventchn_stubs.c @@ -20,20 +20,10 @@ #include #include #include - #include - -#define __XEN_TOOLS__ - #include - -#if XEN_SYSCTL_INTERFACE_VERSION < 4 -#include -#else #include #include -#endif - #include #define CAML_NAME_SPACE diff --git a/tools/ocaml/libs/log/Makefile b/tools/ocaml/libs/log/Makefile index 47c7918fcc..2a02629fff 100644 --- a/tools/ocaml/libs/log/Makefile +++ b/tools/ocaml/libs/log/Makefile @@ -1,4 +1,5 @@ TOPLEVEL=../.. +XEN_ROOT=$(TOPLEVEL)/../.. include $(TOPLEVEL)/common.make OBJS = syslog log logs diff --git a/tools/ocaml/libs/mmap/Makefile b/tools/ocaml/libs/mmap/Makefile index bd8ab43b69..374ef69cfd 100644 --- a/tools/ocaml/libs/mmap/Makefile +++ b/tools/ocaml/libs/mmap/Makefile @@ -1,4 +1,5 @@ TOPLEVEL=../.. +XEN_ROOT=$(TOPLEVEL)/../.. include $(TOPLEVEL)/common.make OBJS = mmap diff --git a/tools/ocaml/libs/uuid/Makefile b/tools/ocaml/libs/uuid/Makefile index 8ddb0e2854..136967a9a8 100644 --- a/tools/ocaml/libs/uuid/Makefile +++ b/tools/ocaml/libs/uuid/Makefile @@ -1,4 +1,5 @@ TOPLEVEL=../.. +XEN_ROOT=$(TOPLEVEL)/../.. include $(TOPLEVEL)/common.make OBJS = uuid diff --git a/tools/ocaml/libs/xb/Makefile b/tools/ocaml/libs/xb/Makefile index 56afb4aa38..c68dc9ed94 100644 --- a/tools/ocaml/libs/xb/Makefile +++ b/tools/ocaml/libs/xb/Makefile @@ -1,4 +1,5 @@ TOPLEVEL=../.. +XEN_ROOT=$(TOPLEVEL)/../.. include $(TOPLEVEL)/common.make CFLAGS += -I../mmap diff --git a/tools/ocaml/libs/xb/xb_stubs.c b/tools/ocaml/libs/xb/xb_stubs.c index b4d1ee65dc..a68e783f70 100644 --- a/tools/ocaml/libs/xb/xb_stubs.c +++ b/tools/ocaml/libs/xb/xb_stubs.c @@ -27,10 +27,7 @@ #include #include -#define __XEN_TOOLS__ - #include -#define u32 uint32_t #include CAMLprim value stub_header_size(void) diff --git a/tools/ocaml/libs/xb/xs_ring_stubs.c b/tools/ocaml/libs/xb/xs_ring_stubs.c index 9aef23ef4d..a3bb175df9 100644 --- a/tools/ocaml/libs/xb/xs_ring_stubs.c +++ b/tools/ocaml/libs/xb/xs_ring_stubs.c @@ -21,10 +21,7 @@ #include #include -#define __XEN_TOOLS__ - #include -#define u32 uint32_t #include #include diff --git a/tools/ocaml/libs/xc/Makefile b/tools/ocaml/libs/xc/Makefile index 9e361b505e..b0b0bcc4ab 100644 --- a/tools/ocaml/libs/xc/Makefile +++ b/tools/ocaml/libs/xc/Makefile @@ -1,4 +1,5 @@ TOPLEVEL=../.. +XEN_ROOT=$(TOPLEVEL)/../.. include $(TOPLEVEL)/common.make CFLAGS += -I../mmap -I./ diff --git a/tools/ocaml/libs/xc/xc.h b/tools/ocaml/libs/xc/xc.h index f88245decd..ac3307a1e7 100644 --- a/tools/ocaml/libs/xc/xc.h +++ b/tools/ocaml/libs/xc/xc.h @@ -14,19 +14,13 @@ * GNU Lesser General Public License for more details. */ -#define __XEN_TOOLS__ - #include #include #include #include #include #include -#if XEN_SYSCTL_INTERFACE_VERSION < 4 -#include -#else #include -#endif #include #include #include diff --git a/tools/ocaml/libs/xc/xc_lib.c b/tools/ocaml/libs/xc/xc_lib.c index da072df569..981ab7bdc9 100644 --- a/tools/ocaml/libs/xc/xc_lib.c +++ b/tools/ocaml/libs/xc/xc_lib.c @@ -631,9 +631,9 @@ int xc_domain_getinfo(int handle, unsigned int domid, xc_domaininfo_t *info) int xc_domain_setmaxmem(int handle, unsigned int domid, unsigned int max_memkb) { + int ret; DECLARE_DOMCTL(XEN_DOMCTL_max_mem, domid); domctl.u.max_mem.max_memkb = max_memkb; - int ret; ret = do_domctl(handle, &domctl); if (ret < 0) @@ -682,9 +682,9 @@ int xc_domain_set_memmap_limit(int handle, unsigned int domid, int xc_domain_set_time_offset(int handle, unsigned int domid, int time_offset) { + int ret; DECLARE_DOMCTL(XEN_DOMCTL_settimeoffset, domid); domctl.u.settimeoffset.time_offset_seconds = time_offset; - int ret; ret = do_domctl(handle, &domctl); if (ret < 0) @@ -884,10 +884,10 @@ int xc_vcpu_setcontext(int handle, unsigned int domid, int xc_domain_irq_permission(int handle, unsigned int domid, unsigned char pirq, unsigned char allow_access) { + int ret; DECLARE_DOMCTL(XEN_DOMCTL_irq_permission, domid); domctl.u.irq_permission.pirq = pirq; domctl.u.irq_permission.allow_access = allow_access; - int ret; ret = do_domctl(handle, &domctl); if (ret) @@ -900,11 +900,11 @@ int xc_domain_iomem_permission(int handle, unsigned int domid, unsigned long first_mfn, unsigned long nr_mfns, unsigned char allow_access) { + int ret; DECLARE_DOMCTL(XEN_DOMCTL_iomem_permission, domid); domctl.u.iomem_permission.first_mfn = first_mfn; domctl.u.iomem_permission.nr_mfns = nr_mfns; domctl.u.iomem_permission.allow_access = allow_access; - int ret; ret = do_domctl(handle, &domctl); if (ret) diff --git a/tools/ocaml/libs/xc/xc_stubs.c b/tools/ocaml/libs/xc/xc_stubs.c index df0279869e..02dc1ad87a 100644 --- a/tools/ocaml/libs/xc/xc_stubs.c +++ b/tools/ocaml/libs/xc/xc_stubs.c @@ -99,7 +99,7 @@ CAMLprim value stub_marshall_core_header(value header) CAMLreturn(s); } -CAMLprim value stub_xc_interface_open() +CAMLprim value stub_xc_interface_open(void) { int handle; handle = xc_interface_open(); @@ -109,12 +109,12 @@ CAMLprim value stub_xc_interface_open() } -CAMLprim value stub_xc_interface_open_fake() +CAMLprim value stub_xc_interface_open_fake(void) { return Val_int(-1); } -CAMLprim value stub_xc_using_injection() +CAMLprim value stub_xc_using_injection(void) { if (xc_using_injection ()){ return Val_int(1); @@ -312,7 +312,9 @@ CAMLprim value stub_xc_domain_getinfolist(value xc_handle, value first_domain, v CAMLparam3(xc_handle, first_domain, nb); CAMLlocal2(result, temp); xc_domaininfo_t * info; - int i, ret, toalloc; + int i, ret, toalloc, c_xc_handle, retval; + unsigned int c_max_domains; + uint32_t c_first_domain; /* get the minimum number of allocate byte we need and bump it up to page boundary */ toalloc = (sizeof(xc_domaininfo_t) * Int_val(nb)) | 0xfff; @@ -322,12 +324,12 @@ CAMLprim value stub_xc_domain_getinfolist(value xc_handle, value first_domain, v result = temp = Val_emptylist; - int c_xc_handle = _H(xc_handle); - uint32_t c_first_domain = _D(first_domain); - unsigned int c_max_domains = Int_val(nb); + c_xc_handle = _H(xc_handle); + c_first_domain = _D(first_domain); + c_max_domains = Int_val(nb); // caml_enter_blocking_section(); - int retval = xc_domain_getinfolist(c_xc_handle, c_first_domain, - c_max_domains, info); + retval = xc_domain_getinfolist(c_xc_handle, c_first_domain, + c_max_domains, info); // caml_leave_blocking_section(); if (retval < 0) { @@ -849,15 +851,18 @@ CAMLprim value stub_map_foreign_range(value xc_handle, value dom, CAMLparam4(xc_handle, dom, size, mfn); CAMLlocal1(result); struct mmap_interface *intf; + int c_xc_handle; + uint32_t c_dom; + unsigned long c_mfn; result = caml_alloc(sizeof(struct mmap_interface), Abstract_tag); intf = (struct mmap_interface *) result; intf->len = Int_val(size); - int c_xc_handle = _H(xc_handle); - uint32_t c_dom = _D(dom); - unsigned long c_mfn = Nativeint_val(mfn); + c_xc_handle = _H(xc_handle); + c_dom = _D(dom); + c_mfn = Nativeint_val(mfn); // caml_enter_blocking_section(); intf->addr = xc_map_foreign_range(c_xc_handle, c_dom, intf->len, PROT_READ|PROT_WRITE, diff --git a/tools/ocaml/libs/xs/Makefile b/tools/ocaml/libs/xs/Makefile index 87cd375f16..266560f1ab 100644 --- a/tools/ocaml/libs/xs/Makefile +++ b/tools/ocaml/libs/xs/Makefile @@ -1,4 +1,5 @@ TOPLEVEL=../.. +XEN_ROOT=$(TOPLEVEL)/../.. include $(TOPLEVEL)/common.make OCAMLINCLUDE += -I ../xb/ diff --git a/tools/ocaml/xenstored/Makefile b/tools/ocaml/xenstored/Makefile index 1af6368e44..fc351d6829 100644 --- a/tools/ocaml/xenstored/Makefile +++ b/tools/ocaml/xenstored/Makefile @@ -1,3 +1,4 @@ +XEN_ROOT = ../../.. OCAML_TOPLEVEL = .. include $(OCAML_TOPLEVEL)/common.make