From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7800) id 3E45C3858D28; Wed, 30 Nov 2022 02:10:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3E45C3858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669774222; bh=QmoWSwOrWplLDvDxCgLrbZ1da2CT13+qOfQ1IsGNWmU=; h=From:To:Subject:Date:From; b=JRzhSt69jgJInve1Ym2GbRGthCBnfiCGl+HnScfjLl1eXGBRtxZgYIzj2KFhUu+9O IrG2NeJ71Vilj0xsIqEF07QGz9bq/kF3ACH00CvPcKf3EEt8gTC/a0HYE93NRjVVLP ed0BywFN/hCr5Tue5HSQy6SmJnOiNKvBzcZGNu3k= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Vineet Gupta To: glibc-cvs@sourceware.org Subject: [glibc] scripts: Add "|" operator support to glibcpp's parsing X-Act-Checkin: glibc X-Git-Author: Shahab Vahedi X-Git-Refname: refs/heads/master X-Git-Oldrev: 227df6243a2b5b4d70d11772d12c02eb9cb666ca X-Git-Newrev: 987f8647e8d6206cebc613e5c162ff8b4d014d40 Message-Id: <20221130021022.3E45C3858D28@sourceware.org> Date: Wed, 30 Nov 2022 02:10:22 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=987f8647e8d6206cebc613e5c162ff8b4d014d40 commit 987f8647e8d6206cebc613e5c162ff8b4d014d40 Author: Shahab Vahedi Date: Sun Nov 27 18:38:24 2022 +0100 scripts: Add "|" operator support to glibcpp's parsing 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 Reviewed-by: Florian Weimer Signed-off-by: Shahab Vahedi Diff: --- 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