From owner-svn-src-all@FreeBSD.ORG Tue Aug 26 13:58:49 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 78A4AD3C; Tue, 26 Aug 2014 13:58:49 +0000 (UTC) Received: from mail108.syd.optusnet.com.au (mail108.syd.optusnet.com.au [211.29.132.59]) by mx1.freebsd.org (Postfix) with ESMTP id 3A3D03A02; Tue, 26 Aug 2014 13:58:48 +0000 (UTC) Received: from c122-106-147-133.carlnfd1.nsw.optusnet.com.au (c122-106-147-133.carlnfd1.nsw.optusnet.com.au [122.106.147.133]) by mail108.syd.optusnet.com.au (Postfix) with ESMTPS id 53A041A3FC6; Tue, 26 Aug 2014 23:58:41 +1000 (EST) Date: Tue, 26 Aug 2014 23:58:40 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Ed Schouten Subject: Re: svn commit: r270227 - head/sys/sys In-Reply-To: Message-ID: <20140826233018.H32188@besplex.bde.org> References: <201408201632.s7KGW2vF093636@svn.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=BdjhjNd2 c=1 sm=1 tr=0 a=7NqvjVvQucbO2RlWB8PEog==:117 a=PO7r1zJSAAAA:8 a=RrlIlrznAvoA:10 a=Bs0Nco5NFfgA:10 a=kj9zAlcOel0A:10 a=JzwRw_2MAAAA:8 a=6I5d2MoRAAAA:8 a=iBY4ed8fU91s6cjptCEA:9 a=CjuIK1q_8ugA:10 a=SV7veod9ZcQA:10 Cc: Davide Italiano , svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Aug 2014 13:58:49 -0000 On Tue, 26 Aug 2014, Ed Schouten wrote: > On 20 August 2014 18:32, Davide Italiano wrote: >> - _bt->frac = _ts->tv_nsec * (uint64_t)18446744073LL; >> + _bt->frac = _ts->tv_nsec * (uint64_t)18446744073; > > You could also consider using UINT64_C(18446744073); that's the C > standard way of creating an integer constant having a certain type. That would be a further obfuscation. The *INTC() macros expand to integer constant expressions of the specified type suitable for use in #if preprocessing directives. (It is otherwise difficult to detemine the correct suffix, to add to the constant to give it the specified type). There are no preprocessing directives here, so a simple cast works. The cast could also be applied to the other operand but it is easier to read when applied to the constant. UINT64_C() might work around the compiler bug of warning for constants larger than ULONG_MAX, depending on its implementation. I think it always does. On 64-bit arches, the above constant is not larger than ULONG_MAX so there is no problem, and on 32-bit arches the implementation can't be much different from appending 'ULL'. The expression could also be written without a cast and without using UINT64_C(), by using a 'ULL' suffix instead of 'LL'. That would still use the long long abomination, and be different obfuscation -- the type of the constant doesn't really matter, but we need to promote to the type of 'frac', that is, uint64_t. 'ULL' works because long longs are at least 64 bits (and I think unsigned long longs are also 2's complemention, so their type is larger than uint64_t. Bruce