home *** CD-ROM | disk | FTP | other *** search
- /*
- * select() emulation for MiNT. Written by Eric R. Smith and placed in the
- * public domain
- */
-
- #include <errno.h>
- #include "mintbind.h"
-
- struct timeval {
- long tv_sec;
- long tv_usec;
- };
-
- int
- select(junk, rfds, wfds, xfds, timeout)
- int junk;
- long rfds, wfds, xfds;
- struct timeval *timeout;
- {
- /* the only tricky part, really, is figuring out the timeout value.
- a null pointer means indefinite timeout, which is the same as a 0
- value under MiNT. A non-null pointer to a 0 valued struct means
- to poll; in MiNT we simulate this with a minimum timeout value.
- */
- unsigned short mtime;
- int rval;
-
- if (timeout) {
- mtime = timeout->tv_sec * 1000 + timeout->tv_usec/1000;
- if (mtime == 0) mtime = 1;
- }
- else
- mtime = 0;
-
- rval = Fselect(mtime, rfds, wfds, xfds);
- if (rval < 0) {
- errno = -rval;
- return -1;
- }
- return rval;
- }
-