pkgsrc/sysutils/xentools20/patches/patch-ac
seb 9ab4a5acbe Fix build with libcurl-7.6.10.
Fix build with NetBSD's current gcc 4.1.2.
Bump PKGREVISION to 9.

Approved by maintainer.
2006-11-22 00:12:34 +00:00

122 lines
3.7 KiB
Text

$NetBSD: patch-ac,v 1.4 2006/11/22 00:12:34 seb Exp $
--- python/xen/lowlevel/xu/xu.c.orig 2005-08-03 23:57:58.000000000 +0000
+++ python/xen/lowlevel/xu/xu.c
@@ -15,7 +15,9 @@
#include <sys/socket.h>
#include <sys/mman.h>
#include <sys/poll.h>
+#ifndef __NetBSD__
#include <sys/sysmacros.h>
+#endif
#include <netinet/in.h>
#include <fcntl.h>
#include <unistd.h>
@@ -25,7 +27,11 @@
#include <xen/xen.h>
#include <xen/io/domain_controller.h>
+#ifdef __NetBSD__
+#include <xen/NetBSD/xenio.h>
+#else
#include <xen/linux/privcmd.h>
+#endif
#define XENPKG "xen.lowlevel.xu"
@@ -35,6 +41,9 @@
#endif
/* NB. The following should be kept in sync with the kernel's evtchn driver. */
+#ifdef __NetBSD__
+#define EVTCHN_DEV_NAME "/dev/xenevt"
+#else
#define EVTCHN_DEV_NAME "/dev/xen/evtchn"
#define EVTCHN_DEV_MAJOR 10
#define EVTCHN_DEV_MINOR 201
@@ -45,6 +54,7 @@
#define EVTCHN_BIND _IO('E', 2)
/* EVTCHN_UNBIND: Unbind from the specified event-channel port. */
#define EVTCHN_UNBIND _IO('E', 3)
+#endif
/* Size of a machine page frame. */
#define PAGE_SIZE 4096
@@ -130,7 +140,11 @@ static PyObject *xu_notifier_bind(PyObje
if ( !PyArg_ParseTuple(args, "i", &idx) )
return NULL;
+#ifdef __NetBSD__
+ if ( ioctl(xun->evtchn_fd, EVTCHN_BIND, &idx) != 0 )
+#else
if ( ioctl(xun->evtchn_fd, EVTCHN_BIND, idx) != 0 )
+#endif
return PyErr_SetFromErrno(PyExc_IOError);
Py_INCREF(Py_None);
@@ -145,7 +159,11 @@ static PyObject *xu_notifier_unbind(PyOb
if ( !PyArg_ParseTuple(args, "i", &idx) )
return NULL;
+#ifdef __NetBSD__
+ if ( ioctl(xun->evtchn_fd, EVTCHN_UNBIND, &idx) != 0 )
+#else
if ( ioctl(xun->evtchn_fd, EVTCHN_UNBIND, idx) != 0 )
+#endif
return PyErr_SetFromErrno(PyExc_IOError);
Py_INCREF(Py_None);
@@ -192,13 +210,16 @@ staticforward PyTypeObject xu_notifier_t
static PyObject *xu_notifier_new(PyObject *self, PyObject *args)
{
xu_notifier_object *xun;
+#ifndef __NetBSD__
struct stat st;
+#endif
if ( !PyArg_ParseTuple(args, "") )
return NULL;
xun = PyObject_New(xu_notifier_object, &xu_notifier_type);
+#ifndef __NetBSD__
/* Make sure any existing device file links to correct device. */
if ( (lstat(EVTCHN_DEV_NAME, &st) != 0) ||
!S_ISCHR(st.st_mode) ||
@@ -206,14 +227,17 @@ static PyObject *xu_notifier_new(PyObjec
(void)unlink(EVTCHN_DEV_NAME);
reopen:
+#endif
xun->evtchn_fd = open(EVTCHN_DEV_NAME, O_NONBLOCK|O_RDWR);
if ( xun->evtchn_fd == -1 )
{
+#ifndef __NetBSD__
if ( (errno == ENOENT) &&
((mkdir("/dev/xen", 0755) == 0) || (errno == EEXIST)) &&
(mknod(EVTCHN_DEV_NAME, S_IFCHR|0600,
makedev(EVTCHN_DEV_MAJOR,EVTCHN_DEV_MINOR)) == 0) )
goto reopen;
+#endif
PyObject_Del((PyObject *)xun);
return PyErr_SetFromErrno(PyExc_IOError);
}
@@ -508,7 +532,7 @@ static PyObject *xu_message_get_payload(
return dict;
}
- return PyString_FromStringAndSize(xum->msg.msg, xum->msg.length);
+ return PyString_FromStringAndSize((char *)xum->msg.msg, xum->msg.length);
}
static PyObject *xu_message_get_header(PyObject *self, PyObject *args)
@@ -1110,7 +1134,8 @@ static PyObject *xu_port_new(PyObject *s
* The control-interface event channel for DOM0 is already set up.
* We use an ioctl to discover the port at our end of the channel.
*/
- port1 = ioctl(xup->xc_handle, IOCTL_PRIVCMD_INITDOMAIN_EVTCHN, NULL);
+ if (ioctl(xup->xc_handle, IOCTL_PRIVCMD_INITDOMAIN_EVTCHN, &port1))
+ port1 = -1;
port2 = -1; /* We don't need the remote end of the DOM0 link. */
if ( port1 < 0 )
{