|
161 | 161 | (re.compile(r'\bSTRUCT_GROUP\('), r'\1'), |
162 | 162 | ] |
163 | 163 |
|
| 164 | +# |
| 165 | +# Transforms for function prototypes |
| 166 | +# |
| 167 | +function_xforms = [ |
| 168 | + (r"^static +", "", 0), |
| 169 | + (r"^extern +", "", 0), |
| 170 | + (r"^asmlinkage +", "", 0), |
| 171 | + (r"^inline +", "", 0), |
| 172 | + (r"^__inline__ +", "", 0), |
| 173 | + (r"^__inline +", "", 0), |
| 174 | + (r"^__always_inline +", "", 0), |
| 175 | + (r"^noinline +", "", 0), |
| 176 | + (r"^__FORTIFY_INLINE +", "", 0), |
| 177 | + (r"__init +", "", 0), |
| 178 | + (r"__init_or_module +", "", 0), |
| 179 | + (r"__deprecated +", "", 0), |
| 180 | + (r"__flatten +", "", 0), |
| 181 | + (r"__meminit +", "", 0), |
| 182 | + (r"__must_check +", "", 0), |
| 183 | + (r"__weak +", "", 0), |
| 184 | + (r"__sched +", "", 0), |
| 185 | + (r"_noprof", "", 0), |
| 186 | + (r"__printf\s*\(\s*\d*\s*,\s*\d*\s*\) +", "", 0), |
| 187 | + (r"__(?:re)?alloc_size\s*\(\s*\d+\s*(?:,\s*\d+\s*)?\) +", "", 0), |
| 188 | + (r"__diagnose_as\s*\(\s*\S+\s*(?:,\s*\d+\s*)*\) +", "", 0), |
| 189 | + (r"DECL_BUCKET_PARAMS\s*\(\s*(\S+)\s*,\s*(\S+)\s*\)", r"\1, \2", 0), |
| 190 | + (r"__attribute_const__ +", "", 0), |
| 191 | + (r"__attribute__\s*\(\((?:[\w\s]+(?:\([^)]*\))?\s*,?)+\)\)\s+", "", 0), |
| 192 | +] |
| 193 | + |
| 194 | + |
164 | 195 |
|
165 | 196 | # |
166 | 197 | # A little helper to get rid of excess white space |
@@ -894,49 +925,10 @@ def dump_function(self, ln, prototype): |
894 | 925 | return_type = '' |
895 | 926 | decl_type = 'function' |
896 | 927 |
|
897 | | - # Prefixes that would be removed |
898 | | - sub_prefixes = [ |
899 | | - (r"^static +", "", 0), |
900 | | - (r"^extern +", "", 0), |
901 | | - (r"^asmlinkage +", "", 0), |
902 | | - (r"^inline +", "", 0), |
903 | | - (r"^__inline__ +", "", 0), |
904 | | - (r"^__inline +", "", 0), |
905 | | - (r"^__always_inline +", "", 0), |
906 | | - (r"^noinline +", "", 0), |
907 | | - (r"^__FORTIFY_INLINE +", "", 0), |
908 | | - (r"__init +", "", 0), |
909 | | - (r"__init_or_module +", "", 0), |
910 | | - (r"__deprecated +", "", 0), |
911 | | - (r"__flatten +", "", 0), |
912 | | - (r"__meminit +", "", 0), |
913 | | - (r"__must_check +", "", 0), |
914 | | - (r"__weak +", "", 0), |
915 | | - (r"__sched +", "", 0), |
916 | | - (r"_noprof", "", 0), |
917 | | - (r"__printf\s*\(\s*\d*\s*,\s*\d*\s*\) +", "", 0), |
918 | | - (r"__(?:re)?alloc_size\s*\(\s*\d+\s*(?:,\s*\d+\s*)?\) +", "", 0), |
919 | | - (r"__diagnose_as\s*\(\s*\S+\s*(?:,\s*\d+\s*)*\) +", "", 0), |
920 | | - (r"DECL_BUCKET_PARAMS\s*\(\s*(\S+)\s*,\s*(\S+)\s*\)", r"\1, \2", 0), |
921 | | - (r"__attribute_const__ +", "", 0), |
922 | | - |
923 | | - # It seems that Python support for re.X is broken: |
924 | | - # At least for me (Python 3.13), this didn't work |
925 | | -# (r""" |
926 | | -# __attribute__\s*\(\( |
927 | | -# (?: |
928 | | -# [\w\s]+ # attribute name |
929 | | -# (?:\([^)]*\))? # attribute arguments |
930 | | -# \s*,? # optional comma at the end |
931 | | -# )+ |
932 | | -# \)\)\s+ |
933 | | -# """, "", re.X), |
934 | | - |
935 | | - # So, remove whitespaces and comments from it |
936 | | - (r"__attribute__\s*\(\((?:[\w\s]+(?:\([^)]*\))?\s*,?)+\)\)\s+", "", 0), |
937 | | - ] |
938 | | - |
939 | | - for search, sub, flags in sub_prefixes: |
| 928 | + # |
| 929 | + # Apply the initial transformations. |
| 930 | + # |
| 931 | + for search, sub, flags in function_xforms: |
940 | 932 | prototype = KernRe(search, flags).sub(sub, prototype) |
941 | 933 |
|
942 | 934 | # Macros are a special case, as they change the prototype format |
|
0 commit comments