From owner-freebsd-hackers@freebsd.org Thu Feb 15 08:10:51 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 A86B7F05F6B for ; Thu, 15 Feb 2018 08:10:51 +0000 (UTC) (envelope-from lists@eitanadler.com) Received: from mail-yw0-x22d.google.com (mail-yw0-x22d.google.com [IPv6:2607:f8b0:4002:c05::22d]) (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 4CD3E683D6 for ; Thu, 15 Feb 2018 08:10:51 +0000 (UTC) (envelope-from lists@eitanadler.com) Received: by mail-yw0-x22d.google.com with SMTP id e65so8060565ywh.9 for ; Thu, 15 Feb 2018 00:10:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eitanadler.com; s=0xdeadbeef; h=mime-version:from:date:message-id:subject:to; bh=qHdtZVPrVLjizC7UeFuCXHILaFssjqC8C2QD2KtK2gg=; b=gLdkT7bNFqNYX6FYGMJSbUKq35Aprd7Wmb/325Ba8Gg6oZUMk4XEcYsqZLYYP0l2zs TyOIPSXykV8Rxqg9g6WjMS8Pzzbl9CS9C0Ceq08WolOQrb12Ssp8UDZfm/KXjAKwXHcT l5tKLptHDZ/HQHfSel99uCogmoMMP5dLZHHLU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=qHdtZVPrVLjizC7UeFuCXHILaFssjqC8C2QD2KtK2gg=; b=Rp34oXXeSZOGV/5LSwvGr2PrQan4ZeyUN/9QogVUM/U5NoiE+D1Rcn8/jqH76itd7Q zZ5O4U+7AUXc3UhBR54Pe03U/5II7CxthRq/I+oFUIpCw5suaWJQYG5FplLJUZirzC+/ T0UT7A40B+4mv9OIGSaOXU275j97SE58tv9c/IRvaArHGpKrZb7sKqMsUZFppjGqDiqG 7/BsTE7kqa8j6QB9PwwPu6f/0BG3H0KMqmQBt9Aug+gddAmvh0/NNzcTI1x561e+Z1UZ rKbUBccut9Iyq7JS4n1IbBUMpfm7qhS6ofJLtV3Yhf7qE0HpjpzEM+uJ13HVXvhag3o3 9hXw== X-Gm-Message-State: APf1xPARZhqOvxF8maKCGm1JeDtoSbjhEW6ZC556CBL2ldrkyzdFjDIJ z1wGO2O0HrSMcDYCJentjsR2BQvZO0Ewx8W0WxloNsl3 X-Google-Smtp-Source: AH8x225ihSIQ21Y4hqWubzAZsCEQa+SzlLj1/zBrgfOEr2Abn+ED7eUfCpM/3ca/ky1bR8YphoOjuTRqMiUhDRa3+lc= X-Received: by 10.37.189.135 with SMTP id f7mr1388193ybh.486.1518682250301; Thu, 15 Feb 2018 00:10:50 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a25:7107:0:0:0:0:0 with HTTP; Thu, 15 Feb 2018 00:10:19 -0800 (PST) From: Eitan Adler Date: Thu, 15 Feb 2018 00:10:19 -0800 Message-ID: Subject: Marking select(2) as restrict To: 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: Thu, 15 Feb 2018 08:10:52 -0000 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