From owner-freebsd-hackers@freebsd.org Mon Feb 19 06:20:04 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 C1AA4F05842 for ; Mon, 19 Feb 2018 06:20:04 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from vps1.elischer.org (vps1.elischer.org [204.109.63.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "vps1.elischer.org", Issuer "CA Cert Signing Authority" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 635ED826E0 for ; Mon, 19 Feb 2018 06:20:04 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from Julian-MBP3.local (203-59-173-201.dyn.iinet.net.au [203.59.173.201]) (authenticated bits=0) by vps1.elischer.org (8.15.2/8.15.2) with ESMTPSA id w1J6JxSg028828 (version=TLSv1.2 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Sun, 18 Feb 2018 22:20:01 -0800 (PST) (envelope-from julian@freebsd.org) Subject: Re: 1 << 31 redux To: Kyle Evans , Eitan Adler Cc: FreeBSD Hackers References: From: Julian Elischer Message-ID: <798b566c-dc9c-cdd8-9040-6fa0806c1406@freebsd.org> Date: Mon, 19 Feb 2018 14:19:53 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US 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, 19 Feb 2018 06:20:04 -0000 On 14/1/18 1:34 am, Kyle Evans wrote: > On Thu, Jan 11, 2018 at 6:03 AM, Eitan Adler wrote: >> Hi all, >> >> A few years ago I fixed most of the cases where we used 1 << 31 in FreeBSD. >> This expression is illegal in C. Since then the issue has arisen again. >> >> https://reviews.freebsd.org/D13858 fixed most of the non-contrib cases. >> >> I'd also like to see if we could find some more general solution, be it a >> compiler warning, bit set macro, or otherwise. >> > For what it's worth, I've really come to like and appreciate NetBSD's > approach with __BIT/__BITS. See [1] for implementation, [2] for usage. > > [1] http://src.illumos.org/source/xref/netbsd-src/sys/sys/cdefs.h#577 I like __BIT() but it should give a compile error if the number is too large rather than just setting it to 0. in fact I think I think it should take a target and use the size of the target rather than assuming int. > [2] http://src.illumos.org/source/xref/netbsd-src/sys/arch/arm/sunxi/sunxi_usbphy.c#L44 > _______________________________________________ > 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" >