1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-30 06:50:31 +02:00

don't provide scm_std_select on mingw and similar platforms

* libguile/iselect.h: If we do not have sys/select.h, don't provide
  scm_std_select, SELECT_TYPE, FD_SET, FD_ZERO, FD_ISSET, or FD_CLR.
  Guile should not be setting these macros in public API.  This is an
  incompatible change on mingw, but oh well.

* libguile/threads.c: Rely on gnulib's select, and use that to implement
  scm_std_select.

* libguile/deprecated.h:
* libguile/deprecated.c: Only provide scm_internal_select if we have
  sys/select.h.
This commit is contained in:
Andy Wingo 2013-03-09 22:45:33 +01:00
parent d3c88f1826
commit 6ab4de6125
4 changed files with 41 additions and 43 deletions

View file

@ -24,6 +24,12 @@
# include <config.h> # include <config.h>
#endif #endif
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <arpa/inet.h>
#define SCM_BUILDING_DEPRECATED_CODE #define SCM_BUILDING_DEPRECATED_CODE
#include "libguile/_scm.h" #include "libguile/_scm.h"
@ -60,11 +66,6 @@
#include "libguile/feature.h" #include "libguile/feature.h"
#include "libguile/uniform.h" #include "libguile/uniform.h"
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <arpa/inet.h>
#if (SCM_ENABLE_DEPRECATED == 1) #if (SCM_ENABLE_DEPRECATED == 1)
@ -2356,16 +2357,18 @@ scm_thread_usleep (unsigned long t)
return scm_std_usleep (t); return scm_std_usleep (t);
} }
#ifdef HAVE_SYS_SELECT_H
int scm_internal_select (int fds, int scm_internal_select (int fds,
SELECT_TYPE *rfds, fd_set *rfds,
SELECT_TYPE *wfds, fd_set *wfds,
SELECT_TYPE *efds, fd_set *efds,
struct timeval *timeout) struct timeval *timeout)
{ {
scm_c_issue_deprecation_warning scm_c_issue_deprecation_warning
("`scm_internal_select' is deprecated. Use scm_std_select instead."); ("`scm_internal_select' is deprecated. Use scm_std_select instead.");
return scm_std_select (fds, rfds, wfds, efds, timeout); return scm_std_select (fds, rfds, wfds, efds, timeout);
} }
#endif /* HAVE_SYS_SELECT_H */

View file

@ -742,11 +742,13 @@ SCM_DEPRECATED SCM scm_c_make_keyword (const char *s);
SCM_DEPRECATED unsigned int scm_thread_sleep (unsigned int); SCM_DEPRECATED unsigned int scm_thread_sleep (unsigned int);
SCM_DEPRECATED unsigned long scm_thread_usleep (unsigned long); SCM_DEPRECATED unsigned long scm_thread_usleep (unsigned long);
#if SCM_HAVE_SYS_SELECT_H
SCM_DEPRECATED int scm_internal_select (int fds, SCM_DEPRECATED int scm_internal_select (int fds,
SELECT_TYPE *rfds, fd_set *rfds,
SELECT_TYPE *wfds, fd_set *wfds,
SELECT_TYPE *efds, fd_set *efds,
struct timeval *timeout); struct timeval *timeout);
#endif
/* Deprecated because the cuserid call is deprecated. /* Deprecated because the cuserid call is deprecated.
*/ */

View file

@ -3,7 +3,7 @@
#ifndef SCM_ISELECT_H #ifndef SCM_ISELECT_H
#define SCM_ISELECT_H #define SCM_ISELECT_H
/* Copyright (C) 1997,1998,2000,2001, 2002, 2006 Free Software Foundation, Inc. /* Copyright (C) 1997,1998,2000,2001, 2002, 2006, 2013 Free Software Foundation, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
@ -29,36 +29,19 @@
#include <sys/types.h> #include <sys/types.h>
#if SCM_HAVE_SYS_SELECT_H #if SCM_HAVE_SYS_SELECT_H
# include <sys/select.h>
#endif
#if SCM_HAVE_WINSOCK2_H #include <sys/select.h>
# include <winsock2.h>
#endif
#ifdef FD_SET
#define SELECT_TYPE fd_set
#define SELECT_SET_SIZE FD_SETSIZE
#else /* no FD_SET */
/* Define the macros to access a single-int bitmap of descriptors. */
#define SELECT_SET_SIZE 32
#define SELECT_TYPE int
#define FD_SET(n, p) (*(p) |= (1 << (n)))
#define FD_CLR(n, p) (*(p) &= ~(1 << (n)))
#define FD_ISSET(n, p) (*(p) & (1 << (n)))
#define FD_ZERO(p) (*(p) = 0)
#endif /* no FD_SET */
SCM_API int scm_std_select (int fds, SCM_API int scm_std_select (int fds,
SELECT_TYPE *rfds, fd_set *rfds,
SELECT_TYPE *wfds, fd_set *wfds,
SELECT_TYPE *efds, fd_set *efds,
struct timeval *timeout); struct timeval *timeout);
#define SELECT_TYPE fd_set
#endif /* SCM_HAVE_SYS_SELECT_H */
#endif /* SCM_ISELECT_H */ #endif /* SCM_ISELECT_H */
/* /*

View file

@ -45,6 +45,8 @@
# include <pthread_np.h> # include <pthread_np.h>
#endif #endif
#include <sys/select.h>
#include <assert.h> #include <assert.h>
#include <fcntl.h> #include <fcntl.h>
#include <nproc.h> #include <nproc.h>
@ -1851,9 +1853,9 @@ SCM_DEFINE (scm_condition_variable_p, "condition-variable?", 1, 0, 0,
struct select_args struct select_args
{ {
int nfds; int nfds;
SELECT_TYPE *read_fds; fd_set *read_fds;
SELECT_TYPE *write_fds; fd_set *write_fds;
SELECT_TYPE *except_fds; fd_set *except_fds;
struct timeval *timeout; struct timeval *timeout;
int result; int result;
@ -1876,11 +1878,19 @@ do_std_select (void *args)
return NULL; return NULL;
} }
#if !SCM_HAVE_SYS_SELECT_H
static int scm_std_select (int nfds,
fd_set *readfds,
fd_set *writefds,
fd_set *exceptfds,
struct timeval *timeout);
#endif
int int
scm_std_select (int nfds, scm_std_select (int nfds,
SELECT_TYPE *readfds, fd_set *readfds,
SELECT_TYPE *writefds, fd_set *writefds,
SELECT_TYPE *exceptfds, fd_set *exceptfds,
struct timeval *timeout) struct timeval *timeout)
{ {
fd_set my_readfds; fd_set my_readfds;