made to work
This commit is contained in:
		
							parent
							
								
									d6c52e0fef
								
							
						
					
					
						commit
						5d861a3399
					
				
					 2 changed files with 33 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -116,6 +116,13 @@ static int timeout();
 | 
			
		|||
 | 
			
		||||
int chan_any(c) register chan *c;
 | 
			
		||||
{
 | 
			
		||||
#ifdef __BSD4_2
 | 
			
		||||
#include <fcntl.h>
 | 
			
		||||
#ifndef O_NDELAY
 | 
			
		||||
#define O_NDELAY FNDELAY
 | 
			
		||||
#endif
 | 
			
		||||
	int flags;
 | 
			
		||||
#endif
 | 
			
		||||
	switch (c->type) {
 | 
			
		||||
	case C_T_FILE:
 | 
			
		||||
		if ((c->f.flgs&C_F_READAHEAD)!=0)
 | 
			
		||||
| 
						 | 
				
			
			@ -132,6 +139,24 @@ int chan_any(c) register chan *c;
 | 
			
		|||
				deadlock=0;
 | 
			
		||||
					/* No deadlock while waiting for key */
 | 
			
		||||
 | 
			
		||||
				/* Unfortunately, the mechanism that was used
 | 
			
		||||
				   here does not work on all Unix systems.
 | 
			
		||||
				   On BSD 4.2 and newer, the "read" is 
 | 
			
		||||
				   automatically restarted. Therefore, on
 | 
			
		||||
				   these systems, we try it with non-blocking
 | 
			
		||||
				   reads
 | 
			
		||||
				*/
 | 
			
		||||
#ifdef __BSD4_2
 | 
			
		||||
				flags = fcntl(fileno(fp), F_GETFL, 0);
 | 
			
		||||
				fcntl(fileno(fp), F_SETFL, flags | O_NDELAY);
 | 
			
		||||
				errno = 0;
 | 
			
		||||
				ch = getc(fp);
 | 
			
		||||
				fcntl(fileno(fp), F_SETFL, flags);
 | 
			
		||||
				if (errno == EWOULDBLOCK) {
 | 
			
		||||
					clearerr(fp);
 | 
			
		||||
					return 0;
 | 
			
		||||
				}
 | 
			
		||||
#else
 | 
			
		||||
				signal(SIGALRM, timeout);
 | 
			
		||||
				alarm(1);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -141,8 +166,11 @@ int chan_any(c) register chan *c;
 | 
			
		|||
				signal(SIGALRM, SIG_IGN);
 | 
			
		||||
				alarm(0);
 | 
			
		||||
 | 
			
		||||
				if (errno==EINTR)
 | 
			
		||||
				if (errno==EINTR) {
 | 
			
		||||
					clearerr(fp);
 | 
			
		||||
					return 0;
 | 
			
		||||
				}
 | 
			
		||||
#endif
 | 
			
		||||
				else {
 | 
			
		||||
					if (!feof(fp)) {
 | 
			
		||||
						c->f.flgs|=C_F_READAHEAD;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,6 +12,7 @@
 | 
			
		|||
 | 
			
		||||
 exp $top_save
 | 
			
		||||
 pro $top_save, 0
 | 
			
		||||
 mes 11
 | 
			
		||||
 loe 0
 | 
			
		||||
 lae 4			; load line number and file name
 | 
			
		||||
 loi EM_PSIZE
 | 
			
		||||
| 
						 | 
				
			
			@ -37,11 +38,14 @@
 | 
			
		|||
 | 
			
		||||
 exp $top_load
 | 
			
		||||
 pro $top_load, 0
 | 
			
		||||
 mes 11
 | 
			
		||||
 lal 0
 | 
			
		||||
 loi EM_PSIZE
 | 
			
		||||
 dup EM_PSIZE
 | 
			
		||||
 loi EM_PSIZE
 | 
			
		||||
 sti EM_PSIZE		; copy pointer from argument 0 to new frame
 | 
			
		||||
 lal 0
 | 
			
		||||
 loi EM_PSIZE
 | 
			
		||||
 loi EM_PSIZE		; load indirect to
 | 
			
		||||
 str 1			; restore SP
 | 
			
		||||
 dup EM_PSIZE		; givesargument 0 again
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue