aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/gnulib.mk1
-rw-r--r--lib/pselect.c34
-rw-r--r--lib/stdlib.in.h13
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) \
857 -e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \ 857 -e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \
858 -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \ 858 -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \
859 -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \ 859 -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
860 -e 's|@''REPLACE_PTSNAME''@|$(REPLACE_PTSNAME)|g' \
860 -e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \ 861 -e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \
861 -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \ 862 -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
862 -e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \ 863 -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 @@
33 pointer parameter stands for no descriptors, an infinite timeout, 33 pointer parameter stands for no descriptors, an infinite timeout,
34 or an unaffected signal mask. */ 34 or an unaffected signal mask. */
35 35
36#if !HAVE_PSELECT
37
36int 38int
37pselect (int nfds, fd_set *restrict rfds, 39pselect (int nfds, fd_set *restrict rfds,
38 fd_set *restrict wfds, fd_set *restrict xfds, 40 fd_set *restrict wfds, fd_set *restrict xfds,
@@ -74,3 +76,35 @@ pselect (int nfds, fd_set *restrict rfds,
74 76
75 return select_result; 77 return select_result;
76} 78}
79
80#else /* HAVE_PSELECT */
81# include <unistd.h>
82# undef pselect
83
84int
85rpl_pselect (int nfds, fd_set *restrict rfds,
86 fd_set *restrict wfds, fd_set *restrict xfds,
87 struct timespec const *restrict timeout,
88 sigset_t const *restrict sigmask)
89{
90 int i;
91
92 /* FreeBSD 8.2 has a bug: it does not always detect invalid fds. */
93 if (nfds < 0 || nfds > FD_SETSIZE)
94 {
95 errno = EINVAL;
96 return -1;
97 }
98 for (i = 0; i < nfds; i++)
99 {
100 if (((rfds && FD_ISSET (i, rfds))
101 || (wfds && FD_ISSET (i, wfds))
102 || (xfds && FD_ISSET (i, xfds)))
103 && dup2 (i, i) != i)
104 return -1;
105 }
106
107 return pselect (nfds, rfds, wfds, xfds, timeout, sigmask);
108}
109
110#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 - "
457#if @GNULIB_PTSNAME@ 457#if @GNULIB_PTSNAME@
458/* Return the pathname of the pseudo-terminal slave associated with 458/* Return the pathname of the pseudo-terminal slave associated with
459 the master FD is open on, or NULL on errors. */ 459 the master FD is open on, or NULL on errors. */
460# if !@HAVE_PTSNAME@ 460# if @REPLACE_PTSNAME@
461# if !(defined __cplusplus && defined GNULIB_NAMESPCE)
462# undef ptsname
463# define ptsname rpl_ptsname
464# endif
465_GL_FUNCDECL_RPL (ptsname, char *, (int fd));
466_GL_CXXALIAS_RPL (ptsname, char *, (int fd));
467# else
468# if !@HAVE_PTSNAME@
461_GL_FUNCDECL_SYS (ptsname, char *, (int fd)); 469_GL_FUNCDECL_SYS (ptsname, char *, (int fd));
462# endif 470# endif
463_GL_CXXALIAS_SYS (ptsname, char *, (int fd)); 471_GL_CXXALIAS_SYS (ptsname, char *, (int fd));
472# endif
464_GL_CXXALIASWARN (ptsname); 473_GL_CXXALIASWARN (ptsname);
465#elif defined GNULIB_POSIXCHECK 474#elif defined GNULIB_POSIXCHECK
466# undef ptsname 475# undef ptsname