Date: Fri, 6 Apr 2018 00:58:37 +1000 (EST) From: Bruce Evans <brde@optusnet.com.au> To: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= <royger@freebsd.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r332072 - head/sys/sys Message-ID: <20180406005023.Y3128@besplex.bde.org> In-Reply-To: <201804051431.w35EVtg4047897@repo.freebsd.org> References: <201804051431.w35EVtg4047897@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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-head@freebsd.org Thu Apr 5 15:33:06 2018 Return-Path: <owner-svn-src-head@freebsd.org> Delivered-To: svn-src-head@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 B3F6FF8E0A8 for <svn-src-head@mailman.ysv.freebsd.org>; 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 2C030820F0 for <svn-src-head@freebsd.org>; 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 <ian@freebsd.org> To: Roger Pau =?ISO-8859-1?Q?Monn=E9?= <royger@FreeBSD.org>, 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-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current <svn-src-head.freebsd.org> List-Unsubscribe: <https://lists.freebsd.org/mailman/options/svn-src-head>, <mailto:svn-src-head-request@freebsd.org?subject=unsubscribe> List-Archive: <http://lists.freebsd.org/pipermail/svn-src-head/> List-Post: <mailto:svn-src-head@freebsd.org> List-Help: <mailto:svn-src-head-request@freebsd.org?subject=help> List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/svn-src-head>, <mailto:svn-src-head-request@freebsd.org?subject=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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20180406005023.Y3128>