Commit Diff


commit - 6e2cec77b292cc2285e369ec01faa877ea91dbdd
commit + 53dbac948575b07e95d184bbfbe4d8953c5ccc4c
blob - 602d0289b34768bd71876c03c7afd6059a10d200
blob + 871e6f66332b53d5a5c732f0393c9e6459d91ed0
--- bin/9c
+++ bin/9c
@@ -19,7 +19,9 @@ usegcc()
 tag="`uname`-`uname -m`-${CC9:-cc}"
 case "$tag" in
 *BSD*)		usegcc ;;
-*Darwin*)	usegcc ;;
+*Darwin*)	usegcc 
+	cflags=`echo $cflags|sed 's/-ggdb/-g3 -no-cpp-precomp/'`
+	;;
 *HP-UX*)	cc=cc; cflags="-g -O -c -Ae" ;;
 *Linux*)	usegcc ;;
 *OSF1*)		cc=cc; cflags="-g -O -c" ;;
blob - 4263f0359811fc3b1ffa7babe175280b883d0aab
blob + 3d72437f12e559065cd257247596586712dbf33d
--- src/cmd/9pserve.c
+++ src/cmd/9pserve.c
@@ -2,7 +2,6 @@
 #include <libc.h>
 #include <fcall.h>
 #include <thread.h>
-#include <poll.h>
 #include <errno.h>
 
 enum
blob - 16804b33f3c5d53ccd8b2778dc5b81f80bf977c8
blob + 7824ff18d26d8d74d03f3c45d196d522416275ac
--- src/lib9/mkfile
+++ src/lib9/mkfile
@@ -10,7 +10,6 @@ NUM=\
 # Could add errfmt, but we want to pick it up from lib9 instead.
 FMTOFILES=\
 	dofmt.$O\
-	errfmt.$O\
 	fltfmt.$O\
 	fmt.$O\
 	fmtfd.$O\
blob - 4467377ae1b2732aa3f33fa54b41d8b0e3731bcd
blob + 32f434c4fb2633d7e6027f74c024a6ceda318e88
--- src/lib9/quote.c
+++ src/lib9/quote.c
@@ -1,9 +1,9 @@
 #include <u.h>
 #include <libc.h>
 
-int	(*doquote)(int);
 
 /* in libfmt */
+extern int (*doquote)(int);
 extern int __needsquotes(char*, int*);
 extern int __runeneedsquotes(Rune*, int*);
 
blob - 2f8581f119592bef775e930d012743cdf91e68b6
blob + 170305eb9365434559a39e4c8b5180de5296ade1
--- src/libthread/fdwait.c
+++ src/libthread/fdwait.c
@@ -4,10 +4,87 @@
 #include <thread.h>
 
 #include <errno.h>
-#include <poll.h>
 #include <unistd.h>
 #include <fcntl.h>
+
+#define debugpoll 0
+
+#ifdef __APPLE__
+#include <sys/time.h>
+enum { POLLIN=1, POLLOUT=2, POLLERR=4 };
+struct pollfd
+{
+	int fd;
+	int events;
+	int revents;
+};
+
+int
+poll(struct pollfd *p, int np, int ms)
+{
+	int i, maxfd, n;
+	struct timeval tv, *tvp;
+	fd_set rfd, wfd, efd;
+	
+	maxfd = -1;
+	FD_ZERO(&rfd);
+	FD_ZERO(&wfd);
+	FD_ZERO(&efd);
+	for(i=0; i<np; i++){
+		p[i].revents = 0;
+		if(p[i].fd == -1)
+			continue;
+		if(p[i].fd > maxfd)
+			maxfd = p[i].fd;
+		if(p[i].events & POLLIN)
+			FD_SET(p[i].fd,	&rfd);
+		if(p[i].events & POLLOUT)
+			FD_SET(p[i].fd, &wfd);
+		FD_SET(p[i].fd, &efd);
+	}
+
+	if(ms != -1){
+		tv.tv_usec = (ms%1000)*1000;
+		tv.tv_sec = ms/1000;
+		tvp = &tv;
+	}else
+		tvp = nil;
+
+	if(debugpoll){
+		fprint(2, "select %d:", maxfd+1);
+		for(i=0; i<=maxfd; i++){
+			if(FD_ISSET(i, &rfd))
+				fprint(2, " r%d", i);
+			if(FD_ISSET(i, &wfd))
+				fprint(2, " w%d", i);
+			if(FD_ISSET(i, &efd))
+				fprint(2, " e%d", i);
+		}
+		fprint(2, "; tp=%p, t=%d.%d\n", tvp, tv.tv_sec, tv.tv_usec);
+	}
 
+	n = select(maxfd+1, &rfd, &wfd, &efd, tvp);
+
+	if(n <= 0)
+		return n;
+
+	for(i=0; i<np; i++){
+		if(p[i].fd == -1)
+			continue;
+		if(FD_ISSET(p[i].fd, &rfd))
+			p[i].revents |= POLLIN;
+		if(FD_ISSET(p[i].fd, &wfd))
+			p[i].revents |= POLLOUT;
+		if(FD_ISSET(p[i].fd, &efd))
+			p[i].revents |= POLLERR;
+	} 
+	return n;
+}
+
+#else
+#include <poll.h>
+#endif
+
 /*
  * Poll file descriptors in an idle loop.
  */
@@ -34,21 +111,22 @@ pollidle(void *v)
 	uint now;
 
 	for(;; yield()){
-		//fprint(2, "poll %d:", npoll);
+		if(debugpoll) fprint(2, "poll %d:", npoll);
 		for(i=0; i<npoll; i++){
-			//fprint(2, " %d%c", pfd[i].fd, pfd[i].events==POLLIN ? 'r' : 'w');
+			if(debugpoll) fprint(2, " %d%c", pfd[i].fd, pfd[i].events==POLLIN ? 'r' : 'w');
 			pfd[i].revents = 0;
 		}
 		t = -1;
+		now = p9nsec()/1000000;
 		for(i=0; i<nsleep; i++){
-			now = p9nsec()/1000000;
 			n = sleeptime[i] - now;
+			if(debugpoll) fprint(2, " s%d", n);
 			if(n < 0)
 				n = 0;
 			if(t == -1 || n < t)
 				t = n;
 		}
-		//fprint(2, "\n");
+		if(debugpoll) fprint(2, "; t=%d\n", t);
 	
 		n = poll(pfd, npoll, t);
 		//fprint(2, "poll ret %d:", n);