diff --git a/src/Cldeetr.c b/src/Cldeetr.c index ceea1cf..9794c0f 100644 --- a/src/Cldeetr.c +++ b/src/Cldeetr.c @@ -50,7 +50,6 @@ int main(int argc, char *argv[]) { char Earg[30], Ename[30], **newargv; int i; - int flags; /* Kickstart program for the Lisp Development Environment (LDE). Run this as setuid root to open the LDE ether socket. Passes all arguments through to LDE plus -E @@ -141,8 +140,7 @@ int main(int argc, char *argv[]) bcopy(if_data.ifc_req[0].ifr_addr.sa_data, ether_host, 6); strcpy(Ename, if_data.ifc_req[0].ifr_name); - flags = fcntl(ether_fd, F_GETFL, 0); - fcntl(ether_fd, F_SETFL, flags | FASYNC | FNDELAY); + fcntl(ether_fd, F_SETFL, fcntl(ether_fd, F_GETFL, 0) | O_ASYNC | O_NONBLOCK); #ifdef DEBUG printf("init_ether: **** Ethernet starts ****\n"); diff --git a/src/chardev.c b/src/chardev.c index bf57a6f..12ec448 100644 --- a/src/chardev.c +++ b/src/chardev.c @@ -84,7 +84,7 @@ LispPTR CHAR_openfile(LispPTR *args) Lisp_errno = (int *)(Addr68k_from_LADDR(args[2])); LispStringToCString(args[0], pathname, MAXPATHLEN); - flags = O_NDELAY; + flags = O_NONBLOCK; ERRSETJMP(NIL); /* TIMEOUT( rval=stat(pathname, &statbuf) ); if(rval == 0){ } */ @@ -103,7 +103,7 @@ LispPTR CHAR_openfile(LispPTR *args) } /* Prevent I/O requests from blocking -- make them error */ /* if no char is available, or there's no room in pipe. */ - fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | FNDELAY); + fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK); return (GetSmallp(fd)); #endif /* DOS */ diff --git a/src/ether.c b/src/ether.c index f212f91..a9515d1 100644 --- a/src/ether.c +++ b/src/ether.c @@ -779,7 +779,6 @@ void init_ether() { differences are in commented-out code below (not ifdefed because they're untested...) */ - int flags; struct strioctl si; unsigned long snaplen = 0; @@ -822,8 +821,7 @@ void init_ether() { return; } - flags = fcntl(ether_fd, F_GETFL, 0); - fcntl(ether_fd, F_SETFL, flags | O_NDELAY); + fcntl(ether_fd, F_SETFL, fcntl(ether_fd, F_GETFL, 0) | O_NONBLOCK); } else { I_Give_Up: @@ -858,7 +856,7 @@ void init_ether() { #else /* OS4 */ if (getuid() != geteuid()) { - if ((ether_fd = open("/dev/nit", O_RDWR | FASYNC)) >= 0) { + if ((ether_fd = open("/dev/nit", O_RDWR | O_ASYNC)) >= 0) { /* it's open, now query it and find out its name and address */ /* JRB - must document that LDE uses the first net board as found by SIOCGIFCONF (see if(4)). Maybe we need an option @@ -1020,7 +1018,7 @@ void init_ether() { #endif /* USE_DLPI */ #endif /* PKTFILTER -- jds 23 sep 96 unmatched if fix */ #ifndef PKTFILTER - if (fcntl(ether_fd, F_SETFL, fcntl(ether_fd, F_GETFL, 0) | FASYNC | FNDELAY) < 0) + if (fcntl(ether_fd, F_SETFL, fcntl(ether_fd, F_GETFL, 0) | O_ASYNC | O_NONBLOCK) < 0) perror("Ether setup SETFLAGS fcntl"); if (fcntl(ether_fd, F_SETOWN, getpid()) < 0) perror("Ether setup SETOWN"); #else /* PKTFILTER */ diff --git a/src/inet.c b/src/inet.c index 4b8c464..8d990ad 100644 --- a/src/inet.c +++ b/src/inet.c @@ -28,6 +28,11 @@ #include #endif /* DOS */ +#ifdef OS5 +/* Solaris doesn't define O_ASYNC, yet still defines FASYNC. */ +#define O_ASYNC FASYNC +#endif + #include "lispemul.h" #include "lispmap.h" #include "lsptypes.h" @@ -106,7 +111,7 @@ LispPTR subr_TCP_ops(int op, LispPTR nameConn, LispPTR proto, LispPTR length, Li addr_class = LispNumToCInt(nameConn); protocol = LispNumToCInt(proto); result = socket(addr_class, protocol, 0); - fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) | FNDELAY | FASYNC); + fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) | O_ASYNC | O_NONBLOCK); fcntl(result, F_SETOWN, getpid()); return (GetSmallp(result)); @@ -130,7 +135,7 @@ LispPTR subr_TCP_ops(int op, LispPTR nameConn, LispPTR proto, LispPTR length, Li perror("TCP connect"); return (NIL); } - fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) | FNDELAY); + fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) | O_NONBLOCK); fcntl(result, F_SETOWN, getpid()); return (GetSmallp(result)); @@ -203,7 +208,7 @@ LispPTR subr_TCP_ops(int op, LispPTR nameConn, LispPTR proto, LispPTR length, Li int oldmask = sigblock(sigmask(SIGIO)); #endif /* SYSVSIGNALS */ - fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) | FNDELAY | FASYNC); + fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) | O_ASYNC | O_NONBLOCK); fcntl(result, F_SETOWN, getpid()); if (listen(result, 5) == -1) { @@ -236,7 +241,7 @@ LispPTR subr_TCP_ops(int op, LispPTR nameConn, LispPTR proto, LispPTR length, Li if (errno != EWOULDBLOCK) perror("TCP Accept"); return (NIL); } - fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) | FNDELAY); + fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) | O_NONBLOCK); fcntl(result, F_SETOWN, getpid()); return (GetSmallp(result)); @@ -274,7 +279,7 @@ LispPTR subr_TCP_ops(int op, LispPTR nameConn, LispPTR proto, LispPTR length, Li close(result); return (NIL); } - fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) | FNDELAY | FASYNC); + fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) | O_ASYNC | O_NONBLOCK); fcntl(result, F_SETOWN, getpid()); FD_SET(result, &LispIOFds); /* so we get interrupts */ diff --git a/src/initdsp.c b/src/initdsp.c index 1a8c234..de0e39c 100644 --- a/src/initdsp.c +++ b/src/initdsp.c @@ -335,7 +335,7 @@ void init_display2(DLword *display_addr, int display_max) /* int_io_open(LispWindowFd); JDS 4/27/94 move to initkbd, to try preventing the * move-mouse-never-get-kbd bug */ #endif - fcntl(LispWindowFd, F_SETFL, fcntl(LispWindowFd, F_GETFL, 0) | FNDELAY); + fcntl(LispWindowFd, F_SETFL, fcntl(LispWindowFd, F_GETFL, 0) | O_NONBLOCK); } #endif /* SUNDISPLAY */ diff --git a/src/ldeether.c b/src/ldeether.c index a6c1f7f..16708d2 100644 --- a/src/ldeether.c +++ b/src/ldeether.c @@ -76,7 +76,6 @@ char filetorun[30] = "lde"; int main(int argc, char *argv[]) { char Earg[30], Ename[30], **newargv; int i; - int flags; #ifdef USE_DLPI static struct packetfilt pf = {0, 1, {ENF_PUSHZERO}}; struct strioctl si; @@ -129,8 +128,7 @@ int main(int argc, char *argv[]) { return (-1); } - flags = fcntl(ether_fd, F_GETFL, 0); - fcntl(ether_fd, F_SETFL, flags | O_NDELAY); + fcntl(ether_fd, F_SETFL, fcntl(ether_fd, F_GETFL, 0) | O_NONBLOCK); #else /* N O T D L P I C O D E */ @@ -210,8 +208,7 @@ int main(int argc, char *argv[]) { bcopy(if_data.ifc_req[0].ifr_addr.sa_data, ether_host, 6); strcpy(Ename, if_data.ifc_req[0].ifr_name); - flags = fcntl(ether_fd, F_GETFL, 0); - fcntl(ether_fd, F_SETFL, flags | FASYNC | FNDELAY); + fcntl(ether_fd, F_SETFL, fcntl(ether_fd, F_GETFL, 0) | O_ASYNC | O_NONBLOCK); #endif /* USE_DLPI */ #ifdef DEBUG diff --git a/src/ocr.c b/src/ocr.c index aa46662..cb24d7e 100644 --- a/src/ocr.c +++ b/src/ocr.c @@ -408,9 +408,9 @@ int doblock; if (flags < 0) return 0; if (doblock) { - flags &= ~FNDELAY; + flags &= ~O_NONBLOCK; } else { - flags |= FNDELAY; + flags |= O_NONBLOCK; } if (fcntl(fd, F_SETFL, flags) < 0) return 0; diff --git a/src/ocrproc.c b/src/ocrproc.c index 8a38b78..92ae002 100644 --- a/src/ocrproc.c +++ b/src/ocrproc.c @@ -317,7 +317,7 @@ static int ocr_init_sv() { perror("ocr_init_sv: fcntl"); return 0; } - flags &= ~FNDELAY; + flags &= ~O_NONBLOCK; if (fcntl(OCR_sv, F_SETFL, flags) < 0) { perror("ocr_init_sv: fcntl 2"); return 0; diff --git a/src/oether.c b/src/oether.c index 198f3d0..78cb83c 100644 --- a/src/oether.c +++ b/src/oether.c @@ -667,7 +667,7 @@ void init_ether() { #else /* OS4 */ if (getuid() != geteuid()) { - if ((ether_fd = open("/dev/nit", O_RDWR | FASYNC)) >= 0) { + if ((ether_fd = open("/dev/nit", O_RDWR | O_ASYNC)) >= 0) { /* it's open, now query it and find out its name and address */ /* JRB - must document that LDE uses the first net board as found by SIOCGIFCONF (see if(4)). Maybe we need an option @@ -808,7 +808,7 @@ if (ether_fd >= 0) { } #ifndef OS4 EtherReadFds |= (1 << ether_fd); - if (fcntl(ether_fd, F_SETFL, fcntl(ether_fd, F_GETFL, 0) | FASYNC | FNDELAY) < 0) + if (fcntl(ether_fd, F_SETFL, fcntl(ether_fd, F_GETFL, 0) | O_ASYNC | O_NONBLOCK) < 0) perror("Ether setup SETFLAGS fcntl"); if (fcntl(ether_fd, F_SETOWN, getpid()) < 0) perror("Ether setup SETOWN"); #else /* OS4 */ diff --git a/src/oldeether.c b/src/oldeether.c index 73fa7fb..b8b8d98 100644 --- a/src/oldeether.c +++ b/src/oldeether.c @@ -48,7 +48,6 @@ int main(int argc, char *argv[]) { char Earg[30], Ename[30], **newargv; int i; - int flags; /* Kickstart program for the Lisp Development Environment (LDE). Run this as setuid root to open the LDE ether socket. Passes all arguments through to LDE plus -E @@ -139,8 +138,7 @@ int main(int argc, char *argv[]) bcopy(if_data.ifc_req[0].ifr_addr.sa_data, ether_host, 6); strcpy(Ename, if_data.ifc_req[0].ifr_name); - flags = fcntl(ether_fd, F_GETFL, 0); - fcntl(ether_fd, F_SETFL, flags | FASYNC | FNDELAY); + fcntl(ether_fd, F_SETFL, fcntl(ether_fd, F_GETFL, 0) | O_ASYNC | O_NONBLOCK); #ifdef DEBUG printf("init_ether: **** Ethernet starts ****\n"); diff --git a/src/osmsg.c b/src/osmsg.c index 1e08801..d460683 100644 --- a/src/osmsg.c +++ b/src/osmsg.c @@ -85,7 +85,7 @@ void mess_init() { int ttyfd; int ptyfd, ptynum; char *ptyname, *ttyname; - int temp, flags; + int temp; int on = 1; ptyname = "/dev/ptypx"; @@ -148,8 +148,7 @@ gotpty: if ((log_id = open(logfile, (O_RDWR | O_CREAT), 0666)) < 0) return; #ifdef LOGINT LogFileFd = cons_pty; /* was kept as an fd_set, but doesn't need to be */ - flags = fcntl(cons_pty, F_GETFL, 0); - fcntl(cons_pty, F_SETFL, (flags | FASYNC | FNDELAY)); + fcntl(cons_pty, F_SETFL, fcntl(cons_pty, F_GETFL, 0) | O_ASYNC | O_NONBLOCK); if (fcntl(cons_pty, F_SETOWN, getpid()) == -1) { #ifdef DEBUG perror("fcntl F_SETOWN of log PTY"); diff --git a/src/testdsp.c b/src/testdsp.c index 85f6d5b..4942f0d 100644 --- a/src/testdsp.c +++ b/src/testdsp.c @@ -89,7 +89,7 @@ void init_display2(int display_addr, int display_max) #ifdef KBINT int_io_open(LispWindowFd); #endif - fcntl(LispWindowFd, F_SETFL, fcntl(LispWindowFd, F_GETFL, 0) | FNDELAY); + fcntl(LispWindowFd, F_SETFL, fcntl(LispWindowFd, F_GETFL, 0) | O_NONBLOCK); } DisplayRegion68k = (short *)display_addr; diff --git a/src/timer.c b/src/timer.c index bc9e1d5..ba11233 100644 --- a/src/timer.c +++ b/src/timer.c @@ -546,7 +546,7 @@ void int_io_open(int fd) perror("fcntl F_SETOWN ERROR"); #endif }; - if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | FASYNC) == -1) perror("fcntl F_SETFL error"); + if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_ASYNC) == -1) perror("fcntl F_SETFL error"); #endif } @@ -555,7 +555,7 @@ void int_io_close(int fd) #ifdef DOS /* Turn off signaller here */ #elif KBINT - fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~FASYNC); + fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~O_ASYNC); #endif } diff --git a/src/unixcomm.c b/src/unixcomm.c index 84a9234..fa63e58 100644 --- a/src/unixcomm.c +++ b/src/unixcomm.c @@ -309,7 +309,7 @@ int FindUnixPipes(void) { /* Find the first PTY pair that is not in use */ int FindAvailablePty(char *Master, char *Slave) { - int res, flags; + int res; char *let, *num; #ifdef OS5 @@ -335,10 +335,7 @@ int FindAvailablePty(char *Master, char *Slave) { #endif if (res != -1) { - flags = fcntl(res, F_GETFL, 0); - flags |= FNDELAY; - - fcntl(res, F_SETFL, flags); + fcntl(res, F_SETFL, fcntl(res, F_GETFL, 0) | O_NONBLOCK); return (res); } #ifndef FULLSLAVENAME @@ -403,7 +400,7 @@ LispPTR Unix_handlecomm(LispPTR *args) { case 0: /* Fork pipe process */ { char *UpPipeName, *DownPipeName, *PipeName; - int res, slot, PipeFD, sockFD; + int slot, PipeFD, sockFD; /* First create the socket */ struct sockaddr_un sock; @@ -450,9 +447,7 @@ LispPTR Unix_handlecomm(LispPTR *args) { if (unlink(PipeName) < 0) perror("Unlink"); return (NIL); } - res = fcntl(PipeFD, F_GETFL, 0); - res |= FNDELAY; - if (fcntl(PipeFD, F_SETFL, res) == -1) { + if (fcntl(PipeFD, F_SETFL, fcntl(PipeFD, F_GETFL, 0) | O_NONBLOCK) == -1) { perror("setting up fifo to nodelay"); return (NIL); } @@ -614,7 +609,7 @@ LispPTR Unix_handlecomm(LispPTR *args) { case 11: /* Fork PTY process */ { char MasterFD[20], SlavePTY[32]; - int Master, flags, slot; + int Master, slot; unsigned short len; Master = FindAvailablePty(MasterFD, SlavePTY); @@ -650,9 +645,7 @@ LispPTR Unix_handlecomm(LispPTR *args) { DBPRINT(("Pipe/fork result = %d.\n", d[3])); if (d[3] == 1) { /* Set up the IO not to block */ - flags = fcntl(Master, F_GETFL, 0); - flags |= FNDELAY; - fcntl(Master, F_SETFL, flags); + fcntl(Master, F_SETFL, fcntl(Master, F_GETFL, 0) | O_NONBLOCK); UJ[slot].type = UJSHELL; /* so we can find them */ UJ[slot].PID = (d[1] << 8) | d[2]; @@ -832,7 +825,7 @@ LispPTR Unix_handlecomm(LispPTR *args) { case 12: /* create Unix socket */ { - int flags, sockFD; + int sockFD; struct sockaddr_un sock; /* First open the socket */ @@ -861,9 +854,7 @@ LispPTR Unix_handlecomm(LispPTR *args) { DBPRINT(("Socket %d bound to name %s.\n", sockFD, shcom)); if (listen(sockFD, 1) < 0) perror("Listen"); /* Set up the IO not to block */ - flags = fcntl(sockFD, F_GETFL, 0); - flags |= FNDELAY; - fcntl(sockFD, F_SETFL, flags); + fcntl(sockFD, F_SETFL, fcntl(sockFD, F_GETFL, 0) | O_NONBLOCK); /* things seem sane, fill out the rest of the UJ slot and return */ UJ[sockFD].status = -1; diff --git a/src/unixfork.c b/src/unixfork.c index 2a7598c..f2bc54c 100644 --- a/src/unixfork.c +++ b/src/unixfork.c @@ -225,7 +225,7 @@ of the packet received except: int fork_Unix() { int LispToUnix[2], /* Incoming pipe from LISP */ UnixToLisp[2], /* Outgoing pipe to LISP */ - UnixPID, LispPipeIn, LispPipeOut, flags, slot; + UnixPID, LispPipeIn, LispPipeOut, slot; pid_t pid; char IOBuf[4]; @@ -292,9 +292,7 @@ int fork_Unix() { close(LispToUnix[1]); close(UnixToLisp[0]); - flags = fcntl(LispPipeIn, F_GETFL, 0); - flags &= (65535 - FNDELAY); - fcntl(LispPipeIn, F_SETFL, flags); + fcntl(LispPipeIn, F_SETFL, fcntl(LispPipeIn, F_GETFL, 0) & ~O_NONBLOCK); while (1) { ssize_t len; diff --git a/src/uraid.c b/src/uraid.c index 2c9aed9..c11a923 100644 --- a/src/uraid.c +++ b/src/uraid.c @@ -1185,7 +1185,7 @@ static int re_init_display(int lisp_display_addr, int display_max) } else { #ifdef KBINT int_io_open(LispWindowFd); - fcntl(LispWindowFd, F_SETFL, fcntl(LispWindowFd, F_GETFL, 0) | FNDELAY); + fcntl(LispWindowFd, F_SETFL, fcntl(LispWindowFd, F_GETFL, 0) | O_NONBLOCK); #ifdef FX_AR_124 /* For AR 124. Type4 driver bug?? by m.matsuda */ @@ -1297,7 +1297,7 @@ static int re_init_display(int lisp_display_addr, int display_max) } else { #ifdef KBINT int_io_open(LispWindowFd); - fcntl(LispWindowFd, F_SETFL, fcntl(LispWindowFd, F_GETFL, 0) | FNDELAY); + fcntl(LispWindowFd, F_SETFL, fcntl(LispWindowFd, F_GETFL, 0) | O_NONBLOCK); #endif }