rktio: repairs for dynamic fd_set support
This commit is contained in:
parent
72b0351331
commit
9461c0e72a
18
racket/src/rktio/README.txt
Normal file
18
racket/src/rktio/README.txt
Normal file
|
@ -0,0 +1,18 @@
|
|||
The "rktio" library (for "Racket I/O") is a layer just above the OS
|
||||
layer to provide a portable interface to filesystem, networking, etc.
|
||||
facilities.
|
||||
|
||||
The library is meant to be
|
||||
|
||||
* easily embeddable;
|
||||
|
||||
* always non-blocking;
|
||||
|
||||
* independent of global state (except on Windows, where internal
|
||||
global state is managed appropriately with locks), so that it works
|
||||
with or without threads; and
|
||||
|
||||
* easily callable though a FFI.
|
||||
|
||||
Many such libraries exist already. This one happens to have exactly
|
||||
the things that a Racket implementation needs.
|
|
@ -824,12 +824,20 @@ int rktio_get_fd_limit(rktio_poll_set_t *fds)
|
|||
int actual_limit;
|
||||
|
||||
# ifdef STORED_ACTUAL_FDSET_LIMIT
|
||||
actual_limit = FDSET_LIMIT(rd);
|
||||
if (FDSET_LIMIT(wr) > actual_limit)
|
||||
actual_limit = FDSET_LIMIT(wr);
|
||||
if (FDSET_LIMIT(ex) > actual_limit)
|
||||
actual_limit = FDSET_LIMIT(ex);
|
||||
actual_limit++;
|
||||
{
|
||||
fd_set *rd, *wr, *ex;
|
||||
|
||||
rd = RKTIO_FDS(fds);
|
||||
wr = RKTIO_FDS(RKTIO_GET_FDSET(fds, 1));
|
||||
ex = RKTIO_FDS(RKTIO_GET_FDSET(fds, 2));
|
||||
|
||||
actual_limit = FDSET_LIMIT(rd);
|
||||
if (FDSET_LIMIT(wr) > actual_limit)
|
||||
actual_limit = FDSET_LIMIT(wr);
|
||||
if (FDSET_LIMIT(ex) > actual_limit)
|
||||
actual_limit = FDSET_LIMIT(ex);
|
||||
actual_limit++;
|
||||
}
|
||||
# elif defined (USE_ULIMIT)
|
||||
actual_limit = ulimit(4, 0);
|
||||
#elif defined(FIXED_FD_LIMIT)
|
||||
|
|
|
@ -16,6 +16,13 @@
|
|||
# include <pthread.h>
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) || defined(OS_X) || defined(__NetBSD__) \
|
||||
|| defined(__NetBSD__) || defined(__OpenBSD__) \
|
||||
|| defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
|
||||
|| defined(__DragonFly__) || defined(__QNX__)
|
||||
# define USE_DYNAMIC_FDSET_SIZE
|
||||
#endif
|
||||
|
||||
#if RKTIO_SYSTEM_WINDOWS
|
||||
# define USE_FAR_RKTIO_FDCALLS
|
||||
#endif
|
||||
|
@ -85,7 +92,7 @@ void rktio_fdset(rktio_poll_set_t *fd, int n);
|
|||
void rktio_fdclr(rktio_poll_set_t *fd, int n);
|
||||
int rktio_fdisset(rktio_poll_set_t *fd, int n);
|
||||
|
||||
# define DECL_FDSET(n, c) fd_set *n
|
||||
# define DECL_FDSET(n, c) rktio_poll_set_t *n
|
||||
# define INIT_DECL_FDSET(r, w, e) { \
|
||||
r = RKTIO_GET_FDSET(rktio->rktio_global_poll_set, 0 ); \
|
||||
w = RKTIO_GET_FDSET(rktio->rktio_global_poll_set, 1 ); \
|
||||
|
@ -102,7 +109,7 @@ int rktio_fdisset(rktio_poll_set_t *fd, int n);
|
|||
# define RKTIO_FD_ISSET(n, p) rktio_fdisset(p, n)
|
||||
|
||||
# if !defined(HAVE_POLL_SYSCALL) && !defined(RKTIO_SYSTEM_WINDOWS)
|
||||
# define RKTIO_FDS(p) ((fd_set *)fds)
|
||||
# define RKTIO_FDS(p) ((fd_set *)p)
|
||||
# endif
|
||||
|
||||
#else
|
||||
|
|
Loading…
Reference in New Issue
Block a user