Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp101176rwr; Wed, 3 May 2023 23:21:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ407LYrcYE8aS3xbV9Y/ij8+O68bZaTU/hM4z+d2NCeTNCdpZWtEWicppN/JhA8fFCEoFF0 X-Received: by 2002:a17:902:650f:b0:1a9:95fa:1fa8 with SMTP id b15-20020a170902650f00b001a995fa1fa8mr2310164plk.41.1683181310946; Wed, 03 May 2023 23:21:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683181310; cv=none; d=google.com; s=arc-20160816; b=vNk8ZJ4yD++gu3HPNEUVC6K176eQLhAs9KJwDI9LHRMMsGKK5CsETRcfhDoPQTpjwe 3Jqlu2jFrPovS1lSrgVuSvxa9TbbESYN/DWSLh4D4P0mXeU5ATy2Obs7UPuWdt9l+i3g ShLYd4SXJn2NRJoiA9fHN1wVy1wgabHK/pJlZVO7qh3EnTVbxAe1Jc624Y/XvpDNxCdZ E3SIi3xmkV8CNEiFZ4Mxz1zGJdLxqNcB1Kto12rB9NQLacLPES4PdLiQqJgQWk2LNkP0 BOjtOtphO2vUujvbytN+Qm/3HhqOs0Ak8IEME44KI/dPZgbtEXwdck119L2iSoagrEgH hwjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=kdsR0guEY624cKUQSYsVx2bXuW3WeI6HUMgourQ1avY=; b=iEPceQu9W/1GQWBTRQr4sUhb6PIxluC4+AE3I9IX8x/nEWJ16uw5q0MDdvn+BSMeM0 TRr9l2ZcRGwMUgAB8T6a9l0DvMI0+Uyv/t94+9mnctKDfUnQH7srEtVsAoL6JK43AcoD I/XO+qyy0Mf9F9TXnAI4ng5CJLez1cEaTy1QRxMV7St82y7v/aB968u7YHWy2aqViUQj hGst0wp5RIFt3fmmvWL0MWUoWY377/K4gjKglEPA0SNYD9kRhmsuJ1TMfB0n9EuUL+SL Cf7g5Ynd5vxEDNOP8U5nV/+dbPk2VSbh/2fOfkeaOyarM4q5UVa2ZErwb3oL39Yw53M9 kodw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=FIntEoog; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f6-20020a17090274c600b001aafc6a76e1si7919786plt.69.2023.05.03.23.21.38; Wed, 03 May 2023 23:21:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=FIntEoog; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229673AbjEDGJx (ORCPT + 99 others); Thu, 4 May 2023 02:09:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229639AbjEDGJv (ORCPT ); Thu, 4 May 2023 02:09:51 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F0CB2128 for ; Wed, 3 May 2023 23:09:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=kdsR0guEY624cKUQSYsVx2bXuW3WeI6HUMgourQ1avY=; b=FIntEoogQ8rpGiMYdMEYJzhIc2 v9YCmx0tlIPF2b6lW12RSQm87qq7sw0v17FTFNuhoRhylAsesdByerA030v8EtH5NSYjUFqTh6KNE DPtf9cg4P/DUXnutvZ0uKphw5WRzJ+Sh68JQwhtfq2OBZZfahDIpDy1LyzPCGel/bb7zBjs/gCrI/ X0kXtCWDOGDjKFndW/PjFT5GkK2n43BNVLjzlikEghAgOBAxxZVtvmjDG1XfrYLPewm/MiZIAv1jp bjhC7xY+DqQkQev7dHqemAuO0ZqtnFXF/Au9WlNIHHVcubEyD4N+EZ8uniSNkRs8ajsIxYG9Iknl6 YDuvcROg==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1puS9c-00AIy0-Fz; Thu, 04 May 2023 06:09:25 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 2014D3006DA; Thu, 4 May 2023 08:09:24 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id E6AEF240701FD; Thu, 4 May 2023 08:09:23 +0200 (CEST) Date: Thu, 4 May 2023 08:09:23 +0200 From: Peter Zijlstra To: Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 1/3] selftests/rseq: Implement rseq_unqual_scalar_typeof Message-ID: <20230504060923.GB1734100@hirez.programming.kicks-ass.net> References: <20230503201324.1587003-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230503201324.1587003-1-mathieu.desnoyers@efficios.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 03, 2023 at 04:13:22PM -0400, Mathieu Desnoyers wrote: > Allow defining variables and perform cast with a typeof which removes > the volatile and const qualifiers. > > This prevents declaring a stack variable with a volatile qualifier > within a macro, which would generate sub-optimal assembler. > > This is imported from the "librseq" project. > > Signed-off-by: Mathieu Desnoyers > --- > tools/testing/selftests/rseq/compiler.h | 27 +++++++++++++++++++++++++ > 1 file changed, 27 insertions(+) > > diff --git a/tools/testing/selftests/rseq/compiler.h b/tools/testing/selftests/rseq/compiler.h > index f47092bddeba..8dc7f881e253 100644 > --- a/tools/testing/selftests/rseq/compiler.h > +++ b/tools/testing/selftests/rseq/compiler.h > @@ -33,4 +33,31 @@ > #define RSEQ_COMBINE_TOKENS(_tokena, _tokenb) \ > RSEQ__COMBINE_TOKENS(_tokena, _tokenb) > > +#ifdef __cplusplus > +#define rseq_unqual_scalar_typeof(x) \ > + std::remove_cv::type>::type > +#else > +/* > + * Use C11 _Generic to express unqualified type from expression. This removes > + * volatile qualifier from expression type. > + */ > +#define rseq_unqual_scalar_typeof(x) \ > + __typeof__( \ > + _Generic((x), \ > + char: (char)0, \ > + unsigned char: (unsigned char)0, \ > + signed char: (signed char)0, \ > + unsigned short: (unsigned short)0, \ > + signed short: (signed short)0, \ > + unsigned int: (unsigned int)0, \ > + signed int: (signed int)0, \ > + unsigned long: (unsigned long)0, \ > + signed long: (signed long)0, \ > + unsigned long long: (unsigned long long)0, \ > + signed long long: (signed long long)0, \ > + default: (x) \ > + ) \ > + ) FWIW, I like how the kernel version uses a little helper for the signed/unsigned pairs. Makes it a little more readable. > +#endif > + > #endif /* RSEQ_COMPILER_H_ */ > -- > 2.25.1 >