]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
scripts: Add "|" operator support to glibcpp's parsing
authorShahab Vahedi <shahab@synopsys.com>
Sun, 27 Nov 2022 17:38:24 +0000 (18:38 +0100)
committerVineet Gupta <vineet.gupta@linux.dev>
Tue, 29 Nov 2022 22:33:56 +0000 (14:33 -0800)
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 <module>
      import glibcelf
    File "/src/glibc/scripts/glibcelf.py", line 226, in <module>
      _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 <fweimer@redhat.com>
Signed-off-by: Shahab Vahedi <shahab@synopsys.com>
scripts/glibcpp.py
support/tst-glibcpp.py

index 455459a609eab1203a091b77fec75538c62f6cb3..2f39979894e35111a05e571b360f5c0d20d47914 100644 (file)
@@ -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.
index a2db1916ccfce3c30675ea1a2c886c173156a54f..cca8bd6c448228ec7dda9cbdf4a1a729421956b8 100644 (file)
@@ -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