[xiph-commits] r18873 - trunk/squishyball

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Tue Mar 12 12:58:58 PDT 2013


Author: xiphmont
Date: 2013-03-12 12:58:58 -0700 (Tue, 12 Mar 2013)
New Revision: 18873

Modified:
   trunk/squishyball/main.c
   trunk/squishyball/mincurses.c
Log:
From: "Kyle J. McKay" <mackyle at gmail.com>
Subject: [PATCH 2/6] Expunge poll calls when defined(__APPLE__)

Use select() rather than poll() on Mac OS X



Modified: trunk/squishyball/main.c
===================================================================
--- trunk/squishyball/main.c	2013-03-12 19:56:10 UTC (rev 18872)
+++ trunk/squishyball/main.c	2013-03-12 19:58:58 UTC (rev 18873)
@@ -42,6 +42,9 @@
 #include <signal.h>
 #include <ncurses.h>
 #include <poll.h>
+#ifdef __APPLE__
+#include <sys/select.h>
+#endif
 #include "mincurses.h"
 #include "main.h"
 
@@ -304,6 +307,17 @@
       pthread_mutex_unlock(&s->mutex);
 
       {
+#ifdef __APPLE__
+        fd_set fds;
+        FD_ZERO(&fds);
+        FD_SET(STDIN_FILENO, &fds);
+        FD_SET(s->exit_fd, &fds);
+        ret=select(s->exit_fd+1,&fds,NULL,NULL,NULL);
+        if(FD_ISSET(s->exit_fd,&fds))
+          break;
+        if(FD_ISSET(STDIN_FILENO,&fds))
+          ret=min_getch(1);
+#else
         struct pollfd fds[2]={
           {STDIN_FILENO,POLLIN,0},
           {s->exit_fd,POLLIN,0}
@@ -314,6 +328,7 @@
           break;
         if(fds[0].revents&(POLLIN))
           ret=min_getch(1);
+#endif
       }
       pthread_mutex_lock(&s->mutex);
     }

Modified: trunk/squishyball/mincurses.c
===================================================================
--- trunk/squishyball/mincurses.c	2013-03-12 19:56:10 UTC (rev 18872)
+++ trunk/squishyball/mincurses.c	2013-03-12 19:58:58 UTC (rev 18873)
@@ -46,6 +46,10 @@
 #include <math.h>
 #include <errno.h>
 #include <poll.h>
+#ifdef __APPLE__
+#include <sys/select.h>
+#include <sys/time.h>
+#endif
 
 #include "mincurses.h"
 
@@ -177,11 +181,22 @@
 
   if(nonblock){
     int ret;
+#ifdef __APPLE__
+    fd_set fds;
+    struct timeval zeroto = {0,0};
+    FD_ZERO(&fds);
+    FD_SET(STDIN_FILENO,&fds);
+    ret=select(STDIN_FILENO+1,&fds,NULL,NULL,&zeroto);
+    if(ret!=1){
+      return ERR;
+    }
+#else
     struct pollfd fds={STDIN_FILENO,POLLIN,0};
     ret=poll(&fds, 1, 0);
     if(!fds.revents&(POLLIN)){
       return ERR;
     }
+#endif
   }
   n = read(STDIN_FILENO, &c2, 1);
   ch = c2;



More information about the commits mailing list