1 /* 2 * reimplementation of Daniel Bernstein's unix library. 3 * placed in the public domain by Uwe Ohse, uwe@ohse.de. 4 */ 5 #include <sys/types.h> 6 #include <fcntl.h> 7 #include "ndelay.h" 8 9 /* love portability */ 10 #ifndef O_NONBLOCK 11 #define O_NONBLOCK O_NDELAY 12 #endif 13 14 int ndelay_on(int fd)15ndelay_on(int fd) 16 { 17 int st; 18 st=fcntl(fd,F_GETFL); 19 if (st==-1) 20 return -1; 21 if (st & O_NONBLOCK) 22 return 0; 23 return fcntl(fd,F_SETFL, st | O_NONBLOCK); 24 } 25