summaryrefslogtreecommitdiff
path: root/tools/include/linux
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2023-07-28 00:26:13 +0100
committerWill Deacon <will@kernel.org>2023-08-04 17:36:52 +0100
commite5d51a6650211baf38daa894d06c47748978e141 (patch)
tree1e4e5f6f6a7c2062a2f2dac2183b6c9b897c1113 /tools/include/linux
parentd6da04b6fbabf4b464bfe29e34ff10c62024d1e4 (diff)
tools compiler.h: Add OPTIMIZER_HIDE_VAR()
Port over the definition of OPTIMIZER_HIDE_VAR() so we can use it in kselftests. Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20230728-arm64-signal-memcpy-fix-v4-2-0c1290db5d46@kernel.org Signed-off-by: Will Deacon <will@kernel.org>
Diffstat (limited to 'tools/include/linux')
-rw-r--r--tools/include/linux/compiler.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h
index 9d36c8ce1fe7..f75cced41d59 100644
--- a/tools/include/linux/compiler.h
+++ b/tools/include/linux/compiler.h
@@ -190,4 +190,10 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
#define ___PASTE(a, b) a##b
#define __PASTE(a, b) ___PASTE(a, b)
+#ifndef OPTIMIZER_HIDE_VAR
+/* Make the optimizer believe the variable can be manipulated arbitrarily. */
+#define OPTIMIZER_HIDE_VAR(var) \
+ __asm__ ("" : "=r" (var) : "0" (var))
+#endif
+
#endif /* _TOOLS_LINUX_COMPILER_H */