]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
posix: Add p{read,write}v2 RWF_NOWAIT flag (BZ#21738)
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 10 Jul 2017 18:53:32 +0000 (15:53 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 11 Jul 2017 14:06:44 +0000 (11:06 -0300)
Linux 4.12 (b745fafaf70c0a98a2e1e7ac8cb14542889ceb0e) adds a new
p{read,write}v2 flag RWF_NOWAIT.  This patch adds it for linux
uio-ext.h header.

Checked on x86_64-linux-gnu (on a 4.10 kernel).

[BZ #21738]
* manual/llio.texi (RWF_NOWAIT): New item.
* misc/tst-preadvwritev2-common.c (do_test_with_invalid_flags):
Add RWF_NOWAIT check.
* sysdeps/unix/sysv/linux/bits/uio-ext.h (RWF_NOWAIT): New flag.

ChangeLog
manual/llio.texi
misc/tst-preadvwritev2-common.c
sysdeps/unix/sysv/linux/bits/uio-ext.h

index 71d027ddad0f7a568f4311f07417bdd218960071..7ee4f2d686ff23391817c66007e84d3b6d2d2a5f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2017-07-11  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
+
+       [BZ #21738]
+       * manual/llio.texi (RWF_NOWAIT): New item.
+       * misc/tst-preadvwritev2-common.c (do_test_with_invalid_flags):
+       Add RWF_NOWAIT check.
+       * sysdeps/unix/sysv/linux/bits/uio-ext.h (RWF_NOWAIT): New flag.
+
 2017-07-11  Stefan Liebler  <stli@linux.vnet.ibm.com>
 
        * sysdeps/unix/sysv/linux/s390/tst-ptrace-singleblock.c:
index ba1f455dfdc460707b1e25804e316404f14ae3a7..e72c53c7858149cf2005cd3c36559c4619390f44 100644 (file)
@@ -770,6 +770,10 @@ Per-IO synchronization as if the file was opened with @code{O_DSYNC} flag.
 
 @item RWF_SYNC
 Per-IO synchronization as if the file was opened with @code{O_SYNC} flag.
+
+@item RWF_NOWAIT
+Use nonblocking mode for this operation; that is, this call to @code{preadv2}
+will fail and set @code{errno} to @code{EAGAIN} if the operation would block.
 @end vtable
 
 When the source file is compiled with @code{_FILE_OFFSET_BITS == 64} the
index 4c53d567b5ef842006e52fcff90604168e72dc40..8abedc14d0602b8e7aeeb1c3108678c9271760d6 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#include <limits.h>
 #include <support/check.h>
 
 static void
 do_test_with_invalid_flags (void)
 {
-  int invalid_flag = 0x1;
-#ifdef RWF_HIPRI
-  invalid_flag <<= 1;
-#endif
-#ifdef RWF_DSYNC
-  invalid_flag <<= 1;
-#endif
-#ifdef RWF_SYNC
-  invalid_flag <<= 1;
-#endif
+#define RWF_SUPPORTED  (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT)
+  /* Set the next bit from the mask of all supported flags.  */
+  int invalid_flag = __builtin_clz (RWF_SUPPORTED);
+  invalid_flag = 0x1 << ((sizeof (int) * CHAR_BIT) - invalid_flag);
 
   char buf[32];
   const struct iovec vec = { .iov_base = buf, .iov_len = sizeof (buf) };
index 4ddb6448b0a5606d153d8471f468cec094e42365..751fc4917d9c84d103b89f14c2ad06dd2b586030 100644 (file)
@@ -46,6 +46,7 @@ extern ssize_t process_vm_writev (pid_t __pid, const struct iovec *__lvec,
 #define RWF_HIPRI      0x00000001 /* High priority request.  */
 #define RWF_DSYNC      0x00000002 /* per-IO O_DSYNC.  */
 #define RWF_SYNC       0x00000004 /* per-IO O_SYNC.  */
+#define RWF_NOWAIT     0x00000008 /* per-IO nonblocking mode.  */
 
 __END_DECLS