From patchwork Mon Jul 10 19:47:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 21529 Received: (qmail 115329 invoked by alias); 10 Jul 2017 19:48:03 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 115231 invoked by uid 89); 10 Jul 2017 19:48:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qk0-f179.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=u8IIDOKJ7W414GxaIC8dyQ6lP99wMHsO1j/chjGurgg=; b=FOtCnYvd6bKq41SR7ZWIhoH8Vy/z2dY/4ehPnLl2MP8WLcOH9dIjuZ/wZKIfzrU8q4 lv7BIIVzloYVqRol7QUAxIop4JB3YlsFA3HcuypLx5gJ/KRTj2TDxe609CUbl19NLvgg jbTsO7oYV4vnadMiYbGjsIATg3vj6/OiR+gonCsh9ndebaQociKOPXXtjJz1rnIIl4YQ 272TCgNuV5Oj0b1Aj/s76vGd/zOI0ycqbfUBSshml6JgCCYqa4LguTb6NPUgkZP8t4G+ X7LmCrZe8xQfd8lO0S/aUXb9gL505pkYfyS6sTxQzD9GQENJusd79Ks8JCj4GASbHArp SaKg== X-Gm-Message-State: AIVw112B2Bsa/4o2J96gQEX0F0oaF+mpkpgvcKFC/wV40dL8BdffAQGQ tQiQAguQ33sYMFnmxfcRAg== X-Received: by 10.55.77.11 with SMTP id a11mr6542114qkb.161.1499716078750; Mon, 10 Jul 2017 12:47:58 -0700 (PDT) Subject: Re: [PATCH] posix: Add p{read,write}v2 RWF_NOWAIT flag (BZ#21738) To: Zack Weinberg Cc: GNU C Library References: <1499714685-12770-1-git-send-email-adhemerval.zanella@linaro.org> From: Adhemerval Zanella Message-ID: Date: Mon, 10 Jul 2017 16:47:55 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: On 10/07/2017 16:36, Zack Weinberg wrote: > Argh, one more thing: > > On Mon, Jul 10, 2017 at 3:34 PM, Zack Weinberg wrote: >> >> Suggest instead "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." > > "... this call to @code{preadv2} or @code{pwritev2} ..." It does work > in both, right? > > zw > That's the new version: [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. diff --git a/manual/llio.texi b/manual/llio.texi index ba1f455..e72c53c 100644 --- a/manual/llio.texi +++ b/manual/llio.texi @@ -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 diff --git a/misc/tst-preadvwritev2-common.c b/misc/tst-preadvwritev2-common.c index 4c53d56..8abedc1 100644 --- a/misc/tst-preadvwritev2-common.c +++ b/misc/tst-preadvwritev2-common.c @@ -16,21 +16,16 @@ License along with the GNU C Library; if not, see . */ +#include #include 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) }; diff --git a/sysdeps/unix/sysv/linux/bits/uio-ext.h b/sysdeps/unix/sysv/linux/bits/uio-ext.h index 4ddb644..12cd78e 100644 --- a/sysdeps/unix/sysv/linux/bits/uio-ext.h +++ b/sysdeps/unix/sysv/linux/bits/uio-ext.h @@ -46,6 +46,10 @@ 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, return -EAGAIN if operation + would block */ +#define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT) + __END_DECLS