Skip to content

Commit

Permalink
x86: string_32.h: workaround for broken gcc 4.0
Browse files Browse the repository at this point in the history
gcc 4.0 fails to allocate %eax for the pattern operand in the rep
store instructions used by memset; force it to do so by declaring a
register variable.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
  • Loading branch information
H. Peter Anvin committed May 26, 2008
1 parent 4b6011b commit 1a20d3e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion include/asm-x86/string_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,18 @@ void *__constant_c_and_count_memset(void *s, unsigned long pattern,
asm volatile("rep ; stosl" \
x \
: "=&c" (d0), "=&D" (d1) \
: "a" (pattern), "0" (count/4), "1" ((long)s) \
: "a" (eax), "0" (count/4), "1" ((long)s) \
: "memory")

{
int d0, d1;
#if __GNUC__ == 4 && __GNUC_MINOR__ == 0
/* Workaround for broken gcc 4.0 */
register unsigned long eax asm("%eax") = pattern;
#else
unsigned long eax = pattern;
#endif

switch (count % 4) {
case 0:
COMMON("");
Expand Down

0 comments on commit 1a20d3e

Please sign in to comment.