2 * PROJECT C Library, X68000 PROGRAMMING INTERFACE DEFINITION
3 * --------------------------------------------------------------------
4 * This file is written by the Project C Library Group, and completely
5 * in public domain. You can freely use, copy, modify, and redistribute
6 * the whole contents, without this notice.
7 * --------------------------------------------------------------------
11 #ifndef __IOCS_INLINE__
12 #define __IOCS_INLINE__
13 #define __DOS_INLINE__
14 #define __DOS_DOSCALL__
24 #include <sys/types.h>
26 #include <sys/select.h>
27 #include <sys/xsocket.h>
29 #include <sys/xunistd.h>
32 #define XFD_ISSET(fd,fds) ((fds) && FD_ISSET ((fd), (fds)))
33 #define isreadable(mode) ((mode) == O_RDONLY || (mode) == O_RDWR)
34 #define iswritable(mode) ((mode) == O_WRONLY || (mode) == O_RDWR)
35 #ifndef _POSIX_FD_SETSIZE
36 #define _POSIX_FD_SETSIZE OPEN_MAX
41 select (int fds
, fd_set
*rfds
, fd_set
*wfds
, fd_set
*efds
, struct timeval
*timeout
)
43 fd_set oread
, owrite
, oexcept
;
47 if (fds
> _POSIX_FD_SETSIZE
)
62 ticks
= timeout
->tv_sec
* 100 + timeout
->tv_usec
/ 10000;
70 start
= _iocs_ontime ();
76 for (fd
= 0; fd
< fds
; fd
++)
80 if (_fddb
[fd
].inuse
== _FD_NOTUSED
)
83 accmode
= _fddb
[fd
].oflag
& O_ACCMODE
;
87 if (XFD_ISSET (fd
, rfds
) && isreadable (accmode
) && _dos_k_keysns ())
93 if (XFD_ISSET (fd
, wfds
) && iswritable (accmode
))
100 else if (_fddb
[fd
].sockno
>= 0)
102 if (XFD_ISSET (fd
, rfds
) && _socklen (_fddb
[fd
].sockno
, 0))
108 if (XFD_ISSET (fd
, wfds
) /* && _socklen (_fddb[fd].sockno, 1) == 0 */)
110 FD_SET (fd
, &owrite
);
117 if (XFD_ISSET (fd
, rfds
) && isreadable (accmode
) && _dos_ioctrlis (fd
))
123 if (XFD_ISSET (fd
, wfds
) && iswritable (accmode
) && _dos_ioctrlos (fd
))
125 FD_SET (fd
, &owrite
);
135 if ((rest
= (_iocs_ontime () - start
) % 8640000) < 0)
144 if ((left
= ticks
- rest
) < 0)
147 timeout
->tv_sec
= left
/ 100;
148 timeout
->tv_usec
= (left
% 100) * 10000;
161 if (ticks
>= 0 && rest
> ticks
)