Skip to content

Commit e5d51a6

Browse files
brooniewilldeacon
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent d6da04b commit e5d51a6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tools/include/linux/compiler.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,10 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
190190
#define ___PASTE(a, b) a##b
191191
#define __PASTE(a, b) ___PASTE(a, b)
192192

193+
#ifndef OPTIMIZER_HIDE_VAR
194+
/* Make the optimizer believe the variable can be manipulated arbitrarily. */
195+
#define OPTIMIZER_HIDE_VAR(var) \
196+
__asm__ ("" : "=r" (var) : "0" (var))
197+
#endif
198+
193199
#endif /* _TOOLS_LINUX_COMPILER_H */

0 commit comments

Comments
 (0)