libxc: osdep: convert xc_evtchn_{pending,unmask}()
authorIan Campbell <ian.campbell@citrix.com>
Fri, 3 Dec 2010 09:36:47 +0000 (09:36 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 3 Dec 2010 09:36:47 +0000 (09:36 +0000)
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson.citrix.com>
tools/libxc/xc_evtchn.c
tools/libxc/xc_linux.c
tools/libxc/xc_minios.c
tools/libxc/xc_netbsd.c
tools/libxc/xc_solaris.c
tools/libxc/xenctrlosdep.h

index 81fc15b29add9f51c12514b11cb2c12b1127d312..d8c203f2c2e349dfc9332ec014617fb521eb45b5 100644 (file)
@@ -112,6 +112,17 @@ int xc_evtchn_unbind(xc_evtchn *xce, evtchn_port_t port)
     return xce->ops->u.evtchn.unbind(xce, xce->ops_handle, port);
 }
 
+evtchn_port_or_error_t
+xc_evtchn_pending(xc_evtchn *xce)
+{
+    return xce->ops->u.evtchn.pending(xce, xce->ops_handle);
+}
+
+int xc_evtchn_unmask(xc_evtchn *xce, evtchn_port_t port)
+{
+    return xce->ops->u.evtchn.unmask(xce, xce->ops_handle, port);
+}
+
 /*
  * Local variables:
  * mode: C
index 9044020fe89ef8462de55902b37915cd1d59b488..188741f3df18f8000683673021b7dac3f8cee7fa 100644 (file)
@@ -420,20 +420,24 @@ static int linux_evtchn_unbind(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t
     return ioctl(fd, IOCTL_EVTCHN_UNBIND, &unbind);
 }
 
-evtchn_port_or_error_t
-xc_evtchn_pending(xc_evtchn *xce)
+static evtchn_port_or_error_t linux_evtchn_pending(xc_evtchn *xce, xc_osdep_handle h)
 {
+    int fd = (int)h;
     evtchn_port_t port;
 
-    if ( read_exact(xce->fd, (char *)&port, sizeof(port)) == -1 )
+    if ( read(fd, &port, sizeof(port)) != sizeof(port) )
         return -1;
 
     return port;
 }
 
-int xc_evtchn_unmask(xc_evtchn *xce, evtchn_port_t port)
+static int linux_evtchn_unmask(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t port)
 {
-    return write_exact(xce->fd, (char *)&port, sizeof(port));
+    int fd = (int)h;
+
+    if ( write(fd, &port, sizeof(port)) != sizeof(port) )
+        return -1;
+    return 0;
 }
 
 static struct xc_osdep_ops linux_evtchn_ops = {
@@ -447,6 +451,8 @@ static struct xc_osdep_ops linux_evtchn_ops = {
         .bind_interdomain = &linux_evtchn_bind_interdomain,
         .bind_virq = &linux_evtchn_bind_virq,
         .unbind = &linux_evtchn_unbind,
+        .pending = &linux_evtchn_pending,
+        .unmask = &linux_evtchn_unmask,
     },
 };
 
index e01b4b499255987326328c7eefaef58b4282a4dc..af3791f4fa0ecb64d143f32408d087026ae43a4f 100644 (file)
@@ -371,22 +371,23 @@ static evtchn_port_or_error_t minios_evtchn_bind_virq(xc_evtchn *xce, xc_osdep_h
     return port;
 }
 
-evtchn_port_or_error_t xc_evtchn_pending(xc_evtchn *xce)
+static evtchn_port_or_error_t minios_evtchn_pending(xc_evtchn *xce, xc_osdep_handle h)
 {
+    int fd = (int)h;
     int i;
     unsigned long flags;
     evtchn_port_t ret = -1;
 
     local_irq_save(flags);
-    files[xce->fd].read = 0;
+    files[fd].read = 0;
     for (i = 0; i < MAX_EVTCHN_PORTS; i++) {
-        evtchn_port_t port = files[xce->fd].evtchn.ports[i].port;
-        if (port != -1 && files[xce->fd].evtchn.ports[i].pending) {
+        evtchn_port_t port = files[fd].evtchn.ports[i].port;
+        if (port != -1 && files[fd].evtchn.ports[i].pending) {
             if (ret == -1) {
                 ret = port;
-                files[xce->fd].evtchn.ports[i].pending = 0;
+                files[fd].evtchn.ports[i].pending = 0;
             } else {
-                files[xce->fd].read = 1;
+                files[fd].read = 1;
                 break;
             }
         }
@@ -395,7 +396,7 @@ evtchn_port_or_error_t xc_evtchn_pending(xc_evtchn *xce)
     return ret;
 }
 
-int xc_evtchn_unmask(xc_evtchn *xce, evtchn_port_t port)
+static int minios_evtchn_unmask(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t port)
 {
     unmask_evtchn(port);
     return 0;
@@ -412,7 +413,9 @@ static struct xc_osdep_ops minios_evtchn_ops = {
         .bind_interdomain = &minios_evtchn_bind_interdomain,
         .bind_virq = &minios_evtchn_bind_virq,
         .unbind = &minios_evtchn_unbind,
-    },
+        .pending = &minios_evtchn_pending,
+        .unmask = &minios_evtchn_unmask,
+   },
 };
 
 /* Optionally flush file to disk and discard page cache */
index 9d708fce57701a744636f3b368f26596d6bccb2c..47169ee5b465f1eff47f0e9ab2a0609a1aed0446 100644 (file)
@@ -285,20 +285,22 @@ netbsd_evtchn_bind_virq(xc_evtchn *xce, xc_osdep_handle h, unsigned int virq)
        return bind.port;
 }
 
-evtchn_port_or_error_t
-xc_evtchn_pending(xc_evtchn *xce)
+static evtchn_port_or_error_t
+netbsd_evtchn_pending(xc_evtchn *xce, xc_osdep_handle h)
 {
+    int fd = (int)h;
     evtchn_port_t port;
 
-    if ( read_exact(xce->fd, (char *)&port, sizeof(port)) == -1 )
+    if ( read_exact(fd, (char *)&port, sizeof(port)) == -1 )
         return -1;
 
     return port;
 }
 
-int xc_evtchn_unmask(xc_evtchn *xce, evtchn_port_t port)
+static int netbsd_evtchn_unmask(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t port)
 {
-    return write_exact(xce->fd, (char *)&port, sizeof(port));
+    int fd = (int)h;
+    return write_exact(fd, (char *)&port, sizeof(port));
 }
 
 static struct xc_osdep_ops netbsd_evtchn_ops = {
@@ -312,6 +314,8 @@ static struct xc_osdep_ops netbsd_evtchn_ops = {
          .bind_interdomain = &netbsd_evtchn_bind_interdomain,
          .bind_virq = &netbsd_evtchn_bind_virq,
          .unbind = &netbsd_evtchn_unbind,
+         .pending = &netbsd_evtchn_pending,
+         .unmask = &netbsd_evtchn_unmask,
     },
 };
 
index ea786e79eebb1afdf3992addb6c8854cb0b99f59..beec2872d4d6d17a1f574b9cc99f470a001c0550 100644 (file)
@@ -262,20 +262,22 @@ static int solaris_evtchn_unbind(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_
     return ioctl(fd, IOCTL_EVTCHN_UNBIND, &unbind);
 }
 
-evtchn_port_or_error_t
-xc_evtchn_pending(xc_evtchn *xce)
+static evtchn_port_or_error_t
+solaris_evtchn_pending(xc_evtchn *xce, xc_osdep_handle h)
 {
+    int fd = (int)h;
     evtchn_port_t port;
 
-    if ( read_exact(xce->fd, (char *)&port, sizeof(port)) == -1 )
+    if ( read_exact(fd, (char *)&port, sizeof(port)) == -1 )
         return -1;
 
     return port;
 }
 
-int xc_evtchn_unmask(xc_evtchn *xce, evtchn_port_t port)
+static int solaris_evtchn_unmask(xc_evtchn *xce, xc_osdep_handle h,evtchn_port_t port)
 {
-    return write_exact(xce->fd, (char *)&port, sizeof(port));
+    int fd = (int)h;
+    return write_exact(fd, (char *)&port, sizeof(port));
 }
 
 static struct xc_osdep_ops solaris_evtchn_ops = {
@@ -289,6 +291,8 @@ static struct xc_osdep_ops solaris_evtchn_ops = {
         .bind_interdomain = &solaris_evtchn_bind_interdomain,
         .bind_virq = &solaris_evtchn_bind_virq,
         .unbind = &solaris_evtchn_unbind,
+        .pending = &solaris_evtchn_pending,
+        .unmask = &solaris_evtchn_unmask,
     },
 };
 
index 9091d0be8fbb1ebe0de5c32c87ee3e67a98703f3..24d4bc27ef880cd8aff0b2b7cfd07e29c2f05508 100644 (file)
@@ -85,6 +85,9 @@ struct xc_osdep_ops
             evtchn_port_or_error_t (*bind_virq)(xc_evtchn *xce, xc_osdep_handle h, unsigned int virq);
 
             int (*unbind)(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t port);
+
+            evtchn_port_or_error_t (*pending)(xc_evtchn *xce, xc_osdep_handle h);
+            int (*unmask)(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t port);
         } evtchn;
     } u;
 };