ocaml: NetBSD support and general CFLAGS cleanup
authorKeir Fraser <keir.fraser@citrix.com>
Fri, 7 May 2010 18:08:55 +0000 (19:08 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Fri, 7 May 2010 18:08:55 +0000 (19:08 +0100)
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
16 files changed:
Config.mk
tools/ocaml/common.make
tools/ocaml/libs/eventchn/Makefile
tools/ocaml/libs/eventchn/eventchn_stubs.c
tools/ocaml/libs/log/Makefile
tools/ocaml/libs/mmap/Makefile
tools/ocaml/libs/uuid/Makefile
tools/ocaml/libs/xb/Makefile
tools/ocaml/libs/xb/xb_stubs.c
tools/ocaml/libs/xb/xs_ring_stubs.c
tools/ocaml/libs/xc/Makefile
tools/ocaml/libs/xc/xc.h
tools/ocaml/libs/xc/xc_lib.c
tools/ocaml/libs/xc/xc_stubs.c
tools/ocaml/libs/xs/Makefile
tools/ocaml/xenstored/Makefile

index 903f01592473f9de1d2c927ceb0adb7866aaea35..da9276f9cf4069e7b2db24a2f1de7c8f06c45321 100644 (file)
--- 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
index cb951045824dc4cd62d04ce07f8b1f0154f0ea40..63b6b2ee24a38ee3fbe5e0e7af3c35203711cf07 100644 (file)
@@ -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
index 9d6ef31ffee971677163c32e5aea70c1b83151bf..60b66f28472f0405a395c1b8f6f443b2affc94b6 100644 (file)
@@ -1,4 +1,5 @@
 TOPLEVEL=../..
+XEN_ROOT=$(TOPLEVEL)/../..
 include $(TOPLEVEL)/common.make
 
 OBJS = eventchn
index ab61b0a22723043d95d6b70dcb3800f759ec4206..210aa30afaddcfca697fcec0d683bf45f527db88 100644 (file)
 #include <unistd.h>
 #include <errno.h>
 #include <stdint.h>
-
 #include <sys/ioctl.h>
-
-#define __XEN_TOOLS__
-
 #include <xen/sysctl.h>
-
-#if XEN_SYSCTL_INTERFACE_VERSION < 4
-#include <xen/linux/evtchn.h>
-#else
 #include <xen/xen.h>
 #include <xen/sys/evtchn.h>
-#endif
-
 #include <xenctrl.h>
 
 #define CAML_NAME_SPACE
index 47c7918fcc51f9926ce90b287a7eb8d2cc94e2eb..2a02629fff46780966e8cee4240f8d359acc5eaa 100644 (file)
@@ -1,4 +1,5 @@
 TOPLEVEL=../..
+XEN_ROOT=$(TOPLEVEL)/../..
 include $(TOPLEVEL)/common.make
 
 OBJS = syslog log logs
index bd8ab43b69d6f1c2cf12b71b266adbe6844943cc..374ef69cfdd9db2fb74dfd27f139a549f66021df 100644 (file)
@@ -1,4 +1,5 @@
 TOPLEVEL=../..
+XEN_ROOT=$(TOPLEVEL)/../..
 include $(TOPLEVEL)/common.make
 
 OBJS = mmap
index 8ddb0e2854eeb137164f4ead81d4091c0e297ffb..136967a9a893d6611c1c77792f5721abcd6039e3 100644 (file)
@@ -1,4 +1,5 @@
 TOPLEVEL=../..
+XEN_ROOT=$(TOPLEVEL)/../..
 include $(TOPLEVEL)/common.make
 
 OBJS = uuid
index 56afb4aa380391e65938f69f69ec9a36021dc538..c68dc9ed94ba4412ab56c96a6c7f437cb474486c 100644 (file)
@@ -1,4 +1,5 @@
 TOPLEVEL=../..
+XEN_ROOT=$(TOPLEVEL)/../..
 include $(TOPLEVEL)/common.make
 
 CFLAGS += -I../mmap
index b4d1ee65dc5253aea4ed0757f582fa6103bad5ec..a68e783f708b4395acd9ad7764599edcbaa63dc4 100644 (file)
 #include <caml/fail.h>
 #include <caml/callback.h>
 
-#define __XEN_TOOLS__
-
 #include <xenctrl.h>
-#define u32 uint32_t
 #include <xen/io/xs_wire.h>
 
 CAMLprim value stub_header_size(void)
index 9aef23ef4d93da2a5faee5918c5371781914d68e..a3bb175df99d852e74049dbeddf60c35705efb46 100644 (file)
 #include <errno.h>
 #include <string.h>
 
-#define __XEN_TOOLS__
-
 #include <xenctrl.h>
-#define u32 uint32_t
 #include <xen/io/xs_wire.h>
 
 #include <caml/mlvalues.h>
index 9e361b505e8b8958119aba58cf6c828976a6ccdc..b0b0bcc4ab94e0109f13987982a450d54f98c7e6 100644 (file)
@@ -1,4 +1,5 @@
 TOPLEVEL=../..
+XEN_ROOT=$(TOPLEVEL)/../..
 include $(TOPLEVEL)/common.make
 
 CFLAGS += -I../mmap -I./
index f88245decd3af1b7a8b3944be8be0ca2062e367f..ac3307a1e7a66137419f27249c76dbd3e42d25cb 100644 (file)
  * GNU Lesser General Public License for more details.
  */
 
-#define __XEN_TOOLS__
-
 #include <xen/xen.h>
 #include <xen/memory.h>
 #include <xen/sysctl.h>
 #include <xen/domctl.h>
 #include <xen/sched.h>
 #include <xen/sysctl.h>
-#if XEN_SYSCTL_INTERFACE_VERSION < 4
-#include <xen/linux/privcmd.h>
-#else
 #include <xen/sys/privcmd.h>
-#endif
 #include <xen/version.h>
 #include <xen/foreign/x86_32.h>
 #include <xen/foreign/x86_64.h>
index da072df569532f97a6a26f8cd027196485c3d823..981ab7bdc9cfa35253a65f54dc8d934a5aef9251 100644 (file)
@@ -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)
index df0279869eab589ebaafb14bd6cd2caa1a40ddcc..02dc1ad87ac0965ce7de86b99cb21c4c1aa5d30f 100644 (file)
@@ -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,
index 87cd375f1687465dd91b21bd1f7360088a222be2..266560f1ab7c3e6d4516fc7dfe006520261f2d4c 100644 (file)
@@ -1,4 +1,5 @@
 TOPLEVEL=../..
+XEN_ROOT=$(TOPLEVEL)/../..
 include $(TOPLEVEL)/common.make
 
 OCAMLINCLUDE += -I ../xb/
index 1af6368e44eacb9a7f0224a46ac6f965c6a7dd2e..fc351d6829f20174c4cd9bdaa3b064b2bdd2adde 100644 (file)
@@ -1,3 +1,4 @@
+XEN_ROOT = ../../..
 OCAML_TOPLEVEL = ..
 include $(OCAML_TOPLEVEL)/common.make