fd_set fix for PLACES
svn: r16301
This commit is contained in:
parent
ab894fbe18
commit
6a9deb3a85
|
@ -442,6 +442,7 @@ static Scheme_Env *place_instance_init_post_kernel() {
|
|||
scheme_init_stx_places();
|
||||
scheme_init_sema_places();
|
||||
scheme_init_gmp_places();
|
||||
scheme_alloc_global_fdset();
|
||||
|
||||
env = scheme_make_empty_env();
|
||||
scheme_set_param(scheme_current_config(), MZCONFIG_ENV, (Scheme_Object *)env);
|
||||
|
|
|
@ -59,7 +59,6 @@ static int mzerrno = 0;
|
|||
#else
|
||||
# include <errno.h>
|
||||
#endif
|
||||
#include "schfd.h"
|
||||
|
||||
#ifdef USE_UNIX_SOCKETS_TCP
|
||||
# include <netinet/in.h>
|
||||
|
@ -93,6 +92,8 @@ struct SOCKADDR_IN {
|
|||
extern int scheme_stupid_windows_machine;
|
||||
#endif
|
||||
|
||||
#include "schfd.h"
|
||||
|
||||
#define TCP_BUFFER_SIZE 4096
|
||||
|
||||
#ifdef USE_UNIX_SOCKETS_TCP
|
||||
|
@ -157,13 +158,19 @@ typedef struct Scheme_UDP {
|
|||
|
||||
#if defined(WINDOWS_PROCESSES) || defined(WINDOWS_FILE_HANDLES)
|
||||
# define DECL_OS_FDSET(n) fd_set n[1]
|
||||
# define INIT_DECL_OS_FDSET(n) /* empty */
|
||||
# define INIT_DECL_OS_FDSET(r, w, e) /* empty */
|
||||
# define INIT_DECL_OS_RD_FDSET(r) /* empty */
|
||||
# define INIT_DECL_OS_WR_FDSET(r) /* empty */
|
||||
# define INIT_DECL_OS_ER_FDSET(r) /* empty */
|
||||
# define MZ_OS_FD_ZERO(p) FD_ZERO(p)
|
||||
# define MZ_OS_FD_SET(n, p) FD_SET(n, p)
|
||||
# define MZ_OS_FD_CLR(n, p) FD_CLR(n, p)
|
||||
#else
|
||||
# define DECL_OS_FDSET(n) DECL_FDSET(n, 1)
|
||||
# define INIT_DECL_OS_FDSET(n) INIT_DECL_FDSET(n, 1)
|
||||
# define INIT_DECL_OS_FDSET(r, w, e) INIT_DECL_FDSET(r, w, e)
|
||||
# define INIT_DECL_OS_RD_FDSET(r) INIT_DECL_RD_FDSET(r)
|
||||
# define INIT_DECL_OS_WR_FDSET(r) INIT_DECL_WR_FDSET(r)
|
||||
# define INIT_DECL_OS_ER_FDSET(r) INIT_DECL_ER_FDSET(r)
|
||||
# define MZ_OS_FD_ZERO(p) MZ_FD_ZERO(p)
|
||||
# define MZ_OS_FD_SET(n, p) MZ_FD_SET(n, p)
|
||||
# define MZ_OS_FD_CLR(n, p) MZ_FD_CLR(n, p)
|
||||
|
@ -816,8 +823,8 @@ static int tcp_check_accept(Scheme_Object *_listener)
|
|||
struct timeval time = {0, 0};
|
||||
int sr, i;
|
||||
|
||||
INIT_DECL_OS_FDSET(readfds);
|
||||
INIT_DECL_OS_FDSET(exnfds);
|
||||
INIT_DECL_OS_RD_FDSET(readfds);
|
||||
INIT_DECL_OS_ER_FDSET(exnfds);
|
||||
|
||||
if (LISTENER_WAS_CLOSED(listener))
|
||||
return 1;
|
||||
|
@ -880,8 +887,8 @@ static int tcp_check_connect(Scheme_Object *connector_p)
|
|||
struct timeval time = {0, 0};
|
||||
int sr;
|
||||
|
||||
INIT_DECL_OS_FDSET(writefds);
|
||||
INIT_DECL_OS_FDSET(exnfds);
|
||||
INIT_DECL_OS_WR_FDSET(writefds);
|
||||
INIT_DECL_OS_ER_FDSET(exnfds);
|
||||
|
||||
s = *(tcp_t *)connector_p;
|
||||
|
||||
|
@ -935,8 +942,8 @@ static int tcp_check_write(Scheme_Object *port)
|
|||
struct timeval time = {0, 0};
|
||||
int sr;
|
||||
|
||||
INIT_DECL_OS_FDSET(writefds);
|
||||
INIT_DECL_OS_FDSET(exnfds);
|
||||
INIT_DECL_OS_WR_FDSET(writefds);
|
||||
INIT_DECL_OS_ER_FDSET(exnfds);
|
||||
|
||||
s = data->tcp;
|
||||
|
||||
|
@ -1034,8 +1041,8 @@ static int tcp_byte_ready (Scheme_Input_Port *port)
|
|||
DECL_OS_FDSET(exfds);
|
||||
struct timeval time = {0, 0};
|
||||
|
||||
INIT_DECL_OS_FDSET(readfds);
|
||||
INIT_DECL_OS_FDSET(exfds);
|
||||
INIT_DECL_OS_RD_FDSET(readfds);
|
||||
INIT_DECL_OS_ER_FDSET(exfds);
|
||||
#endif
|
||||
|
||||
if (port->closed)
|
||||
|
@ -2807,8 +2814,8 @@ static int udp_check_send(Scheme_Object *_udp)
|
|||
struct timeval time = {0, 0};
|
||||
int sr;
|
||||
|
||||
INIT_DECL_OS_FDSET(writefds);
|
||||
INIT_DECL_OS_FDSET(exnfds);
|
||||
INIT_DECL_OS_WR_FDSET(writefds);
|
||||
INIT_DECL_OS_ER_FDSET(exnfds);
|
||||
|
||||
MZ_OS_FD_ZERO(writefds);
|
||||
MZ_OS_FD_SET(udp->s, writefds);
|
||||
|
@ -3039,8 +3046,8 @@ static int udp_check_recv(Scheme_Object *_udp)
|
|||
struct timeval time = {0, 0};
|
||||
int sr;
|
||||
|
||||
INIT_DECL_OS_FDSET(readfds);
|
||||
INIT_DECL_OS_FDSET(exnfds);
|
||||
INIT_DECL_OS_RD_FDSET(readfds);
|
||||
INIT_DECL_OS_ER_FDSET(exnfds);
|
||||
|
||||
MZ_OS_FD_ZERO(readfds);
|
||||
MZ_OS_FD_SET(udp->s, readfds);
|
||||
|
|
|
@ -77,7 +77,6 @@ static int mzerrno = 0;
|
|||
extern int osk_not_console; /* set by cmd-line flag */
|
||||
#endif
|
||||
#include <math.h> /* for fmod , used by default_sleep */
|
||||
#include "schfd.h"
|
||||
|
||||
#ifndef MZ_BINARY
|
||||
# define MZ_BINARY 0
|
||||
|
@ -115,6 +114,8 @@ static void init_thread_memory();
|
|||
# define OS_THREAD_TYPE HANDLE
|
||||
#endif
|
||||
|
||||
#include "schfd.h"
|
||||
|
||||
#ifdef WINDOWS_FILE_HANDLES
|
||||
|
||||
# define MZ_FDS
|
||||
|
@ -306,6 +307,8 @@ THREAD_LOCAL Scheme_Object *scheme_orig_stdout_port;
|
|||
THREAD_LOCAL Scheme_Object *scheme_orig_stderr_port;
|
||||
THREAD_LOCAL Scheme_Object *scheme_orig_stdin_port;
|
||||
|
||||
THREAD_LOCAL fd_set *scheme_fd_set;
|
||||
|
||||
Scheme_Object *(*scheme_make_stdin)(void) = NULL;
|
||||
Scheme_Object *(*scheme_make_stdout)(void) = NULL;
|
||||
Scheme_Object *(*scheme_make_stderr)(void) = NULL;
|
||||
|
@ -677,6 +680,13 @@ Scheme_Object * scheme_make_eof (void)
|
|||
Also implement special hooks for Windows "descriptors", like
|
||||
even queues and semaphores. */
|
||||
|
||||
void scheme_alloc_global_fdset() {
|
||||
#ifdef USE_FAR_MZ_FDCALLS
|
||||
REGISTER_SO(scheme_fd_set);
|
||||
scheme_fd_set = scheme_alloc_fdset_array(3, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef USE_DYNAMIC_FDSET_SIZE
|
||||
static int dynamic_fd_size;
|
||||
|
||||
|
@ -4925,8 +4935,8 @@ fd_byte_ready (Scheme_Input_Port *port)
|
|||
DECL_FDSET(exnfds, 1);
|
||||
struct timeval time = {0, 0};
|
||||
|
||||
INIT_DECL_FDSET(readfds, 1);
|
||||
INIT_DECL_FDSET(exnfds, 1);
|
||||
INIT_DECL_RD_FDSET(readfds);
|
||||
INIT_DECL_ER_FDSET(exnfds);
|
||||
|
||||
MZ_FD_ZERO(readfds);
|
||||
MZ_FD_ZERO(exnfds);
|
||||
|
@ -5938,8 +5948,8 @@ fd_write_ready (Scheme_Object *port)
|
|||
struct timeval time = {0, 0};
|
||||
int sr;
|
||||
|
||||
INIT_DECL_FDSET(writefds, 1);
|
||||
INIT_DECL_FDSET(exnfds, 1);
|
||||
INIT_DECL_WR_FDSET(writefds);
|
||||
INIT_DECL_ER_FDSET(exnfds);
|
||||
|
||||
MZ_FD_ZERO(writefds);
|
||||
MZ_FD_ZERO(exnfds);
|
||||
|
@ -8147,7 +8157,7 @@ static void default_sleep(float v, void *fds)
|
|||
if (external_event_fd) {
|
||||
DECL_FDSET(readfds, 1);
|
||||
|
||||
INIT_DECL_FDSET(readfds, 1);
|
||||
INIT_DECL_RD_FDSET(readfds);
|
||||
|
||||
MZ_FD_ZERO(readfds);
|
||||
MZ_FD_SET(external_event_fd, readfds);
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
|
||||
#ifdef USE_FAR_MZ_FDCALLS
|
||||
# define DECL_FDSET(n, c) static fd_set *n
|
||||
# define INIT_DECL_FDSET(n, c) (n = (n ? (fd_set *)scheme_init_fdset_array(n, c) : (fd_set *)scheme_alloc_fdset_array(c, 1)))
|
||||
extern THREAD_LOCAL fd_set *scheme_fd_set;
|
||||
# define DECL_FDSET(n, c) fd_set *n
|
||||
# define INIT_DECL_FDSET(r, w, e) { \
|
||||
r = MZ_GET_FDSET(scheme_fd_set, 0 ); \
|
||||
w = MZ_GET_FDSET(scheme_fd_set, 1 ); \
|
||||
e = MZ_GET_FDSET(scheme_fd_set, 2 ); \
|
||||
}
|
||||
# define INIT_DECL_RD_FDSET(r) r = MZ_GET_FDSET(scheme_fd_set, 0 )
|
||||
# define INIT_DECL_WR_FDSET(r) r = MZ_GET_FDSET(scheme_fd_set, 1 )
|
||||
# define INIT_DECL_ER_FDSET(r) r = MZ_GET_FDSET(scheme_fd_set, 2 )
|
||||
#else
|
||||
# define DECL_FDSET(n, c) fd_set n[c]
|
||||
# define INIT_DECL_FDSET(n, c) /* empty */
|
||||
# define INIT_DECL_FDSET(r, w, e) /* empty */
|
||||
# define INIT_DECL_RD_FDSET(r) /* empty */
|
||||
# define INIT_DECL_WR_FDSET(r) /* empty */
|
||||
# define INIT_DECL_ER_FDSET(r) /* empty */
|
||||
#endif
|
||||
|
|
|
@ -3119,6 +3119,7 @@ int scheme_is_user_port(Scheme_Object *port);
|
|||
int scheme_byte_ready_or_user_port_ready(Scheme_Object *p, Scheme_Schedule_Info *sinfo);
|
||||
|
||||
int scheme_pipe_char_count(Scheme_Object *p);
|
||||
void scheme_alloc_global_fdset();
|
||||
|
||||
#define CURRENT_INPUT_PORT(config) scheme_get_param(config, MZCONFIG_INPUT_PORT)
|
||||
#define CURRENT_OUTPUT_PORT(config) scheme_get_param(config, MZCONFIG_OUTPUT_PORT)
|
||||
|
|
|
@ -3531,7 +3531,7 @@ static int check_sleep(int need_activity, int sleep_now)
|
|||
scheme_notify_multithread(0);
|
||||
|
||||
#if defined(USING_FDS)
|
||||
INIT_DECL_FDSET(set, 3);
|
||||
INIT_DECL_FDSET(set, set1, set2);
|
||||
set1 = (fd_set *) MZ_GET_FDSET(set, 1);
|
||||
set2 = (fd_set *) MZ_GET_FDSET(set, 2);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user