From patchwork Sun Nov 27 17:38:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shahab Vahedi X-Patchwork-Id: 61131 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6982138532C7 for ; Sun, 27 Nov 2022 17:40:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6982138532C7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669570827; bh=twkXLuXpGi9lPSb69jVVJQor4U+M89o04NzMdTQ13L4=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=bVISb+6XUD+NDsnIL5vDJ6rfe9uyzfb8kel2z+MaYveSS6usy5jfnaTWI8ldHhc14 ix/ofXd8DC3dmRLNnCcYPbhxcPn6nceKpk60cXi7LWpqgRhPovcTpWfKB2UnvxnOvD KmPRiStZ6f+AqOKlYgKdJVVwV3V2DW4N6j/zgLjQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mx0a-00230701.pphosted.com (mx0a-00230701.pphosted.com [148.163.156.19]) by sourceware.org (Postfix) with ESMTPS id CE9633858C83 for ; Sun, 27 Nov 2022 17:40:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CE9633858C83 Received: from pps.filterd (m0098571.ppops.net [127.0.0.1]) by mx0a-00230701.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AR3HE4k000524; Sun, 27 Nov 2022 09:39:59 -0800 Received: from smtprelay-out1.synopsys.com (smtprelay-out1.synopsys.com [149.117.87.133]) by mx0a-00230701.pphosted.com (PPS) with ESMTPS id 3m3jpt3f6d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 27 Nov 2022 09:39:59 -0800 Received: from mailhost.synopsys.com (mdc-mailhost2.synopsys.com [10.225.0.210]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client CN "mailhost.synopsys.com", Issuer "SNPSica2" (verified OK)) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id D6AD5C00FD; Sun, 27 Nov 2022 17:39:56 +0000 (UTC) Received: from atlantis.internal.synopsys.com (unknown [10.225.29.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client did not present a certificate) by mailhost.synopsys.com (Postfix) with ESMTPSA id B2280A005E; Sun, 27 Nov 2022 17:39:54 +0000 (UTC) X-SNPS-Relay: synopsys.com To: libc-alpha@sourceware.org Cc: Shahab Vahedi , Florian Weimer , Claudiu Zissulescu , arcml Subject: [PATCH v3 1/2] scripts: Add "|" operator support to glibcpp's parsing Date: Sun, 27 Nov 2022 18:38:24 +0100 Message-Id: <20221127173825.3106-2-shahab@synopsys.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221127173825.3106-1-shahab@synopsys.com> References: <20221118131542.23188-1-shahab@synopsys.com> <20221127173825.3106-1-shahab@synopsys.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: Rb-JVnB1tyM7jcOck2Umr2G_CPqWknQT X-Proofpoint-GUID: Rb-JVnB1tyM7jcOck2Umr2G_CPqWknQT X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-27_08,2022-11-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_active_cloned_notspam policy=outbound_active_cloned score=0 lowpriorityscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 spamscore=0 adultscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211270147 X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Shahab Vahedi via Libc-alpha From: Shahab Vahedi Reply-To: Shahab Vahedi Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" From the tests point of view, this is a necessary step for another patch [1] and allows parsing macros such as "#define A | B". Without it, a few tests [2] choke when the other patch [1] is applied: /src/glibc/scripts/../elf/elf.h:4167: error: uninterpretable macro token sequence: ( EF_ARC_MACH_MSK | EF_ARC_OSABI_MSK ) Traceback (most recent call last): File "/src/glibc/elf/tst-glibcelf.py", line 23, in import glibcelf File "/src/glibc/scripts/glibcelf.py", line 226, in _elf_h = _parse_elf_h() ^^^^^^^^^^^^^^ File "/src/glibc/scripts/glibcelf.py", line 223, in _parse_elf_h raise IOError('parse error in elf.h') OSError: parse error in elf.h [1] ARC: update definitions in elf/elf.h https://sourceware.org/pipermail/libc-alpha/2022-November/143503.html [2] tst-glibcelf, tst-relro-ldso, and tst-relro-libc Signed-off-by: Shahab Vahedi Reviewed-by: Florian Weimer --- scripts/glibcpp.py | 1 + support/tst-glibcpp.py | 1 + 2 files changed, 2 insertions(+) diff --git a/scripts/glibcpp.py b/scripts/glibcpp.py index 455459a609..2f39979894 100644 --- a/scripts/glibcpp.py +++ b/scripts/glibcpp.py @@ -346,6 +346,7 @@ RE_SPLIT_INTEGER_SUFFIX = re.compile(r'([^ullULL]+)([ullULL]*)') BINARY_OPERATORS = { '+': operator.add, '<<': operator.lshift, + '|': operator.or_, } # Use the general-purpose dict type if it is order-preserving. diff --git a/support/tst-glibcpp.py b/support/tst-glibcpp.py index a2db1916cc..cca8bd6c44 100644 --- a/support/tst-glibcpp.py +++ b/support/tst-glibcpp.py @@ -131,6 +131,7 @@ check_macro_eval('#define A 1', {'A': 1}) check_macro_eval('#define A (1)', {'A': 1}) check_macro_eval('#define A (1 + 1)', {'A': 2}) check_macro_eval('#define A (1U << 31)', {'A': 1 << 31}) +check_macro_eval('#define A (1 | 2)', {'A': 1 | 2}) check_macro_eval('''\ #define A (B + 1) #define B 10