From owner-svn-src-all@freebsd.org Thu Apr 5 15:23:10 2018 Return-Path: Delivered-To: svn-src-all@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 C3072F8D67D; Thu, 5 Apr 2018 15:23:10 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail105.syd.optusnet.com.au (mail105.syd.optusnet.com.au [211.29.132.249]) by mx1.freebsd.org (Postfix) with ESMTP id 2ED6281A5D; Thu, 5 Apr 2018 15:23:09 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from [192.168.0.102] (c110-21-101-228.carlnfd1.nsw.optusnet.com.au [110.21.101.228]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id 5FA6D10474D1; Fri, 6 Apr 2018 00:58:43 +1000 (AEST) Date: Fri, 6 Apr 2018 00:58:37 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r332072 - head/sys/sys In-Reply-To: <201804051431.w35EVtg4047897@repo.freebsd.org> Message-ID: <20180406005023.Y3128@besplex.bde.org> References: <201804051431.w35EVtg4047897@repo.freebsd.org> MIME-Version: 1.0 X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=FNpr/6gs c=1 sm=1 tr=0 a=PalzARQSbocsUSjMRkwAPg==:117 a=PalzARQSbocsUSjMRkwAPg==:17 a=nlC_4_pT8q9DhB4Ho9EA:9 a=br4i30Z5CdPjGGWIS_YA:9 a=45ClL6m2LaAA:10 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 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: Thu, 05 Apr 2018 15:23:10 -0000 On Thu, 5 Apr 2018, [UTF-8] Roger Pau Monn=C3=A9 wrote: > Log: > introduce GiB and MiB macros > > This macros convert from GiB or MiB into bytes. This is undocumented namspace pollution with bad names and worse types. The better names GB and MB would be more likely to conflicted with code not written by disk marketers. > Modified: head/sys/sys/param.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/sys/param.h=09Thu Apr 5 14:25:39 2018=09(r332071) > +++ head/sys/sys/param.h=09Thu Apr 5 14:31:54 2018=09(r332072) > @@ -362,4 +362,8 @@ __END_DECLS > */ > #define __PAST_END(array, offset) (((__typeof__(*(array)) *)(array))[offs= et]) Old style bug: space instead of tab after #define. > > +/* Unit conversion macros. */ > +#define GiB(v) (v ## ULL << 30) > +#define MiB(v) (v ## ULL << 20) > + New style bugs: - space instead of tab after #define - use of the long long abomination Type error: - the abomination doesn't have the same type of carefully typedefed types like vm_size_t on any supported arch. > #endif=09/* _SYS_PARAM_H_ */ Old style bugs: - tab instead of space before comment on #endif. - backwards comment on #endif. Bruce From owner-svn-src-all@freebsd.org Thu Apr 5 15:33:06 2018 Return-Path: Delivered-To: svn-src-all@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 B4009F8E0A9 for ; Thu, 5 Apr 2018 15:33:06 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from pmta2.delivery6.ore.mailhop.org (pmta2.delivery6.ore.mailhop.org [54.200.129.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2C0A9820F1 for ; Thu, 5 Apr 2018 15:33:05 +0000 (UTC) (envelope-from ian@freebsd.org) X-MHO-User: 6f4e4b6f-38e6-11e8-b951-f99fef315fd9 X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 67.177.211.60 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [67.177.211.60]) by outbound2.ore.mailhop.org (Halon) with ESMTPSA id 6f4e4b6f-38e6-11e8-b951-f99fef315fd9; Thu, 05 Apr 2018 15:31:40 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id w35FWvYE087640; Thu, 5 Apr 2018 09:32:57 -0600 (MDT) (envelope-from ian@freebsd.org) Message-ID: <1522942377.49673.245.camel@freebsd.org> Subject: Re: svn commit: r332072 - head/sys/sys From: Ian Lepore To: Roger Pau =?ISO-8859-1?Q?Monn=E9?= , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Date: Thu, 05 Apr 2018 09:32:57 -0600 In-Reply-To: <201804051431.w35EVtg4047897@repo.freebsd.org> References: <201804051431.w35EVtg4047897@repo.freebsd.org> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.1 FreeBSD GNOME Team Port Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 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: Thu, 05 Apr 2018 15:33:06 -0000 On Thu, 2018-04-05 at 14:31 +0000, Roger Pau Monné wrote: > Author: royger > Date: Thu Apr  5 14:31:54 2018 > New Revision: 332072 > URL: https://svnweb.freebsd.org/changeset/base/332072 > > Log: >   introduce GiB and MiB macros >    >   This macros convert from GiB or MiB into bytes. >    >   Sponsored by: Citrix Systems R&D > > Modified: >   head/sys/sys/param.h > > Modified: head/sys/sys/param.h > ============================================================================== > --- head/sys/sys/param.h Thu Apr  5 14:25:39 2018 (r332071) > +++ head/sys/sys/param.h Thu Apr  5 14:31:54 2018 (r332072) > @@ -362,4 +362,8 @@ __END_DECLS >   */ >  #define __PAST_END(array, offset) (((__typeof__(*(array)) *)(array))[offset]) >   > +/* Unit conversion macros. */ > +#define GiB(v) (v ## ULL << 30) > +#define MiB(v) (v ## ULL << 20) > + >  #endif /* _SYS_PARAM_H_ */ > These names don't make it clear whether the conversion is bytes->GiB or GiB->bytes.  The names seem way too generic for a public namespace in a file as heavily included behind your back as param.h is. Also, this completely reasonable usage won't work, likely with confusing compile error messages:   int bytes, gibytes;   ...   bytes = GiB(gibytes); -- Ian