mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-12 00:30:20 +02:00
Default to using poll(2) in `fport_input_waiting'.
* libguile/fports.c (fport_input_waiting): Use poll(2) instead of select(2) when possible. Cosmetic changes by Ludovic Courtès. * configure.in: Look for <poll.h> and `poll'.
This commit is contained in:
parent
99c6be814f
commit
c27411f180
2 changed files with 21 additions and 5 deletions
|
@ -4,7 +4,8 @@ dnl
|
||||||
|
|
||||||
define(GUILE_CONFIGURE_COPYRIGHT,[[
|
define(GUILE_CONFIGURE_COPYRIGHT,[[
|
||||||
|
|
||||||
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
|
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
||||||
|
2006, 2007, 2008, 2009, 2011 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of GUILE
|
This file is part of GUILE
|
||||||
|
|
||||||
|
@ -661,7 +662,7 @@ AC_CHECK_HEADERS([complex.h fenv.h io.h libc.h limits.h malloc.h memory.h proces
|
||||||
regex.h rxposix.h rx/rxposix.h sys/dir.h sys/ioctl.h sys/select.h \
|
regex.h rxposix.h rx/rxposix.h sys/dir.h sys/ioctl.h sys/select.h \
|
||||||
sys/time.h sys/timeb.h sys/times.h sys/stdtypes.h sys/types.h \
|
sys/time.h sys/timeb.h sys/times.h sys/stdtypes.h sys/types.h \
|
||||||
sys/utime.h time.h unistd.h utime.h pwd.h grp.h sys/utsname.h \
|
sys/utime.h time.h unistd.h utime.h pwd.h grp.h sys/utsname.h \
|
||||||
direct.h strings.h machine/fpu.h])
|
direct.h strings.h machine/fpu.h poll.h])
|
||||||
|
|
||||||
# "complex double" is new in C99, and "complex" is only a keyword if
|
# "complex double" is new in C99, and "complex" is only a keyword if
|
||||||
# <complex.h> is included
|
# <complex.h> is included
|
||||||
|
@ -755,7 +756,7 @@ AC_CHECK_HEADERS([assert.h crt_externs.h])
|
||||||
# isblank - available as a GNU extension or in C99
|
# isblank - available as a GNU extension or in C99
|
||||||
# _NSGetEnviron - Darwin specific
|
# _NSGetEnviron - Darwin specific
|
||||||
#
|
#
|
||||||
AC_CHECK_FUNCS([DINFINITY DQNAN cexp chsize clog clog10 ctermid fesetround ftime ftruncate fchown getcwd geteuid gettimeofday gmtime_r ioctl lstat mkdir mknod nice pipe _pipe readdir_r readdir64_r readlink rename rmdir select setegid seteuid setlocale setpgid setsid sigaction siginterrupt stat64 strftime strptime symlink sync sysconf tcgetpgrp tcsetpgrp times uname waitpid strdup system usleep atexit on_exit chown link fcntl ttyname getpwent getgrent kill getppid getpgrp fork setitimer getitimer strchr strcmp index bcopy memcpy rindex truncate unsetenv isblank _NSGetEnviron strncasecmp])
|
AC_CHECK_FUNCS([DINFINITY DQNAN cexp chsize clog clog10 ctermid fesetround ftime ftruncate fchown getcwd geteuid gettimeofday gmtime_r ioctl lstat mkdir mknod nice pipe _pipe readdir_r readdir64_r readlink rename rmdir select setegid seteuid setlocale setpgid setsid sigaction siginterrupt stat64 strftime strptime symlink sync sysconf tcgetpgrp tcsetpgrp times uname waitpid strdup system usleep atexit on_exit chown link fcntl ttyname getpwent getgrent kill getppid getpgrp fork setitimer getitimer strchr strcmp index bcopy memcpy rindex truncate unsetenv isblank _NSGetEnviron strncasecmp poll])
|
||||||
|
|
||||||
# Reasons for testing:
|
# Reasons for testing:
|
||||||
# netdb.h - not in mingw
|
# netdb.h - not in mingw
|
||||||
|
|
|
@ -46,7 +46,9 @@
|
||||||
#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
|
#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_POLL_H
|
||||||
|
#include <poll.h>
|
||||||
|
#endif
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
@ -485,8 +487,21 @@ scm_fdes_to_port (int fdes, char *mode, SCM name)
|
||||||
static int
|
static int
|
||||||
fport_input_waiting (SCM port)
|
fport_input_waiting (SCM port)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SELECT
|
|
||||||
int fdes = SCM_FSTREAM (port)->fdes;
|
int fdes = SCM_FSTREAM (port)->fdes;
|
||||||
|
|
||||||
|
/* `FD_SETSIZE', which is 1024 on GNU systems, effectively limits the
|
||||||
|
highest numerical value of file descriptors that can be monitored.
|
||||||
|
Thus, use poll(2) whenever that is possible. */
|
||||||
|
|
||||||
|
#ifdef HAVE_POLL
|
||||||
|
struct pollfd pollfd = { fdes, POLLIN, 0 };
|
||||||
|
|
||||||
|
if (poll (&pollfd, 1, 0) < 0)
|
||||||
|
scm_syserror ("fport_input_waiting");
|
||||||
|
|
||||||
|
return pollfd.revents & POLLIN ? 1 : 0;
|
||||||
|
|
||||||
|
#elif defined(HAVE_SELECT)
|
||||||
struct timeval timeout;
|
struct timeval timeout;
|
||||||
SELECT_TYPE read_set;
|
SELECT_TYPE read_set;
|
||||||
SELECT_TYPE write_set;
|
SELECT_TYPE write_set;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue