[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] tools: ocaml: Change GET_C_STRUCT to Intf_val to follow common naming scheme



# HG changeset patch
# User Zheng Li <dev@xxxxxxxx>
# Date 1317919625 -3600
# Node ID f0c0aa7d57e67a64a339eba24bef59b817a2c96d
# Parent  4d4edbc963560a25547eb91ffaec1ec273b09b38
tools: ocaml: Change GET_C_STRUCT to Intf_val to follow common naming scheme

Change GET_C_STRUCT to Intf_val to follow the common naming scheme of
OCaml macros, and for better readability.

Signed-off-by: Zheng Li <dev@xxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---


diff -r 4d4edbc96356 -r f0c0aa7d57e6 tools/ocaml/libs/mmap/mmap_stubs.c
--- a/tools/ocaml/libs/mmap/mmap_stubs.c        Thu Oct 06 17:45:43 2011 +0100
+++ b/tools/ocaml/libs/mmap/mmap_stubs.c        Thu Oct 06 17:47:05 2011 +0100
@@ -28,7 +28,7 @@
 #include <caml/fail.h>
 #include <caml/callback.h>
 
-#define GET_C_STRUCT(a) ((struct mmap_interface *) a)
+#define Intf_val(a) ((struct mmap_interface *) a)
 
 static int mmap_interface_init(struct mmap_interface *intf,
                                int fd, int pflag, int mflag,
@@ -61,27 +61,27 @@
 
        result = caml_alloc(sizeof(struct mmap_interface), Abstract_tag);
 
-       if (mmap_interface_init(GET_C_STRUCT(result), Int_val(fd),
+       if (mmap_interface_init(Intf_val(result), Int_val(fd),
                                c_pflag, c_mflag,
                                Int_val(len), Int_val(offset)))
                caml_failwith("mmap");
        CAMLreturn(result);
 }
 
-CAMLprim value stub_mmap_final(value interface)
+CAMLprim value stub_mmap_final(value intf)
 {
-       CAMLparam1(interface);
+       CAMLparam1(intf);
 
-       if (GET_C_STRUCT(interface)->addr != MAP_FAILED)
-               munmap(GET_C_STRUCT(interface)->addr, 
GET_C_STRUCT(interface)->len);
-       GET_C_STRUCT(interface)->addr = MAP_FAILED;
+       if (Intf_val(intf)->addr != MAP_FAILED)
+               munmap(Intf_val(intf)->addr, Intf_val(intf)->len);
+       Intf_val(intf)->addr = MAP_FAILED;
 
        CAMLreturn(Val_unit);
 }
 
-CAMLprim value stub_mmap_read(value interface, value start, value len)
+CAMLprim value stub_mmap_read(value intf, value start, value len)
 {
-       CAMLparam3(interface, start, len);
+       CAMLparam3(intf, start, len);
        CAMLlocal1(data);
        int c_start;
        int c_len;
@@ -89,33 +89,33 @@
        c_start = Int_val(start);
        c_len = Int_val(len);
 
-       if (c_start > GET_C_STRUCT(interface)->len)
+       if (c_start > Intf_val(intf)->len)
                caml_invalid_argument("start invalid");
-       if (c_start + c_len > GET_C_STRUCT(interface)->len)
+       if (c_start + c_len > Intf_val(intf)->len)
                caml_invalid_argument("len invalid");
 
        data = caml_alloc_string(c_len);
-       memcpy((char *) data, GET_C_STRUCT(interface)->addr + c_start, c_len);
+       memcpy((char *) data, Intf_val(intf)->addr + c_start, c_len);
 
        CAMLreturn(data);
 }
 
-CAMLprim value stub_mmap_write(value interface, value data,
+CAMLprim value stub_mmap_write(value intf, value data,
                                value start, value len)
 {
-       CAMLparam4(interface, data, start, len);
+       CAMLparam4(intf, data, start, len);
        int c_start;
        int c_len;
 
        c_start = Int_val(start);
        c_len = Int_val(len);
 
-       if (c_start > GET_C_STRUCT(interface)->len)
+       if (c_start > Intf_val(intf)->len)
                caml_invalid_argument("start invalid");
-       if (c_start + c_len > GET_C_STRUCT(interface)->len)
+       if (c_start + c_len > Intf_val(intf)->len)
                caml_invalid_argument("len invalid");
 
-       memcpy(GET_C_STRUCT(interface)->addr + c_start, (char *) data, c_len);
+       memcpy(Intf_val(intf)->addr + c_start, (char *) data, c_len);
 
        CAMLreturn(Val_unit);
 }

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.