From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 130201 invoked by alias); 23 Aug 2016 19:29:43 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 130189 invoked by uid 89); 23 Aug 2016 19:29:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f49.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=5Qtcb38cedoynvGjVMt2insHdRW9Y6YQ+riUC77zrF4=; b=ivWS+IqtF+zj3C9NHc8I4TthVWTgRnIsj5ReRcVvhvsXTLsFIoIGdaqLqRxlls/h5y g+/sk5SNqZRLHPDoVJyvrBMPLwZlxEkMGOeTYUzQvVG8bOPtUYyVtU4dXs3mIKPxXSEs WDP7PG13sEwAlkk1ZksDlhnI1thZKIfKKSv69doqNwDyIxDaLNo00FQeHF/JmqYa4/mU 6yCd8m2AUeM28zQUhmfCj5UKXqBCm6MzeecPpZnj7ttZaU1upCODct48XPvMeprgQy2v LV5nZ5/eR2YERM7r0XBoERLgioy/46satpOL6MCfI/dfDSXUsvIYb0RGo0eewrZkf/M8 7tVA== X-Gm-Message-State: AEkoout7VtWpoMDQlctRexM/yRs+gtD193VM9X8US3QA9YidjXNAqYQU9wgo0ng8UJ/nBl41 X-Received: by 10.28.27.143 with SMTP id b137mr22049432wmb.12.1471980570689; Tue, 23 Aug 2016 12:29:30 -0700 (PDT) Subject: Re: [PATCH 4/4] Consolidate posix_fadvise implementations To: Yury Norov References: <1471617709-16267-1-git-send-email-adhemerval.zanella@linaro.org> <1471617709-16267-5-git-send-email-adhemerval.zanella@linaro.org> <20160822150819.GC15745@yury-N73SV> Cc: libc-alpha@sourceware.org From: Adhemerval Zanella Message-ID: Date: Tue, 23 Aug 2016 19:29:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <20160822150819.GC15745@yury-N73SV> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-SW-Source: 2016-08/txt/msg00737.txt.bz2 Thanks for the reviews, comments below. On 22/08/2016 12:08, Yury Norov wrote: >> diff --git a/posix/tst-posix_fadvise-common.c b/posix/tst-posix_fadvise-common.c >> new file mode 100644 >> index 0000000..6670835 >> --- /dev/null >> +++ b/posix/tst-posix_fadvise-common.c >> @@ -0,0 +1,113 @@ >> +/* Common posix_fadvise tests definitions. >> + Copyright (C) 2016 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 >> + 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, see >> + . */ >> + >> +#include >> +#include >> +#include >> +#include >> + >> +static void do_prepare (void); >> +#define PREPARE(argc, argv) do_prepare () >> +static int do_test (void); >> +#define TEST_FUNCTION do_test () >> + >> +#include >> + >> +static char *temp_filename; >> +static int temp_fd; >> +static char fifoname[] = "/tmp/tst-posix_fadvise-fifo-XXXXXX"; >> +static int fifofd; >> + >> +static void >> +do_prepare (void) >> +{ >> + temp_fd = create_temp_file ("tst-posix_fadvise.", &temp_filename); >> + if (temp_fd == -1) >> + { >> + printf ("cannot create temporary file: %m\n"); >> + exit (1); >> + } >> + >> + if (mktemp (fifoname) == NULL) >> + { > > Trailing whitespace Ack, I will fix it. > >> + printf ("%s: cannot generate temp file name: %m\n", __func__); >> + exit (1); >> + } >> + add_temp_file (fifoname); >> + >> + if (mkfifo (fifoname, S_IWUSR | S_IRUSR) != 0) >> + { >> + printf ("%s: cannot create fifo: %m\n", __func__); >> + exit (1); >> + } >> + >> + fifofd = open (fifoname, O_RDONLY | O_NONBLOCK); >> + if (fifofd == -1) >> + { >> + printf ("%s: cannot open fifo: %m\n", __func__); >> + exit (1); >> + } >> +} >> + >> +#define FAIL(str) \ >> + do { printf ("error: %s (line %d)\n", str, __LINE__); return 1; } while (0) >> + > > You don't fit into a single line anyway. Why don't you make it nicer? Right, I think the snippet below should be more readable. I will change it. #define FAIL(str) \ do { \ printf ("error: %s (line %d)\n", str, __LINE__); \ return 1; \ } while (0) >> +/* Effectivelly testing posix_fadvise is hard because side effects are not >> + observed without checking either performance or any kernel specific >> + supplied information. Also, the syscall is meant to be an advisory, >> + so kernel is free to use these information in which way it seems as >> + fit (even ignoring it). >> + > > Trailing whitespaces > Ack. >> diff --git a/sysdeps/unix/sysv/linux/posix_fadvise.c b/sysdeps/unix/sysv/linux/posix_fadvise.c >> index 093d707..869a642 100644 >> --- a/sysdeps/unix/sysv/linux/posix_fadvise.c >> +++ b/sysdeps/unix/sysv/linux/posix_fadvise.c >> @@ -22,27 +22,46 @@ >> /* Advice the system about the expected behaviour of the application with >> respect to the file associated with FD. */ >> >> +#ifndef __OFF_T_MATCHES_OFF64_T >> + >> +/* Both arm and powerpc implements fadvise64_64 with last 'advise' argument >> + just after 'fd' to avoid the requirement of implementing 7-arg syscalls. >> + ARM also defines __NR_fadvise64_64 as __NR_arm_fadvise64_64. >> + >> + tile requires __ASSUME_ALIGNED_REGISTER_PAIRS but implements the 32-bit >> + fadvise64_64 without the padding 0 after fd. >> + >> + s390 implements fadvice64_64 using a specific struct with arguments >> + packed inside. This is the only implementation handled in arch-specific >> + code. */ > > Are you sure it will be the only implementation forever, and comment > will be valid too? The comment is meant to only describe supported architectures at the time the patch was created. Any other port that either deviates from current approach or uses a already describe one should update this description. >> diff --git a/sysdeps/unix/sysv/linux/posix_fadvise64.c b/sysdeps/unix/sysv/linux/posix_fadvise64.c >> index 6d10558..15e08b7 100644 >> --- a/sysdeps/unix/sysv/linux/posix_fadvise64.c >> +++ b/sysdeps/unix/sysv/linux/posix_fadvise64.c >> @@ -17,32 +17,54 @@ >> >> #include >> #include >> -#include >> +#include >> >> int __posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise); >> -int __posix_fadvise64_l32 (int fd, off64_t offset, size_t len, int advise); >> + >> +/* Both arm and powerpc implements fadvise64_64 with last 'advise' argument >> + just after 'fd' to avoid the requirement of implementing 7-arg syscalls. >> + ARM also defines __NR_fadvise64_64 as __NR_arm_fadvise64_64. >> + >> + tile requires __ASSUME_ALIGNED_REGISTER_PAIRS but implements the 32-bit >> + fadvise64_64 without the padding 0 after fd. >> + >> + s390 implements fadvice64_64 using a specific struct with arguments >> + packed inside. This is the only implementation handled in arch-specific >> + code. */ >> + >> +#ifdef __ASSUME_FADVISE64_64_NO_ALIGN >> +# undef __ALIGNMENT_ARG >> +# define __ALIGNMENT_ARG >> +#endif >> + >> +#ifndef __NR_fadvise64_64 >> +# define __NR_fadvise64_64 __NR_fadvise64 >> +#endif >> >> /* Advice the system about the expected behaviour of the application with >> respect to the file associated with FD. */ >> - > > Is it necessary to remove this line. You don't do so elsewhere.. Ack, I will add it.