From owner-freebsd-hackers@freebsd.org Mon Feb 26 12:46:42 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 C1D3FF21333; Mon, 26 Feb 2018 12:46:41 +0000 (UTC) (envelope-from tijl@freebsd.org) Received: from mailrelay118.isp.belgacom.be (mailrelay118.isp.belgacom.be [195.238.20.145]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "relay.skynet.be", Issuer "GlobalSign Organization Validation CA - SHA256 - G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 15F877380F; Mon, 26 Feb 2018 12:46:40 +0000 (UTC) (envelope-from tijl@freebsd.org) X-Belgacom-Dynamic: yes IronPort-PHdr: =?us-ascii?q?9a23=3ArAR86hFIKLnGdYmUQPj+jp1GYnF86YWxBRYc798d?= =?us-ascii?q?s5kLTJ7yp8WwAkXT6L1XgUPTWs2DsrQY07GQ6/iocFdDyK7JiGoFfp1IWk1Nou?= =?us-ascii?q?QttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXdrXKo8DEdBAj0OxZr?= =?us-ascii?q?KeTpAI7SiNm82/yv95HJbAhEmDSwbaluIBmqsA7cqtQYjYx+J6gr1xDHuGFIe+?= =?us-ascii?q?NYxWNpIVKcgRPx7dqu8ZBg7ipdpesv+9ZPXqvmcas4S6dYDCk9PGAu+MLrrxjD?= =?us-ascii?q?QhCR6XYaT24bjwBHAwnB7BH9Q5fxri73vfdz1SWGIcH7S60/VC+85Kl3VhDnlC?= =?us-ascii?q?YHNyY48G7JjMxwkLlbqw+lqxBm3oLYfJ2ZOP94c6jAf90VWHBBU95fWSJBHI2y?= =?us-ascii?q?cogBAOgPPelXs4bzqEADrQe8CAWwGO/j1iNEimHw0KYn0+ohCwbG3Ak4EtwQsX?= =?us-ascii?q?TUrtH1P7oMXOCyy6nI1ivMb/ZM1jf784jDbxcsoe2NXbJydcrc0kkhFxnbgVqO?= =?us-ascii?q?tIHrIj2b2v4Ks2iB4OptTOSigHMkpQFpujWixdoghpPXio8ay13I7zh1zYg7KN?= =?us-ascii?q?GiVUJ2b9GpHZ1NvC+ALYR2WNktQ2RwtSY/zb0JpIC0cTARyJQi2x7fc/uHc5WU?= =?us-ascii?q?4h77VOaePzN4hHV9dbK8nRmy9UmgyujiWcmu11ZGtDZFktjOtnAJzRDc9s+HSv?= =?us-ascii?q?xm/ki/3DaAzQbT6vpeLUAzj6rbJIYtwr82lpUNrUTOBiz7lFjsgKOIeUgp+/Kk?= =?us-ascii?q?5/npb7jovJOQKoF5hw7mPqQrgMO/AOA4MgYUX2ic/OSxzKHj/Uz7QLVOlfA2nL?= =?us-ascii?q?PZv47EKssAva62HhVZ0oE56xawFzumysgXnWEbLFJZfxKKl4vpNE/QIPD8Cvey?= =?us-ascii?q?mFqskC11yP/YJbLhGYjCImLEkLf7crZ381RcxxYrzdBD+5JUDakMIPzpWkDvqt?= =?us-ascii?q?PXFQQ5PBGtz+b8FNVyzIUeVn+VDa+DLazSqkSF5uw1I+aSeoAaoy39JOU/6/7p?= =?us-ascii?q?l385lkcXfbO10psPdHC4AvNmLl2XYXr2nNgOD3wFvhEjQ+DziF2NSyJcZ3WsUK?= =?us-ascii?q?Im/TE2E4ymDZ3dSY+zm7OBxzq0EodRZmBcBVDfWUvvIq+eRvwBIA+MK8l62mgO?= =?us-ascii?q?T7SsY4g5yQy1sgLmjbFgK6zd53tLm4jk0Y1J5u/X3To18id5Cs2byCnZU2B2mk?= =?us-ascii?q?smXTI79ptT50tnxQHQguBDn/VEGIkLtLtyWQAgOMuZlrQiBg=3D=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2AmBgCOAJRa/4aF9lFcGgEBAQEBAgEBA?= =?us-ascii?q?QEIAQEBAYNPVoEAKI5qjQcBAYIBMgFjlgWCFoU9AoI/VhcBAgEBAQEBAQIBaih?= =?us-ascii?q?CDAGBaSQBgkcBBTocIxALDgoJJQ8qHgYThRStNohkghQBAQEBAQEEAQEBASSOL?= =?us-ascii?q?IsTBaFhCZQTgQSRaZckHwE2gVFNMAiCfYRbPzeIYoN1AQEB?= X-IPAS-Result: =?us-ascii?q?A2AmBgCOAJRa/4aF9lFcGgEBAQEBAgEBAQEIAQEBAYNPVoE?= =?us-ascii?q?AKI5qjQcBAYIBMgFjlgWCFoU9AoI/VhcBAgEBAQEBAQIBaihCDAGBaSQBgkcBB?= =?us-ascii?q?TocIxALDgoJJQ8qHgYThRStNohkghQBAQEBAQEEAQEBASSOLIsTBaFhCZQTgQS?= =?us-ascii?q?RaZckHwE2gVFNMAiCfYRbPzeIYoN1AQEB?= Received: from 134.133-246-81.adsl-dyn.isp.belgacom.be (HELO kalimero.tijl.coosemans.org) ([81.246.133.134]) by relay.skynet.be with ESMTP; 26 Feb 2018 13:45:29 +0100 Received: from kalimero.tijl.coosemans.org (kalimero.tijl.coosemans.org [127.0.0.1]) by kalimero.tijl.coosemans.org (8.15.2/8.15.2) with ESMTP id w1QCjR7J051426; Mon, 26 Feb 2018 13:45:29 +0100 (CET) (envelope-from tijl@FreeBSD.org) Date: Mon, 26 Feb 2018 13:45:26 +0100 From: Tijl Coosemans To: Bruce Evans Cc: Mark Millard , FreeBSD Hackers , FreeBSD Standards , Kevin Lo Subject: Re: Marking select(2) as restrict Message-ID: <20180226134526.425aa33c@kalimero.tijl.coosemans.org> In-Reply-To: <20180226200951.V2634@besplex.bde.org> References: <20180221032247.GA81670@ns.kevlo.org> <20180221104400.GU94212@kib.kiev.ua> <20180222112752.10da7e51@kalimero.tijl.coosemans.org> <20180222105608.GE94212@kib.kiev.ua> <20180225214813.776a9f58@kalimero.tijl.coosemans.org> <2909E983-953A-4463-959C-F3C386BC6C9A@yahoo.com> <20180226135457.B1203@besplex.bde.org> <1A2830F4-A00B-4C56-8D28-C46715DC7C9E@yahoo.com> <20180226200951.V2634@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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: Mon, 26 Feb 2018 12:46:42 -0000 On Mon, 26 Feb 2018 21:00:21 +1100 (EST) Bruce Evans wrote: > For select() with restrict, I think the compiler cannot assert that > the args don't overlap since (even without the detailed specification > and Example 3), the compiler cannot know if select() modifies its args. > For all that the compiler knows, select() might be a stub that never > modifies or even reads anything. I think doing no accesses satifies > the constraints of restrict. It might be valid for the compiler to > assert that the (values pointed to by) the fdset args don't change for > select(nfd, &fdset, &fdset, &fdset, &tv) (because any write access > through an fdset type would give undefined behaviour on the other fdset > args; tv can still change since it has a different type). But this is > precisely what is wanted for the original example where we only care > about the return value -- then fdset is indeterminate after the call > so we shouldn't use it; the compiler is unlikely to optimize the non-use > of it and the worst that it can do is add a runtime assertion that the > arg didn't change. I don't think the compiler can assert that fdset is unmodified. It's valid for select to modify fdset through one pointer if it doesn't dereference the other two.