From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::12d; helo=mail-it1-x12d.google.com; envelope-from=df7729@gmail.com; receiver=edk2-devel@lists.01.org Received: from mail-it1-x12d.google.com (mail-it1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 17F352119AC2C for ; Tue, 11 Dec 2018 14:53:19 -0800 (PST) Received: by mail-it1-x12d.google.com with SMTP id z7so6260375iti.0 for ; Tue, 11 Dec 2018 14:53:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HPhyxFxyctyMvxyJ+05INFX4NuBTNGQ1BdzwcCHff1U=; b=byhrDUUW77M2mNuGtCY/Jz+5LVFPa9utLUKX61QWMQGFSI5Nf3dgKsU7SgAlhdsht+ Fu/hj0r0zh/0DmS/UUzGEk1Y4Zw0bmYWve+BaK8reUor37opHk3Hd3MO5rG2Lra0O4uK +w9omA+SXpFIQT9mwToNccNzVh5ih1LUhW0Yr74uyWtr8Q9PjKan527229zW5NfpXDrX LoMPn9xVgLtDFpdU8ZcfL7CuoHOF28/rh942PikpdW5N0cGjFPIjslojCFlggpD8YxCG gZDBEif/qapZrOIgFq3SU95m/E0XKdmoOGALLlf+MXUWwT38LVnhDFXpKKplNZQurKtJ ehDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HPhyxFxyctyMvxyJ+05INFX4NuBTNGQ1BdzwcCHff1U=; b=S4KDc8AgP/5nfOmcByTDBNQhAzXKmmTjzcGN6PAx6RPV0o8wj/tEICKGbKMPOR2gnb CzOo8gklUt4YgZSiNy4UlggHcAOWzRKP4ztuy/3QXulk7ydaa8DMBXUIeJsZm263PAwW uAZ9STuEFG1wGPrmySXNkm2XjbDQ5IsA/MVrFoE1XiHTDAdldtCHcBnqLA462Ps+LJ+J sFs1pCl/6UU1KMtp6gxr/ODfw+fPQloux770WsANs+OmTKYvnfmYp9p2JZmFL2zHslU4 eBEwIhoVou5DYIC76Ukvt10x/x76+Vmv/Cxb8QCH2xMy7UnA4YMYZ35Sckhskbqlyb0p x5tQ== X-Gm-Message-State: AA+aEWaXCiZF4pms74wG4xsN49vtfsPpEtVtneeOXjG0H+2/+DIgRmpE +4flUxfM8TVI0cTM4y6rCDk6O2Ogz9VSxlmzEaQ= X-Google-Smtp-Source: AFSGD/VTyG5nm/H2xeEMyzOyu/MUftGiJG+8PIaGb5Z6GNArBOTu5VyBorLLuj6YOuMqalkfno6vbmCnju+wM9vrbk0= X-Received: by 2002:a24:1dce:: with SMTP id 197mr4174606itj.154.1544568799075; Tue, 11 Dec 2018 14:53:19 -0800 (PST) MIME-Version: 1.0 References: <20181130224537.18936-1-ard.biesheuvel@linaro.org> <20181130224537.18936-7-ard.biesheuvel@linaro.org> <4a244c8f-8f59-2936-f543-2bd43f78af9c@redhat.com> <11e96d9d-7f7c-7b2d-c05d-e5d009a2f4b1@redhat.com> In-Reply-To: <11e96d9d-7f7c-7b2d-c05d-e5d009a2f4b1@redhat.com> From: "David F." Date: Tue, 11 Dec 2018 14:53:07 -0800 Message-ID: To: Laszlo Ersek Cc: Ard Biesheuvel , edk2 developers list , "Carsey, Jaben" , "Gao, Liming" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [PATCH v2 6/6] BaseTools/CommonLib: drop definition of MAX_UINTN X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Dec 2018 22:53:20 -0000 Content-Type: text/plain; charset="UTF-8" I don't know, to me it's very clear that UINTN is talking about the target, just like size_t would be. There are/were a bunch of API's using UINTN so using UINTN was desirable, and where needed UINTN_MAX. I just don't see an advantage to removing it. Do see disadvantage to removing it for breaking existing code and for those that want the "native" (best/fasted/most efficient) int size for the processor (similar again to size_t) On Tue, Dec 11, 2018 at 7:46 AM Laszlo Ersek wrote: > On 12/11/18 08:11, David F. wrote: > > Not sure why you'd take that out when someone using UINTN for variables > may > > want to use MAX_UINTN ? Future may be different. > > The UINTN type comes from the UEFI spec: > > Unsigned value of native width. (4 bytes on supported 32-bit > processor instructions, 8 bytes on supported 64-bit processor > instructions, 16 bytes on supported 128-bit processor instructions) > > In this sense, "native" refers to the firmware execution environment. > The firmware execution environment need not have anything in common with > the build environment. (You can build 32-bit ARM firmware on X64 hosts.) > In such a scenario, using UINTN *at all* is fraught with > misunderstandings. It *would* be possible to use UINTN as it applies to > the build (= hosted) environment, and in that sense MAX_UINTN would also > be possible to define. However, the code being removed (= defining > MAX_UINTN as MAX_ADDRESS) proves that that approach would be very easy > to misunderstand and misuse. People could easily mistake it for applying > to the firmware execution environment. > > UINT32 and UINT64 are not affected by this ambiguity. > > Optimally, given that the build utilities target a hosted C runtime, > they should use standard C types, such as "unsigned int", or e.g. > "uint32_t". Together with standard C macros expressing limits, such as > UINT_MAX (from ) and UINT32_MAX (from ). > > Clearly no-one has capacity to clean up BaseTools like this. For > starters, we should at least remove whatever actively causes confusion. > > Thanks, > Laszlo > > > On Mon, Dec 3, 2018 at 5:08 AM Laszlo Ersek wrote: > > > >> On 11/30/18 23:45, Ard Biesheuvel wrote: > >>> The maximum value that can be represented by the native word size > >>> of the *target* should be irrelevant when compiling tools that > >>> run on the build *host*. So drop the definition of MAX_UINTN, now > >>> that we no longer use it. > >>> > >>> Contributed-under: TianoCore Contribution Agreement 1.1 > >>> Signed-off-by: Ard Biesheuvel > >>> Reviewed-by: Jaben Carsey > >>> --- > >>> BaseTools/Source/C/Common/CommonLib.h | 1 - > >>> 1 file changed, 1 deletion(-) > >>> > >>> diff --git a/BaseTools/Source/C/Common/CommonLib.h > >> b/BaseTools/Source/C/Common/CommonLib.h > >>> index 6930d9227b87..b1c6c00a3478 100644 > >>> --- a/BaseTools/Source/C/Common/CommonLib.h > >>> +++ b/BaseTools/Source/C/Common/CommonLib.h > >>> @@ -22,7 +22,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, > >> EITHER EXPRESS OR IMPLIED. > >>> > >>> #define MAX_LONG_FILE_PATH 500 > >>> > >>> -#define MAX_UINTN MAX_ADDRESS > >>> #define MAX_UINT64 ((UINT64)0xFFFFFFFFFFFFFFFFULL) > >>> #define MAX_UINT16 ((UINT16)0xFFFF) > >>> #define MAX_UINT8 ((UINT8)0xFF) > >>> > >> > >> Reviewed-by: Laszlo Ersek > >> _______________________________________________ > >> edk2-devel mailing list > >> edk2-devel@lists.01.org > >> https://lists.01.org/mailman/listinfo/edk2-devel > >> > > > >