Replace macro arguments when applying replaceTokens
replaceTokens was only replacing tokens for cpp name clashes in the
macro body. This change will also replace tokens in the arguments.
Bug: 297317502
Test: bionic/libc/kernel/tools/update_all.py
Change-Id: I102d000a8a4cea507b00c867df2a16106d8aed89
Signed-off-by: Edward Liaw <edliaw@google.com>
diff --git a/libc/kernel/tools/cpp.py b/libc/kernel/tools/cpp.py
index 40e1f26..8b2b709 100755
--- a/libc/kernel/tools/cpp.py
+++ b/libc/kernel/tools/cpp.py
@@ -1471,9 +1471,18 @@
made_change = True
i += 1
- if b.isDefine() and b.define_id in replacements:
- b.define_id = replacements[b.define_id]
- made_change = True
+ if b.isDefine():
+ tokens = CppStringTokenizer(b.define_id).tokens
+ id_change = False
+ for tok in tokens:
+ if tok.kind == TokenKind.IDENTIFIER:
+ if tok.id in replacements:
+ tok.id = replacements[tok.id]
+ id_change = True
+ if id_change:
+ b.define_id = ''.join([tok.id for tok in tokens])
+ made_change = True
+
if made_change and b.isIf():
# Keep 'expr' in sync with 'tokens'.
diff --git a/libc/kernel/uapi/linux/ioprio.h b/libc/kernel/uapi/linux/ioprio.h
index 1fbedd0..9ae9dae 100644
--- a/libc/kernel/uapi/linux/ioprio.h
+++ b/libc/kernel/uapi/linux/ioprio.h
@@ -65,6 +65,6 @@
if(IOPRIO_BAD_VALUE(__linux_class, IOPRIO_NR_CLASSES) || IOPRIO_BAD_VALUE(level, IOPRIO_NR_LEVELS) || IOPRIO_BAD_VALUE(hint, IOPRIO_NR_HINTS)) return IOPRIO_CLASS_INVALID << IOPRIO_CLASS_SHIFT;
return(__linux_class << IOPRIO_CLASS_SHIFT) | (hint << IOPRIO_HINT_SHIFT) | level;
}
-#define IOPRIO_PRIO_VALUE(class,level) ioprio_value(__linux_class, level, IOPRIO_HINT_NONE)
-#define IOPRIO_PRIO_VALUE_HINT(class,level,hint) ioprio_value(__linux_class, level, hint)
+#define IOPRIO_PRIO_VALUE(__linux_class,level) ioprio_value(__linux_class, level, IOPRIO_HINT_NONE)
+#define IOPRIO_PRIO_VALUE_HINT(__linux_class,level,hint) ioprio_value(__linux_class, level, hint)
#endif