Skip to content

Commit

Permalink
clang: workaround for generated constants
Browse files Browse the repository at this point in the history
KBuild abuses the asm statement to write to a file and
clang chokes about these invalid asm statements. Hack it
even more by fooling this is actual valid asm code.

cc: Masahiro Yamada <[email protected]>
cc: Tom Rini <[email protected]>
Signed-off-by: Jeroen Hofstee <[email protected]>
  • Loading branch information
jhofstee authored and albert-aribaud-u-boot committed Sep 9, 2014
1 parent f2cbb03 commit fe5d1ab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ targets += arch/$(ARCH)/lib/asm-offsets.s

# Default sed regexp - multiline due to syntax constraints
define sed-y
"/^->/{s:->#\(.*\):/* \1 */:; \
"s:[[:space:]]*\.ascii[[:space:]]*\"\(.*\)\":\1:; \
/^->/{s:->#\(.*\):/* \1 */:; \
s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
s:->::; p;}"
Expand Down
6 changes: 3 additions & 3 deletions include/linux/kbuild.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
#define __LINUX_KBUILD_H

#define DEFINE(sym, val) \
asm volatile("\n->" #sym " %0 " #val : : "i" (val))
asm volatile("\n.ascii \"->" #sym " %0 " #val "\"" : : "i" (val))

#define BLANK() asm volatile("\n->" : : )
#define BLANK() asm volatile("\n.ascii \"->\"" : : )

#define OFFSET(sym, str, mem) \
DEFINE(sym, offsetof(struct str, mem))

#define COMMENT(x) \
asm volatile("\n->#" x)
asm volatile("\n.ascii \"->#" x "\"")

#endif

0 comments on commit fe5d1ab

Please sign in to comment.