From owner-freebsd-hackers@freebsd.org Wed Feb 21 01:52:37 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D562CF1D5B6 for ; Wed, 21 Feb 2018 01:52:36 +0000 (UTC) (envelope-from sblachmann@gmail.com) Received: from mail-qt0-x22f.google.com (mail-qt0-x22f.google.com [IPv6:2607:f8b0:400d:c0d::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 68AB87D4FC for ; Wed, 21 Feb 2018 01:52:36 +0000 (UTC) (envelope-from sblachmann@gmail.com) Received: by mail-qt0-x22f.google.com with SMTP id v90so114669qte.12 for ; Tue, 20 Feb 2018 17:52:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=JaH26S1HWVW1E/QSWCcyQNpHUojcN2+HZnec9mksyiM=; b=P8/EOJTe+WxXbh6MMgrBtHNc67RuC/HltjYNVhdg1fieUgfsgh7oNH8cB/tF1MkQ+c uYGSBZ6D3tty2BCTRYhaOsgD9htYiUoPHe2Qyk62RIVIRxbsbpZAn7r4QQyHaidNexEG W+KgTY/alwqANc26WGJ5ZqLFB9Zg5RflFGUBEeSUSYaihvBs9ON1MPaalCVNC1TIzAwN Wy3b01bNZVhMiPF0MdHOOmq7Kyg/mfdK4mbs0ZZLR+LvdtFoO1y1i8ikP8caE/d1Mm5R hEfVeWY3VU/9PKbokX9vVSBrzycHvOYP+o1bNlOqi2nYyNddAL5Z8vG39cvzNhEAFiNG bEMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=JaH26S1HWVW1E/QSWCcyQNpHUojcN2+HZnec9mksyiM=; b=ZY87XE0EBI9PlsrKKkqpHYSQANFdyMjQCQCBE8OCN8DZY1RgTExYovHkcypBxtiw3T aKmD8Dl7GoGwkOeKeGyIokGKUBcMxHZ/vuQFa2aehLNk7pfuFSIEzsj6f7Q+1rVMiXF4 hFBY8tvfNqI8hS71A67VJONUWdn8CxcjPGoqFICnrCoduqpwsVXZNh0fwYmAPuIu5Isz i5sCoLJoi5fP+7sUDp+FC3bMZtWp1BebXJYPqnpDWTEicw2SwMd/X95NowLjODEY3UlN RvS2mj1NM5NiHqMW3O/Urjfz6hBwqZ4sn21EcjnvZebEdcLsrB3fMbaqlqfCHv4QEYJB 9F8g== X-Gm-Message-State: APf1xPCMI985XCkl/mdNDdmRbwd64e9Gv5OOWdriOtRGRqL6sgZvcoro m96bQhxyPN3OQY1Nr6SeLKH2zDV9/MQe+KDFz3NfLw== X-Google-Smtp-Source: AH8x226afCHH5zhohDuJeX19CuaQjr4w66A1CwxEtMLYT31i9FrLoRFl7tyK3Kx8z//AtqG0G3ByxlGWzDtxUHT6eVE= X-Received: by 10.200.52.204 with SMTP id x12mr2741011qtb.267.1519177956046; Tue, 20 Feb 2018 17:52:36 -0800 (PST) MIME-Version: 1.0 Received: by 10.140.32.74 with HTTP; Tue, 20 Feb 2018 17:52:35 -0800 (PST) In-Reply-To: References: From: Stefan Blachmann Date: Wed, 21 Feb 2018 02:52:35 +0100 Message-ID: Subject: Re: Marking select(2) as restrict To: Eitan Adler Cc: FreeBSD Hackers , Warner Losh Content-Type: text/plain; charset="UTF-8" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Feb 2018 01:52:37 -0000 As the last C standard I know is ANSI, I was curious and read what restrict does (https://en.wikipedia.org/wiki/Restrict). To understand more about select() I read in the Linux tutorial (http://man7.org/linux/man-pages/man2/select_tut.2.html) . The section "Select Law" looks like that things could break easy. Personally (in particular because I don't know the matter) I would be afraid that making select pointers restrict could cause hard-to debug misbehavior of a few programs that are already working borderline (linux ports etc). But as said, this is my unqualified guess. And, few, almost no documents on select show it as restrict. Always following Posix isn't necessarily good, as many don't care about it. For example, with 11.0 the default Posix conform SHM setting was changed to non-Posix-compliant, because posix conformity caused just too many people troubles. And, maybe the gain would be little anyway? Just my worthless 2 cents. Have a good day @hackers :) Stefan On 2/21/18, Eitan Adler wrote: > I filed a request for a slightly modified version of this patch to be > exp-run. I'm planning on committing unless there is significant > fallout or objections on this list. > > https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=225981 > > On 15 February 2018 at 00:10, Eitan Adler wrote: >> Hi all, >> >> POSIX requires that the fd_set arguments in select(2) be marked as >> restrict. This patch attempts to implement that. >> >> (a) Am I missing anything? >> (b) Anything in particular to watch out for? >> (c) Assuming an exp-run passes any reason not to commit? >> >> >> Index: lib/libc/sys/select.2 >> =================================================================== >> --- lib/libc/sys/select.2 (revision 329296) >> +++ lib/libc/sys/select.2 (working copy) >> @@ -39,7 +39,7 @@ >> .Sh SYNOPSIS >> .In sys/select.h >> .Ft int >> -.Fn select "int nfds" "fd_set *readfds" "fd_set *writefds" "fd_set >> *exceptfds" "struct timeval *timeout" >> +.Fn select "int nfds" "fd_set * restrict readfds" "fd_set * restrict >> writefds" "fd_set * restrict exceptfds" "struct timeval *timeout" >> .Fn FD_SET fd &fdset >> .Fn FD_CLR fd &fdset >> .Fn FD_ISSET fd &fdset >> Index: lib/libc/sys/select.c >> =================================================================== >> --- lib/libc/sys/select.c (revision 329296) >> +++ lib/libc/sys/select.c (working copy) >> @@ -41,7 +41,7 @@ __weak_reference(__sys_select, __select); >> >> #pragma weak select >> int >> -select(int n, fd_set *rs, fd_set *ws, fd_set *es, struct timeval *t) >> +select(int n, fd_set * restrict rs, fd_set * restrict ws, fd_set * >> restrict es, struct timeval *t) >> { >> >> return (((int (*)(int, fd_set *, fd_set *, fd_set *, struct timeval *)) >> Index: sys/sys/select.h >> =================================================================== >> --- sys/sys/select.h (revision 329296) >> +++ sys/sys/select.h (working copy) >> @@ -101,8 +101,7 @@ int pselect(int, fd_set *__restrict, fd_set *__res >> const struct timespec *__restrict, const sigset_t *__restrict); >> #ifndef _SELECT_DECLARED >> #define _SELECT_DECLARED >> -/* XXX missing restrict type-qualifier */ >> -int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); >> +int select(int, fd_set *__restrict, fd_set *__restrict, fd_set >> *__restrict, struct timeval *); >> #endif >> __END_DECLS >> #endif /* !_KERNEL */ >> >> >> -- >> Eitan Adler > > > > -- > Eitan Adler > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" >