--- a/Unix.st Thu Nov 20 18:34:40 1997 +0100
+++ b/Unix.st Thu Nov 20 19:12:49 1997 +0100
@@ -400,6 +400,10 @@
# undef Point
# undef Rectangle
# undef Block
+# undef String
+# undef Message
+# undef Object
+# undef Context
/* # include <windows.h> /* */
# include <stdarg.h> /* */
@@ -407,6 +411,7 @@
# include <winbase.h> /* */
# include <wingdi.h> /* */
# include <winuser.h> /* */
+# include <winsock.h> /* */
# ifdef __DEF_Array
# define Array __DEF_Array
@@ -423,6 +428,19 @@
# ifdef __DEF_Block
# define Block __DEF_Block
# endif
+# ifdef __DEF_String
+# define String __DEF_String
+# endif
+# ifdef __DEF_Message
+# define Message __DEF_Message
+# endif
+# ifdef __DEF_Object
+# define Object __DEF_Object
+# endif
+# ifdef __DEF_Context
+# define Context __DEF_Context
+# endif
+
# define INT int
# define stat _stat
@@ -8487,15 +8505,19 @@
supportsSelect
"return true, if the OS supports selecting on multiple
- filedescriptors via select."
-
-%{ /* NOCONTEXT */
-#if defined(WIN32)
+ filedescriptors via select.
+ If false is returned, ProcessorScheduler will poll in 50ms
+ intervals for I/O becoming ready."
+
+%{ /* NOCONTEXT */
+#if defined(WIN32S)
RETURN (false);
#endif
+
#if defined(__VMS__)
RETURN (false); /* for now ... */
#endif
+
#if defined(sco)
/*
* sco has a select, but its broken: always waiting 1 second
@@ -9794,12 +9816,12 @@
/*
* if available, try FIONREAD first, which is usually done faster.
*/
-# ifdef FIONREAD
+# if defined(FIONREAD) && !defined(WIN32)
{
int n;
if (__isSmallInteger(fd)) {
- if (n = ioctl(__intVal(fd), FIONREAD) {
+ if (n = ioctl(__intVal(fd), FIONREAD)) {
printf("FIONREAD returns %d\n", n);
}
}
@@ -9919,7 +9941,7 @@
Return first ready fd if I/O ok, nil if timed-out or interrupted."
%{
-#ifdef MSDOS_LIKE
+#if defined(MSDOS_LIKE) && (defined(WIN32S) || !defined(WIN32))
/*
* support a delay-wait only
* (i.e. fail if any filedescriptor is selected upon)
@@ -9929,6 +9951,8 @@
int t;
OBJ fd;
+ @global(OperatingSystem:LastErrorNumber) = nil;
+
if (! __isSmallInteger(millis)) {
goto fail;
}
@@ -10005,6 +10029,7 @@
OBJ fd, retFd;
int ret;
int count;
+ int numFds = 0;
if (__isSmallInteger(millis)) {
FD_ZERO(&rset);
@@ -10025,6 +10050,7 @@
if ((unsigned)f < FD_SETSIZE) {
FD_SET(f, &rset);
if (f > maxF) maxF = f;
+ numFds++;
}
}
}
@@ -10042,6 +10068,7 @@
if ((unsigned)f < FD_SETSIZE) {
FD_SET(f, &wset);
if (f > maxF) maxF = f;
+ numFds++;
}
}
}
@@ -10059,6 +10086,7 @@
if ((unsigned)f < FD_SETSIZE) {
FD_SET(f, &eset);
if (f > maxF) maxF = f;
+ numFds++;
}
}
}
@@ -10084,11 +10112,37 @@
* interruptable.
*/
do {
+# ifdef WIN32
+ if (numFds == 0) {
+ HANDLE dummyHandle = (HANDLE)0;
+
+ if (! GetQueueStatus(QS_ALLINPUT)) {
+ MsgWaitForMultipleObjects(0, &dummyHandle, FALSE, t, QS_ALLINPUT);
+ }
+ ret = 0;
+ } else {
+ ret = select(0, &rset, &wset, &eset, &wt);
+ }
+# else
ret = select(maxF+1, &rset, &wset, &eset, &wt);
+# endif
} while ((ret < 0) && (errno == EINTR));
} else {
do {
+# ifdef WIN32
+ if (numFds == 0) {
+ HANDLE dummyHandle = (HANDLE)0;
+
+ if (! GetQueueStatus(QS_ALLINPUT)) {
+ MsgWaitForMultipleObjects(0, &dummyHandle, FALSE, t, QS_ALLINPUT);
+ }
+ ret = 0;
+ } else {
+ ret = select(0, &rset, &wset, &eset, &wt);
+ }
+# else
ret = select(maxF+1, &rset, &wset, &eset, &wt);
+# endif
/*
* for now: dont loop; if we did, we had to adjust the vt-timeval;
* could otherwise stay in this loop forever ...
@@ -10489,6 +10543,6 @@
!OperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Attic/Unix.st,v 1.266 1997-10-13 12:46:15 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Attic/Unix.st,v 1.267 1997-11-20 18:12:49 cg Exp $'
! !
OperatingSystem initialize!