From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0F4DC77B78 for ; Wed, 3 May 2023 20:14:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230169AbjECUOp (ORCPT ); Wed, 3 May 2023 16:14:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230156AbjECUOg (ORCPT ); Wed, 3 May 2023 16:14:36 -0400 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 846B58A62 for ; Wed, 3 May 2023 13:13:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1683144808; bh=40ZXckww7AYtcV479k70ydFlE0zo0yVWPM2kmuXq4GE=; h=From:To:Cc:Subject:Date:From; b=iWQhduDV2eR1p8Thl+BMwPzCkIwdsiO/5RLyy8ywDEU3r6f16RUbK/SQUaD/8xsdL 3OVqXh1KHJm0i2fCxTimnKBAcpcDrQMNByvpRV7eOP5l2Yybwd6Xia/HGrnYGDl3L0 iMmMYtqenUAKxh8LeUqDRp7spzSOT+ONHMNuRvtTuVRX9ucQ40zsQcK/p2lkKqq2h7 /iW+zAJ4wDCOG/bEKoPymILTMcMYk+x06S+cB1qPjcG/lUAzOw0nLM/5wMfLsDX+ZM w6co6Xh+3+g1i784LVhFGB7QlwV/xHSl2imfTDobzxaEN3RqOmVVCJ8KXsPyxWUflS XdCyV2qe+sO9w== Received: from localhost.localdomain (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4QBSnN4dzBz11hs; Wed, 3 May 2023 16:13:28 -0400 (EDT) From: Mathieu Desnoyers To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers Subject: [RFC PATCH 1/3] selftests/rseq: Implement rseq_unqual_scalar_typeof Date: Wed, 3 May 2023 16:13:22 -0400 Message-Id: <20230503201324.1587003-1-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) \ + ) \ + ) +#endif + #endif /* RSEQ_COMPILER_H_ */ -- 2.25.1