diff options
author | Ulrich Drepper <drepper@redhat.com> | 2006-01-20 07:08:05 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2006-01-20 07:08:05 +0000 |
commit | 7c65e9001b93d5d20046bc4d50fd10fff5f4adc2 (patch) | |
tree | 38f65e2a20910e6d074fbcec137eb66853e70eaa /io | |
parent | 93c04024a6b900b69bbe9a70de06ac23b8273787 (diff) | |
download | glibc-7c65e9001b93d5d20046bc4d50fd10fff5f4adc2.zip glibc-7c65e9001b93d5d20046bc4d50fd10fff5f4adc2.tar.gz glibc-7c65e9001b93d5d20046bc4d50fd10fff5f4adc2.tar.bz2 |
* include/fcntl.h: Declare __have_atfcts.
* sysdeps/unix/sysv/linux/faccessat.c: Use syscall if available.
* sysdeps/unix/sysv/linux/fchmodat.c: Likewise.
* sysdeps/unix/sysv/linux/fchownat.c: Likewise.
* sysdeps/unix/sysv/linux/futimesat.c: Likewise.
* sysdeps/unix/sysv/linux/linkat.c: Likewise.
* sysdeps/unix/sysv/linux/mkdirat.c: Likewise.
* sysdeps/unix/sysv/linux/openat.c: Likewise.
* sysdeps/unix/sysv/linux/readlinkat.c: Likewise.
* sysdeps/unix/sysv/linux/renameat.c: Likewise.
* sysdeps/unix/sysv/linux/symlinkat.c: Likewise.
* sysdeps/unix/sysv/linux/unlinkat.c: Likewise.
* sysdeps/unix/sysv/linux/xmknodat.c: Likewise.
* sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c: Likewise.
* sysdeps/unix/sysv/linux/kernel-features.h: Define __ASSUME_PSELECT,
__ASSUME_PPOLL, and __ASSUME_ATFCTS if possible.
* io/ppoll.c: New file.
* io/Makefile (routines): Add ppoll.
(CFLAGS-ppoll.c): Define.
* io/Versions: Export ppoll for GLIBC_2.4.
* io/sys/poll.h: Declare ppoll.
* sysdeps/unix/sysv/linux/ppoll.c: New file.
* misc/pselect.c: Make it possible to include this file to define
the generic code as a static function.
* sysdeps/unix/sysv/linux/pselect.c: New file.
Diffstat (limited to 'io')
-rw-r--r-- | io/Makefile | 3 | ||||
-rw-r--r-- | io/Versions | 2 | ||||
-rw-r--r-- | io/ppoll.c | 76 | ||||
-rw-r--r-- | io/sys/poll.h | 21 |
4 files changed, 100 insertions, 2 deletions
diff --git a/io/Makefile b/io/Makefile index 5e6d72e..e005cb3 100644 --- a/io/Makefile +++ b/io/Makefile @@ -48,7 +48,7 @@ routines := \ ttyname ttyname_r isatty \ link linkat symlink symlinkat readlink readlinkat \ unlink unlinkat rmdir \ - ftw ftw64 fts poll \ + ftw ftw64 fts poll ppoll \ posix_fadvise posix_fadvise64 \ posix_fallocate posix_fallocate64 \ sendfile sendfile64 @@ -72,6 +72,7 @@ include ../Rules CFLAGS-fcntl.c = -fexceptions -fasynchronous-unwind-tables CFLAGS-poll.c = -fexceptions -fasynchronous-unwind-tables +CFLAGS-ppoll.c = -fexceptions -fasynchronous-unwind-tables CFLAGS-lockf.c = -fexceptions CFLAGS-statfs.c = -fexceptions CFLAGS-fstatfs.c = -fexceptions diff --git a/io/Versions b/io/Versions index 16006a8..bc9c9d2 100644 --- a/io/Versions +++ b/io/Versions @@ -110,5 +110,7 @@ libc { readlinkat; symlinkat; unlinkat; + + ppoll; } } diff --git a/io/ppoll.c b/io/ppoll.c new file mode 100644 index 0000000..a035cfe --- /dev/null +++ b/io/ppoll.c @@ -0,0 +1,76 @@ +/* Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@redhat.com>, 2006. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <errno.h> +#include <limits.h> +#include <signal.h> +#include <stddef.h> /* For NULL. */ +#include <sys/poll.h> +#include <sysdep-cancel.h> + + +int +ppoll (struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, + const sigset_t *sigmask) +{ + int tval = -1; + + /* poll uses a simple millisecond value. Convert it. */ + if (timeout != NULL) + { + if (timeout->tv_sec < 0 + || timeout->tv_nsec < 0 || timeout->tv_nsec >= 1000000000) + { + __set_errno (EINVAL); + return -1; + } + + if (timeout->tv_sec > INT_MAX / 1000 + || (timeout->tv_sec == INT_MAX / 1000 + && ((timeout->tv_nsec + 999999) / 1000000 > INT_MAX % 1000))) + /* We cannot represent the timeout in an int value. Wait + forever. */ + tval = -1; + else + tval = (timeout->tv_sec * 1000 + + (timeout->tv_nsec + 999999) / 1000000); + } + + /* The setting and restoring of the signal mask and the select call + should be an atomic operation. This can't be done without kernel + help. */ + sigset_t savemask; + if (sigmask != NULL) + __sigprocmask (SIG_SETMASK, sigmask, &savemask); + + /* Note the ppoll() is a cancellation point. But since we call + poll() which itself is a cancellation point we do not have + to do anything here. */ + int retval = __poll (fds, nfds, tval); + + if (sigmask != NULL) + __sigprocmask (SIG_SETMASK, &savemask, NULL); + + return retval; +} + +#ifndef ppoll +/* __poll handles cancellation. */ +LIBC_CANCEL_HANDLED (); +#endif diff --git a/io/sys/poll.h b/io/sys/poll.h index 9cf1b9f..4085b78 100644 --- a/io/sys/poll.h +++ b/io/sys/poll.h @@ -1,5 +1,5 @@ /* Compatibility definitions for System V `poll' interface. - Copyright (C) 1994,1996-2001,2004,2005 Free Software Foundation, Inc. + Copyright (C) 1994,1996-2001,2004,2005,2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -24,6 +24,13 @@ /* Get the platform dependent bits of `poll'. */ #include <bits/poll.h> +#ifdef __USE_GNU +/* Get the __sigset_t definition. */ +# include <bits/sigset.h> +/* Get the timespec definition. */ +# define __need_timespec +# include <time.h> +#endif /* Type used for the number of file descriptors. */ @@ -50,6 +57,18 @@ __BEGIN_DECLS __THROW. */ extern int poll (struct pollfd *__fds, nfds_t __nfds, int __timeout); +#ifdef __USE_GNU +/* Like poll, but before waiting the threads signal mask is replaced + with that specified in the fourth parameter. For better usability, + the timeout value is specified using a TIMESPEC object. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int ppoll (struct pollfd *__fds, nfds_t __nfds, + __const struct timespec *__timeout, + __const __sigset_t *__ss); +#endif + __END_DECLS #endif /* sys/poll.h */ |