Re: [LAD] [OT] assembler guru needed

From: Ross Vandegrift <ross@email-addr-hidden>
Date: Fri Sep 07 2007 - 02:26:31 EEST

On Thu, Sep 06, 2007 at 10:21:17AM -0400, Dave Phillips wrote:
> Here's the code in question :
>
> __ASM_GLOBAL_FUNC(interlocked_cmpxchg64,
> "push %ebx\n\t"
> "push %esi\n\t"
> "movl 12(%esp),%esi\n\t"
> "movl 16(%esp),%ebx\n\t"
> "movl 20(%esp),%ecx\n\t"
> "movl 24(%esp),%eax\n\t"
> "movl 28(%esp),%edx\n\t"
> "lock; cmpxchg8b (%esi)\n\t"
> "pop %esi\n\t"
> "pop %ebx\n\t"
> "ret");

According to AMD docs, on the x86-64 arch, all push/pops much be 64-bits
unless you're in legacy (32bit) mode. So you can't do this. A quick
hack removes the x86 specific version of this ASM code and falls back
on the "somewhat portable" version:

--- port.h 2007-08-10 12:18:12.000000000 -0400
+++ port.h.hack 2007-09-06 19:25:33.000000000 -0400
@@ -201,16 +201,6 @@
 
 /* Macros to define assembler functions somewhat portably */
 
-#if defined(__GNUC__) && !defined(__MINGW32__) &&
!defined(__CYGWIN__) && !defined(__APPLE__)
-# define __ASM_GLOBAL_FUNC(name,code) \
- __asm__( ".text\n\t" \
- ".align 4\n\t" \
- ".globl " __ASM_NAME(#name) "\n\t" \
- __ASM_FUNC(#name) "\n" \
- __ASM_NAME(#name) ":\n\t" \
- code \
- "\n\t.previous" );
-#else /* defined(__GNUC__) && !defined(__MINGW32__) &&
!defined(__APPLE__) */
 # define __ASM_GLOBAL_FUNC(name,code) \
       void __asm_dummy_##name(void) { \
           asm( ".align 4\n\t" \
@@ -219,8 +209,6 @@
                __ASM_NAME(#name) ":\n\t" \
                code ); \
       }
-#endif /* __GNUC__ */
-

No promises!

-- 
Ross Vandegrift
ross@email-addr-hidden
"The good Christian should beware of mathematicians, and all those who
make empty prophecies. The danger already exists that the mathematicians
have made a covenant with the devil to darken the spirit and to confine
man in the bonds of Hell."
	--St. Augustine, De Genesi ad Litteram, Book II, xviii, 37
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/mailman/listinfo.cgi/linux-audio-dev
Received on Fri Sep 7 04:15:01 2007

This archive was generated by hypermail 2.1.8 : Fri Sep 07 2007 - 04:15:01 EEST