Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6530449ybi; Wed, 29 May 2019 09:07:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqz9wv2nq+c3goVTkSJMCpJzWQHaLTJwM03rV1NMzzV6wYU+ah5q8OeUr6WVvqdSje01ync7 X-Received: by 2002:a17:902:b18f:: with SMTP id s15mr6301241plr.44.1559146076483; Wed, 29 May 2019 09:07:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559146076; cv=none; d=google.com; s=arc-20160816; b=yNLdV1Jmw3VrKRV0E1iewYjT27z7yrG9DBVlIj0QnAd5BEmcHt1hDKoR0hV/GTzyo/ BrBJcrU6Gzf4DBUatIUsAJiG8OcpxPxl0xgWoA6w2O4gosMtGA0GIS5Ei4CDOPniNnk6 2qNiT/FImUgC+Kr7/8POJy91uWRH5AfZXvU2sp0BomAi3+QrxwOSURL+XexqU6eHROAc N/gyZVJCOFO88Z4k+jPeQ4lULVjARL4c6a/AgyADY+icprNmJc3hfcBT8HpsebxHUAbP gvZqI7oMc14rFwlnctF/ot+tVz9KO6Tks8NunzaiF3yvciiRFxvH6rIbByiQSgkTXF+y IyOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-disposition:mime-version:user-agent:in-reply-to:references :subject:cc:to:from:message-id:date; bh=tyQcrBQtIQyJ9HSq6ALR4G5yOIGs7wVj3RTtMLj5yc4=; b=q8zeLf1miST4L78ip0W/pCCHUuae6EL9yVdXBBZflb10FBhszLHRnaZw07IyY+DGlk pdYyCXUhRWHoSswMfMn0YG/w0VmjIuSYJrymmREChO8tsnMYJ8bOQksyZiv1nKOMoY/u omxlXzYqRxiBVp1GE9hFzjiB2UU4IC5LQxwcHQbKsExXh35yq/YQlQQYL74wgOqiiyAF zsBaKFgg52Vac8CazpBk8M8zkqU4+s3OsJzjOOdSQfgm9oWnxFuwc8y9Gyf+i02yGxI+ gxY8+S5aAE4X/XKQSp507Zd7JDpuiSyO/w2u1y7EmaeY2UOo4L8187P6rThHLHzlEoBD voDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c142si28517192pfc.194.2019.05.29.09.07.36; Wed, 29 May 2019 09:07:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726118AbfE2QHe convert rfc822-to-8bit (ORCPT + 99 others); Wed, 29 May 2019 12:07:34 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:23747 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726062AbfE2QHe (ORCPT ); Wed, 29 May 2019 12:07:34 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 45DbFw05xMz9tyRL; Wed, 29 May 2019 18:07:32 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id T_NoBVU2oEcz; Wed, 29 May 2019 18:07:31 +0200 (CEST) Received: from vm-hermes.si.c-s.fr (vm-hermes.si.c-s.fr [192.168.25.253]) by pegase1.c-s.fr (Postfix) with ESMTP id 45DbFv6Lrkz9tyRF; Wed, 29 May 2019 18:07:31 +0200 (CEST) Received: by vm-hermes.si.c-s.fr (Postfix, from userid 33) id A00D183C; Wed, 29 May 2019 18:07:31 +0200 (CEST) Received: from 37.170.135.142 ([37.170.135.142]) by messagerie.si.c-s.fr (Horde Framework) with HTTP; Wed, 29 May 2019 18:07:31 +0200 Date: Wed, 29 May 2019 18:07:31 +0200 Message-ID: <20190529180731.Horde.NGHeOXuCgw23pVdGqjc0fw9@messagerie.si.c-s.fr> From: Christophe Leroy To: Pascal Van Leeuwen Cc: linux-crypto@vger.kernel.org, Ard Biesheuvel Subject: Re: Conding style question regarding configuration References: In-Reply-To: User-Agent: Internet Messaging Program (IMP) H5 (6.2.3) Content-Type: text/plain; charset=UTF-8; format=flowed; DelSp=Yes MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: 8BIT Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Pascal Van Leeuwen a écrit : >> > Quick question regarding how to configure out code depending on a >> CONFIG_xxx >> > switch. As far as I understood so far, the proper way to do this is >> not by >> > doing an #ifdef but by using a regular if with IS_ENABLED like so: >> > >> > if (IS_ENABLED(CONFIG_PCI)) { >> > } >> > >> > Such that the compiler can still check the code even if the switch is >> > disabled. Now that all works fine and dandy for statements within a >> > function, but how do you configure out, say, global variable >> definitions >> > referencing types that are tied to this configuration switch? Or >> should >> > I just leave them in, depending on the compiler to optimize them away? >> > >> > Obviously the code depends on those variables again, so if it's not >> > done consistently the compiler will complain somehow if the switch is >> not >> > defined ... >> > >> > Also, with if (IS_ENABLED()) I cannot remove my function prototypes, >> > just the function body. Is that really how it's supposed to be done? >> > >> >> Yes. Code and data with static linkage will just be optimized away by >> the compiler if the CONFIG_xx option is not enabled, so all you need >> to guard are the actual statements, function calls etc. >> > Ok, makes sense. Then I'll just config out the relevant function bodies > and assume the compiler will do the rest ... > No need to config out function bodies when they are static. If not, it's better to group then in a C file and associate that file to the config symbol through Makefile Christophe > Thanks, > Pascal van Leeuwen > Silicon IP Architect, Multi-Protocol Engines @ Inside Secure > www.insidesecure.com