diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2012-10-04 00:15:42 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2012-10-04 00:15:42 -0700 |
commit | bb1dfdadd507bb4b77595c87875ef807c101ed7b (patch) | |
tree | eb92a2335896c34e76a9e19362049396b8d0483f /lib | |
parent | 88d69b7ddca305bb96d6e671300f6724e4f147dd (diff) | |
download | emacs-bb1dfdadd507bb4b77595c87875ef807c101ed7b.tar.gz |
Merge from gnulib.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gnulib.mk | 1 | ||||
-rw-r--r-- | lib/pselect.c | 34 | ||||
-rw-r--r-- | lib/stdlib.in.h | 13 |
3 files changed, 46 insertions, 2 deletions
diff --git a/lib/gnulib.mk b/lib/gnulib.mk index e79fe35622c..23749331a83 100644 --- a/lib/gnulib.mk +++ b/lib/gnulib.mk @@ -857,6 +857,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ -e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \ -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \ -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \ + -e 's|@''REPLACE_PTSNAME''@|$(REPLACE_PTSNAME)|g' \ -e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \ -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \ -e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \ diff --git a/lib/pselect.c b/lib/pselect.c index d8ebc70f6c6..1b6d099dccf 100644 --- a/lib/pselect.c +++ b/lib/pselect.c @@ -33,6 +33,8 @@ pointer parameter stands for no descriptors, an infinite timeout, or an unaffected signal mask. */ +#if !HAVE_PSELECT + int pselect (int nfds, fd_set *restrict rfds, fd_set *restrict wfds, fd_set *restrict xfds, @@ -74,3 +76,35 @@ pselect (int nfds, fd_set *restrict rfds, return select_result; } + +#else /* HAVE_PSELECT */ +# include <unistd.h> +# undef pselect + +int +rpl_pselect (int nfds, fd_set *restrict rfds, + fd_set *restrict wfds, fd_set *restrict xfds, + struct timespec const *restrict timeout, + sigset_t const *restrict sigmask) +{ + int i; + + /* FreeBSD 8.2 has a bug: it does not always detect invalid fds. */ + if (nfds < 0 || nfds > FD_SETSIZE) + { + errno = EINVAL; + return -1; + } + for (i = 0; i < nfds; i++) + { + if (((rfds && FD_ISSET (i, rfds)) + || (wfds && FD_ISSET (i, wfds)) + || (xfds && FD_ISSET (i, xfds))) + && dup2 (i, i) != i) + return -1; + } + + return pselect (nfds, rfds, wfds, xfds, timeout, sigmask); +} + +#endif diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index 1d67ec64c66..8311a2893c8 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -457,10 +457,19 @@ _GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - " #if @GNULIB_PTSNAME@ /* Return the pathname of the pseudo-terminal slave associated with the master FD is open on, or NULL on errors. */ -# if !@HAVE_PTSNAME@ +# if @REPLACE_PTSNAME@ +# if !(defined __cplusplus && defined GNULIB_NAMESPCE) +# undef ptsname +# define ptsname rpl_ptsname +# endif +_GL_FUNCDECL_RPL (ptsname, char *, (int fd)); +_GL_CXXALIAS_RPL (ptsname, char *, (int fd)); +# else +# if !@HAVE_PTSNAME@ _GL_FUNCDECL_SYS (ptsname, char *, (int fd)); -# endif +# endif _GL_CXXALIAS_SYS (ptsname, char *, (int fd)); +# endif _GL_CXXALIASWARN (ptsname); #elif defined GNULIB_POSIXCHECK # undef ptsname |