From owner-svn-src-all@freebsd.org Fri Apr 6 14:14:45 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 DD34CF892CD; Fri, 6 Apr 2018 14:14:44 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-io0-f177.google.com (mail-io0-f177.google.com [209.85.223.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 758EA7DD0E; Fri, 6 Apr 2018 14:14:44 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-io0-f177.google.com with SMTP id q84so1881914iod.10; Fri, 06 Apr 2018 07:14:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc:content-transfer-encoding; bh=irA4GjPiFiZC7KoHIIrWxrGK6s9LmizbzmR/8/6+GHs=; b=j1ySjlSGyUljKf/Pmgf7TGNhps9hq1KmSggkH8np0n+UebxcyUeL6/3BWo4Nv5Pn15 w7ZgdPsKc5QO6kd6V11KfcyI1PNJNJftw+8p5xdavaA4FphirVunTaLWUrpeQy7n2Nuk TVI/Sx3aFyR6Ung98ZHuuQc5UF5LICXrfMvoF7pbSQA68lByxKstN7AGPqhJGoIeK6yS smZY+6gYB7bTBlYLj/sB8iPaCCcgJfhCPLX5Nb5zGk6LONyV7GgY4L2yEQ6ndD6UsVxE DU4DVnn0N6hsicVTxcCpC6ocVTRlD6lqC3B0j0DrARVUqFmfvMNemT2bEHA93AejUu+t EVZw== X-Gm-Message-State: AElRT7FjDPYKEjvo4art1+qR0RNxvPBP8xAmDYt2m655qTwUJ4/CyGWt P/aIzAjYgsCrxmw2PabCom7vMwwr X-Google-Smtp-Source: AIpwx49OOZK0cXRjfIDoisalc4Wj0kfG2luanaN/jGzDKmntgHgKpEqgan/UKrBbIbQIpvHgpu0pBQ== X-Received: by 10.107.179.134 with SMTP id c128mr24675656iof.278.1523024083289; Fri, 06 Apr 2018 07:14:43 -0700 (PDT) Received: from mail-io0-f181.google.com (mail-io0-f181.google.com. [209.85.223.181]) by smtp.gmail.com with ESMTPSA id v128-v6sm4747364itg.14.2018.04.06.07.14.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Apr 2018 07:14:42 -0700 (PDT) Received: by mail-io0-f181.google.com with SMTP id q80so1873184ioi.13; Fri, 06 Apr 2018 07:14:42 -0700 (PDT) X-Received: by 10.107.181.72 with SMTP id e69mr25449815iof.267.1523024082688; Fri, 06 Apr 2018 07:14:42 -0700 (PDT) MIME-Version: 1.0 Reply-To: cem@freebsd.org Received: by 10.2.62.19 with HTTP; Fri, 6 Apr 2018 07:14:42 -0700 (PDT) In-Reply-To: <201804061120.w36BK6s6074635@repo.freebsd.org> References: <201804061120.w36BK6s6074635@repo.freebsd.org> From: Conrad Meyer Date: Fri, 6 Apr 2018 07:14:42 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r332092 - in head/sys: amd64/amd64 sys x86/x86 To: =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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: Fri, 06 Apr 2018 14:14:45 -0000 I like something like this for clarity. But I don't see any reason for these function-like macros instead of the more general definition of an SI prefix constant multiple. A multiple works with numeric literals and variables alike. Something like: #define GiB ((size_t)1 << 30) my_foo =3D 15 * GiB; (There's nothing byte-specific about SI prefixes, but "Gi" alone is a worse name. Arguably, size_t is wrong for quantities of bytes on 32-bit platforms with 64-bit off_t.) The compiler will still reduce constant expressions. Perhaps even better, conversion away is straightforward units math, and the compiler can still do the clever thing with right shifts: my_gb =3D howmany(my_foo, GiB); //or my_gb =3D my_foo / GiB; Unfortunately, I expect a lot of code to already have defines or variables with conflicting names, so I'm not sure adding these names to primary headers is viable as-is. Best, Conrad On Fri, Apr 6, 2018 at 4:20 AM, Roger Pau Monn=C3=A9 w= rote: > Author: royger > Date: Fri Apr 6 11:20:06 2018 > New Revision: 332092 > URL: https://svnweb.freebsd.org/changeset/base/332092 > > Log: > remove GiB/MiB macros from param.h > > And instead define them in the files where they are used. > > Requested by: bde > > Modified: > head/sys/amd64/amd64/mp_machdep.c > head/sys/sys/param.h > head/sys/x86/x86/mp_x86.c > > Modified: head/sys/amd64/amd64/mp_machdep.c > =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/amd64/amd64/mp_machdep.c Fri Apr 6 09:25:08 2018 (= r332091) > +++ head/sys/amd64/amd64/mp_machdep.c Fri Apr 6 11:20:06 2018 (= r332092) > @@ -83,6 +83,8 @@ __FBSDID("$FreeBSD$"); > #define BIOS_RESET (0x0f) > #define BIOS_WARM (0x0a) > > +#define GiB(v) (v ## ULL << 30) > + > extern struct pcpu __pcpu[]; > > /* Temporary variables for init_secondary() */ > > 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 Fri Apr 6 09:25:08 2018 (r332091) > +++ head/sys/sys/param.h Fri Apr 6 11:20:06 2018 (r332092) > @@ -362,8 +362,4 @@ __END_DECLS > */ > #define __PAST_END(array, offset) (((__typeof__(*(array)) *)(array))[off= set]) > > -/* Unit conversion macros. */ > -#define GiB(v) (v ## ULL << 30) > -#define MiB(v) (v ## ULL << 20) > - > #endif /* _SYS_PARAM_H_ */ > > Modified: head/sys/x86/x86/mp_x86.c > =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/x86/x86/mp_x86.c Fri Apr 6 09:25:08 2018 (r332091) > +++ head/sys/x86/x86/mp_x86.c Fri Apr 6 11:20:06 2018 (r332092) > @@ -160,6 +160,8 @@ struct cache_info { > > unsigned int boot_address; > > +#define MiB(v) (v ## ULL << 20) > + > void > mem_range_AP_init(void) > { >