]>
Commit | Line | Data |
---|---|---|
f2144b78 SP |
1 | #!/usr/bin/python3 |
2 | # VCSToChangeLog Quirks for the GNU C Library. | |
3 | ||
d614a753 | 4 | # Copyright (C) 2019-2020 Free Software Foundation, Inc. |
f2144b78 SP |
5 | # |
6 | # The GNU C Library is free software; you can redistribute it and/or | |
7 | # modify it under the terms of the GNU Lesser General Public | |
8 | # License as published by the Free Software Foundation; either | |
9 | # version 2.1 of the License, or (at your option) any later version. | |
10 | # | |
11 | # The GNU C Library is distributed in the hope that it will be useful, | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | # Lesser General Public License for more details. | |
15 | # | |
16 | # You should have received a copy of the GNU Lesser General Public | |
17 | # License along with the GNU C Library; if not, see | |
18 | # <http://www.gnu.org/licenses/>. | |
19 | ||
20 | from frontend_c import Frontend | |
21 | from vcs_to_changelog import ProjectQuirks | |
22 | import re | |
23 | ||
24 | class GlibcProjectQuirks(ProjectQuirks): | |
25 | repo = 'git' | |
26 | ||
27 | IGNORE_LIST = [ | |
28 | 'ChangeLog', | |
29 | 'sysdeps/x86_64/dl-trampoline.h' | |
30 | ] | |
31 | ||
32 | MACRO_QUIRKS = \ | |
33 | [{'orig': r'ElfW\((\w+)\)', 'sub': r'\1__ELF_NATIVE_CLASS_t'}, | |
34 | {'orig': r'(libc_freeres_fn)\s*\((\w+)\)', 'sub': r'static void \1__\2 (void)'}, | |
35 | {'orig': r'(IMPL)\s*\((\w+), .*\)$', 'sub': r'static void \1__\2 (void) {}'}, | |
36 | {'orig': r'__(BEGIN|END)_DECLS', 'sub': r''}, | |
37 | {'orig': 'weak_function', 'sub': '__attribute__ ((weak))'}, | |
38 | {'orig': r'ATTRIBUTE_(CONST|MALLOC|PURE|FORMAT)', | |
39 | 'sub': r'__attribute__ ((\1))'}, | |
40 | {'orig': r'__THROW', 'sub': r'__attribute__ ((__nothrow__ __LEAF))'}, | |
41 | {'orig': r'__THROWNL', 'sub': r'__attribute__ ((__nothrow__))'}, | |
42 | {'orig': r'([^_])attribute_(\w+)', 'sub': r'\1__attribute__ ((\2))'}, | |
43 | {'orig': r'^attribute_(\w+)', 'sub': r'__attribute__ ((\1))'}] | |
44 | ||
45 | def __init__(self, debug): | |
46 | self.debug = debug | |
47 | ''' Build a list of macro calls used for symbol versioning and attributes. | |
48 | ||
49 | glibc uses a set of macro calls that do not end with a semi-colon and hence | |
50 | breaks our parser. Identify those calls from include/libc-symbols.h and | |
51 | filter them out. | |
52 | ''' | |
53 | with open('include/libc-symbols.h') as macrofile: | |
54 | op = macrofile.readlines() | |
55 | op = Frontend.remove_comments(self, op) | |
56 | self.C_MACROS = [re.sub(r'.*define (\w+).*', r'\1', x[:-1]) for x in op \ | |
57 | if 'define ' in x] | |
58 | ||
59 | super().__init__() | |
60 | ||
61 | def get_project_quirks(debug): | |
62 | ''' Accessor function. | |
63 | ''' | |
64 | return GlibcProjectQuirks(debug) |