--- a/Unix.st Thu Dec 14 18:49:59 1995 +0100
+++ b/Unix.st Thu Dec 14 20:19:39 1995 +0100
@@ -179,6 +179,10 @@
# include <sys/utsname.h>
# endif
+# if defined(SYSV4)
+# include <stropts.h>
+# endif
+
#endif /* ! transputer */
/*
@@ -3002,10 +3006,12 @@
int ret, flags, f;
-#if defined(F_GETFL) && defined(F_SETFL)
-# if defined(FASYNC)
+#if (defined(F_GETFL) && defined(F_SETFL) && defined(FASYNC)) || defined(SYSV4)
if (__isSmallInteger(fd)) {
f = _intVal(fd);
+# if defined(SYSV4)
+ ret = ioctl(f, I_SETSIG, 0);
+# else /*! SYSV4*/
flags = fcntl(f, F_GETFL, 0);
/*
* if already clear, there is no need for this syscall ...
@@ -3016,9 +3022,9 @@
} else {
ret = flags;
}
+# endif /* !SYSV4 */
RETURN ( _MKSMALLINT(ret) );
}
-# endif
#endif
%}.
"
@@ -3136,23 +3142,43 @@
extern void __signalIoInterrupt();
static int firstCall = 1;
-#if defined(F_GETFL) && defined(F_SETFL)
-# if defined(FASYNC)
+#if (defined(F_GETFL) && defined(F_SETFL) && defined(FASYNC)) || defined(SYSV4)
+/*
+ * SIGIO/SIGPOLL - data available for I/O
+ * (used to wake up waiting processes)
+ */
+#ifdef SIGIO
+# define THESIGNAL SIGIO
+#else
+# ifdef SIGPOLL
+# define THESIGNAL SIGPOLL
+# else
+# ifdef SIGURG
+# define THESIGNAL SIGURG
+# endif
+# endif
+#endif
+
if (__isSmallInteger(fd)) {
if (firstCall) {
+#ifdef HAS_SIGACTION
+ struct sigaction act;
+
+ act.sa_flags = SA_RESTART|SA_SIGINFO;
+ sigemptyset(&act.sa_mask);
+ act.sa_handler = __signalIoInterrupt;
+ sigaction(THESIGNAL, &act, 0);
+#else
+ signal(THESIGNAL, __signalIoInterrupt);
+#endif
firstCall = 0;
-# ifdef SIGIO
- signal(SIGIO, __signalIoInterrupt);
-# endif
-# ifdef SIGPOLL
- signal(SIGPOLL, __signalIoInterrupt);
-# endif
-# ifdef SIGURG
- signal(SIGURG, __signalIoInterrupt);
-# endif
}
+#undef THESIGNAL
f = _intVal(fd);
+# if defined(SYSV4)
+ ret = ioctl(f, I_SETSIG, S_INPUT | S_HIPRI | S_ERROR | S_RDNORM | S_RDBAND | S_MSG | S_HANGUP);
+# else /*! SYSV4*/
flags = fcntl(f, F_GETFL, 0);
/*
* if already set, there is no need for this syscall ...
@@ -3163,9 +3189,9 @@
ret = fcntl(f, F_SETFL, flags | FASYNC);
if (ret >= 0) ret = flags;
}
+# endif /*!SYSV4*/
RETURN ( _MKSMALLINT(ret) );
}
-# endif
#endif
%}.
"
@@ -3345,25 +3371,25 @@
%{ /* NOCONTEXT */
+#if defined(ITIMER_REAL)
extern void __signalTimerInterrupt();
-
-#if defined(ITIMER_REAL)
+ static int firstCall = 1;
+
struct itimerval dt;
-#if defined(HAS_SIGPROCMASK)
- {
- sigset_t sigmask;
-
- sigemptyset(&sigmask);
- sigprocmask(SIG_SETMASK, &sigmask, 0);
+ if (firstCall) {
+#ifdef HAS_SIGACTION
+ struct sigaction act;
+
+ act.sa_flags = SA_RESTART|SA_SIGINFO;
+ sigemptyset(&act.sa_mask);
+ act.sa_handler = __signalTimerInterrupt;
+ sigaction(SIGALRM, &act, 0);
+#else
+ signal(SIGALRM, __signalTimerInterrupt);
+#endif
+ firstCall = 0;
}
-#endif /* HAS_SIGPROCMASK */
-# ifndef xxxSYSV4
-# if defined(BSD) || defined(HAS_SIGSETMASK)
- sigsetmask(0);
-# endif
-# endif
- signal(SIGALRM, __signalTimerInterrupt);
dt.it_interval.tv_sec = 0;
dt.it_interval.tv_usec = 0;
@@ -3510,20 +3536,6 @@
#if defined(ITIMER_VIRTUAL)
struct itimerval dt;
-#if defined(HAS_SIGPROCMASK)
- {
- sigset_t sigmask;
-
- sigemptyset(&sigmask);
- sigprocmask(SIG_SETMASK, &sigmask, 0);
- }
-#endif /* HAS_SIGPROCMASK */
-# ifndef xxxSYSV4
-# if defined(BSD) || defined(HAS_SIGSETMASK)
- sigsetmask(0);
-# endif
-# endif
-
# ifdef SIGVTALRM
signal(SIGVTALRM, __spyInterrupt);
# else
@@ -4233,23 +4245,21 @@
"return true, if the OS supports IO availability interrupts
(i.e. SIGPOLL/SIGIO).
- Currently, this mechanism does not work at all ..."
+ Currently, this mechanism does work for SYSV4 only ..."
%{ /* NOCONTEXT */
-#ifdef NOTDEF
-
-# if defined(SIGPOLL) || defined(SIGIO)
-# if defined(F_GETFL) && defined(F_SETFL)
-# if defined(FASYNC)
- /*
- * mhmh they seem to NOT work on NS2.1
- */
-# if !defined(NEXT)
- RETURN (true);
-# endif
-# endif
-# endif
+#if defined(SYSV4)
+
+# if defined(SIGPOLL) || defined(SIGIO)
+# if (defined(F_GETFL) && defined(F_SETFL) && defined(FASYNC)) || defined(SYSV4)
+ /*
+ * mhmh they seem to NOT work on NS2.1
+ */
+# if !defined(NEXT)
+ RETURN (true);
# endif
+# endif
+# endif
#endif
%}
@@ -4261,11 +4271,9 @@
"return true, if the OS supports nonblocking IO."
%{ /* NOCONTEXT */
-# if defined(F_GETFL) && defined(F_SETFL)
-# if defined(FNDELAY)
+#if defined(F_GETFL) && defined(F_SETFL) && defined(FNDELAY)
RETURN (true);
-# endif
-# endif
+#endif
%}
.
^ false
@@ -5254,6 +5262,6 @@
!OperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Attic/Unix.st,v 1.86 1995-12-09 14:27:24 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Attic/Unix.st,v 1.87 1995-12-14 19:19:39 stefan Exp $'
! !
OperatingSystem initialize!