pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/emulators/qemu use fakepoll.h implementation of poll u...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/14f7767c0900
branches:  trunk
changeset: 502464:14f7767c0900
user:      dbj <dbj%pkgsrc.org@localhost>
date:      Fri Nov 04 21:09:15 2005 +0000

description:
use fakepoll.h implementation of poll using select on apple, which has
a broken poll.

diffstat:

 emulators/qemu/distinfo         |    5 +-
 emulators/qemu/patches/patch-ac |   22 ++++-
 emulators/qemu/patches/patch-ax |  166 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 186 insertions(+), 7 deletions(-)

diffs (228 lines):

diff -r 46f19cf254a3 -r 14f7767c0900 emulators/qemu/distinfo
--- a/emulators/qemu/distinfo   Fri Nov 04 21:05:51 2005 +0000
+++ b/emulators/qemu/distinfo   Fri Nov 04 21:09:15 2005 +0000
@@ -1,10 +1,10 @@
-$NetBSD: distinfo,v 1.12 2005/10/23 19:55:59 rillig Exp $
+$NetBSD: distinfo,v 1.13 2005/11/04 21:09:15 dbj Exp $
 
 SHA1 (qemu-0.7.2.tar.gz) = 4daeccb57448eacc444152f30b5d84dfcca89dfe
 RMD160 (qemu-0.7.2.tar.gz) = 1d2dcc8f43ff4b4b9aa045c64e38c9a10140b13e
 Size (qemu-0.7.2.tar.gz) = 1341993 bytes
 SHA1 (patch-aa) = 455575215bad8864da285e1979da9ff7d8476a24
-SHA1 (patch-ac) = a54824b658f4bbdbbdf74ad1a12bf25bce8f1164
+SHA1 (patch-ac) = fa190b38658ad487a6ddf6d78cc3cbb262c67702
 SHA1 (patch-af) = 221d6d85aa898cb27462806faab58ee2a9871a1c
 SHA1 (patch-ag) = 4bb7ae18fd0f0c5ecfa2ab2594d1de5b33660495
 SHA1 (patch-ah) = 134f47583dbed94e83671ca6197106805b13f759
@@ -20,3 +20,4 @@
 SHA1 (patch-au) = aa2712c382a67beef9225e710e7735ba15995a41
 SHA1 (patch-av) = bd88088f41b6b3c256eec933e5f267fc432e58fa
 SHA1 (patch-aw) = 6299964fb3a747e8f5dfe4354e66722030ee9a75
+SHA1 (patch-ax) = b6eb66859e3ab318ec388d9f33201c27f34677ca
diff -r 46f19cf254a3 -r 14f7767c0900 emulators/qemu/patches/patch-ac
--- a/emulators/qemu/patches/patch-ac   Fri Nov 04 21:05:51 2005 +0000
+++ b/emulators/qemu/patches/patch-ac   Fri Nov 04 21:09:15 2005 +0000
@@ -1,8 +1,20 @@
-$NetBSD: patch-ac,v 1.3 2005/05/25 18:04:57 dbj Exp $
+$NetBSD: patch-ac,v 1.4 2005/11/04 21:09:15 dbj Exp $
 
---- vl.c.orig  Wed Apr 27 16:52:05 2005
-+++ vl.c       Wed May 25 11:42:18 2005
-@@ -43,8 +43,10 @@
+--- vl.c.orig  2005-04-27 16:52:05.000000000 -0400
++++ vl.c
+@@ -34,7 +34,11 @@
+ #include <sys/times.h>
+ #include <sys/wait.h>
+ #include <termios.h>
++#ifdef __APPLE__
++#include "fakepoll.h"
++#else
+ #include <sys/poll.h>
++#endif
+ #include <sys/mman.h>
+ #include <sys/ioctl.h>
+ #include <sys/socket.h>
+@@ -43,8 +47,10 @@
  #ifdef _BSD
  #include <sys/stat.h>
  #ifndef __APPLE__
@@ -13,7 +25,7 @@
  #else
  #include <linux/if.h>
  #include <linux/if_tun.h>
-@@ -68,7 +70,7 @@
+@@ -68,7 +74,7 @@
  
  #ifdef CONFIG_SDL
  #ifdef __APPLE__
diff -r 46f19cf254a3 -r 14f7767c0900 emulators/qemu/patches/patch-ax
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/emulators/qemu/patches/patch-ax   Fri Nov 04 21:09:15 2005 +0000
@@ -0,0 +1,166 @@
+$NetBSD: patch-ax,v 1.1 2005/11/04 21:09:15 dbj Exp $
+
+--- /dev/null  2005-10-13 14:41:11.000000000 -0400
++++ fakepoll.h
+@@ -0,0 +1,161 @@
++// fakepoll.h
++// poll using select
++// Warning: a call to this poll() takes about 4K of stack space.
++
++// Greg Parker     gparker-web%sealiesoftware.com@localhost     December 2000
++// This code is in the public domain and may be copied or modified without 
++// permission. 
++
++// Updated May 2002: 
++// * fix crash when an fd is less than 0
++// * set errno=EINVAL if an fd is greater or equal to FD_SETSIZE
++// * don't set POLLIN or POLLOUT in revents if it wasn't requested 
++//   in events (only happens when an fd is in the poll set twice)
++
++#ifndef _FAKE_POLL_H
++#define _FAKE_POLL_H
++
++#include <limits.h>
++#define FD_SETSIZE OPEN_MAX
++#include <sys/types.h>
++#include <sys/time.h>
++#include <unistd.h>
++#include <stdlib.h>
++
++typedef struct pollfd {
++    int fd;                         /* file desc to poll */
++    short events;                   /* events of interest on fd */
++    short revents;                  /* events that occurred on fd */
++} pollfd_t;
++
++
++// poll flags
++#define POLLIN  0x0001
++#define POLLOUT 0x0004
++#define POLLERR 0x0008
++
++// synonyms
++#define POLLNORM POLLIN
++#define POLLPRI POLLIN
++#define POLLRDNORM POLLIN
++#define POLLRDBAND POLLIN
++#define POLLWRNORM POLLOUT
++#define POLLWRBAND POLLOUT
++
++// ignored
++#define POLLHUP 0x0010
++#define POLLNVAL 0x0020
++
++inline int poll(struct pollfd *pollSet, int pollCount, int pollTimeout)
++{
++    struct timeval tv;
++    struct timeval *tvp;
++    fd_set readFDs, writeFDs, exceptFDs;
++    fd_set *readp, *writep, *exceptp;
++    struct pollfd *pollEnd, *p;
++    int selected;
++    int result;
++    int maxFD;
++
++    if (!pollSet) {
++        pollEnd = NULL;
++        readp = NULL;
++        writep = NULL;
++        exceptp = NULL;
++        maxFD = 0;
++    } 
++    else {
++        pollEnd = pollSet + pollCount;
++        readp = &readFDs;
++        writep = &writeFDs;
++        exceptp = &exceptFDs;
++
++        FD_ZERO(readp);
++        FD_ZERO(writep);
++        FD_ZERO(exceptp);
++        
++        // Find the biggest fd in the poll set
++        maxFD = 0;
++        for (p = pollSet; p < pollEnd; p++) {
++            if (p->fd > maxFD) maxFD = p->fd;
++        }
++
++        if (maxFD >= FD_SETSIZE) {
++            // At least one fd is too big
++            errno = EINVAL;
++            return -1;
++        }
++        
++        // Transcribe flags from the poll set to the fd sets
++        for (p = pollSet; p < pollEnd; p++) {
++            if (p->fd < 0) {
++                // Negative fd checks nothing and always reports zero
++            } else {
++                if (p->events & POLLIN)  FD_SET(p->fd, readp);
++                if (p->events & POLLOUT) FD_SET(p->fd, writep);
++                if (p->events != 0)      FD_SET(p->fd, exceptp);
++                // POLLERR is never set coming in; poll() always reports errors
++                // But don't report if we're not listening to anything at all.
++            }
++        }
++    }
++        
++    // poll timeout is in milliseconds. Convert to struct timeval.
++    // poll timeout == -1 : wait forever : select timeout of NULL
++    // poll timeout == 0  : return immediately : select timeout of zero
++    if (pollTimeout >= 0) {
++        tv.tv_sec = pollTimeout / 1000;
++        tv.tv_usec = (pollTimeout % 1000) * 1000;
++        tvp = &tv;
++    } else {
++        tvp = NULL;
++    }
++    
++    
++    selected = select(maxFD+1, readp, writep, exceptp, tvp);
++
++
++    if (selected < 0) {
++        // Error during select
++        result = -1;
++    } 
++    else if (selected > 0) {
++        // Select found something
++        // Transcribe result from fd sets to poll set.
++        // Also count the number of selected fds. poll returns the 
++        // number of ready fds; select returns the number of bits set.
++        int polled = 0;
++        for (p = pollSet; p < pollEnd; p++) {
++          p->revents = 0;
++            if (p->fd < 0) {
++                // Negative fd always reports zero
++            } else {
++                if ((p->events & POLLIN)   &&  FD_ISSET(p->fd, readp)) {
++                    p->revents |= POLLIN;
++                }
++                if ((p->events & POLLOUT)  &&  FD_ISSET(p->fd, writep)) {
++                    p->revents |= POLLOUT;
++                }
++                if ((p->events != 0)       &&  FD_ISSET(p->fd, exceptp)) {
++                    p->revents |= POLLERR;
++                }
++
++                if (p->revents) polled++;
++            }
++      }
++        result = polled;
++    }
++    else {
++      // selected == 0, select timed out before anything happened
++        // Clear all result bits and return zero.
++        for (p = pollSet; p < pollEnd; p++) {
++            p->revents = 0;
++        }
++        result = 0;
++    }
++
++    return result;
++}
++
++
++#endif



Home | Main Index | Thread Index | Old Index