|
From: <sv...@va...> - 2006-05-26 11:31:23
|
Author: sewardj
Date: 2006-05-26 12:31:15 +0100 (Fri, 26 May 2006)
New Revision: 5935
Log:
Replace the obviously-bogus piece of inline asm with a probably
equally bogus new version. In fact if I actually understood the
magical "earlyclobber" (&) asm constraint this would probably be
unnecessary, but I don't. Ah well.
Modified:
trunk/coregrind/m_debuglog.c
Modified: trunk/coregrind/m_debuglog.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_debuglog.c 2006-05-26 11:29:17 UTC (rev 5934)
+++ trunk/coregrind/m_debuglog.c 2006-05-26 11:31:15 UTC (rev 5935)
@@ -98,23 +98,33 @@
}
=20
#elif defined(VGP_amd64_linux)
-
+__attribute__((noinline))
static UInt local_sys_write_stderr ( HChar* buf, Int n )
{
- UInt __res;
+ Long block[2];
+ block[0] =3D (Long)buf;
+ block[1] =3D n;
__asm__ volatile (
- "movq $1, %%rax\n" /* set %rax =3D __NR_write */
- "movq $2, %%rdi\n" /* set %rdi =3D stderr */
- "movq %1, %%rsi\n" /* set %rsi =3D buf */
- "movl %2, %%edx\n" /* set %edx =3D n */
- "syscall\n" /* write(stderr, buf, n) */
- "movl %%eax, %0\n" /* set __res =3D %eax */
- : "=3Dmr" (__res)
- : "g" (buf), "g" (n)
- : "rax", "rdi", "rsi", "rdx" );
- if (__res < 0)=20
- __res =3D -1;
- return __res;
+ "subq $256, %%rsp\n" /* don't trash the stack redzone */
+ "pushq %%r15\n" /* r15 is callee-save */
+ "movq %0, %%r15\n" /* r15 =3D &block */
+ "pushq %%r15\n" /* save &block */
+ "movq $1, %%rax\n" /* rax =3D __NR_write */
+ "movq $2, %%rdi\n" /* rdi =3D stderr */
+ "movq 0(%%r15), %%rsi\n" /* rsi =3D buf */
+ "movq 8(%%r15), %%rdx\n" /* rdx =3D n */
+ "syscall\n" /* write(stderr, buf, n) */
+ "popq %%r15\n" /* reestablish &block */
+ "movq %%rax, 0(%%r15)\n" /* block[0] =3D result */
+ "popq %%r15\n" /* restore r15 */
+ "addq $256, %%rsp\n" /* restore stack ptr */
+ : /*wr*/
+ : /*rd*/ "g" (block)
+ : /*trash*/ "rax", "rdi", "rsi", "rdx", "memory", "cc"
+ );
+ if (block[0] < 0)=20
+ block[0] =3D -1;
+ return (UInt)block[0];
}
=20
static UInt local_sys_getpid ( void )
|