diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2011-02-14 09:42:19 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2011-02-14 09:42:19 +0000 |
commit | 4655360348c02af0f2be963fcaf23d4916ceb0dd (patch) | |
tree | 28acae7b2593359057129820a128f6a3291ecd7c /winsup/cygwin/config | |
parent | 6148be0f229913f22a8e3681320055b986ce4e83 (diff) | |
download | newlib-4655360348c02af0f2be963fcaf23d4916ceb0dd.zip newlib-4655360348c02af0f2be963fcaf23d4916ceb0dd.tar.gz newlib-4655360348c02af0f2be963fcaf23d4916ceb0dd.tar.bz2 |
* config/i386/profile.h: Sync with Mingw.
Diffstat (limited to 'winsup/cygwin/config')
-rw-r--r-- | winsup/cygwin/config/i386/profile.h | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/winsup/cygwin/config/i386/profile.h b/winsup/cygwin/config/i386/profile.h index 748b89a..d1de0f9 100644 --- a/winsup/cygwin/config/i386/profile.h +++ b/winsup/cygwin/config/i386/profile.h @@ -35,24 +35,49 @@ * @(#)profile.h 8.1 (Berkeley) 6/11/93 */ -#define _MCOUNT_DECL static inline void _mcount +/* + * This file is taken from Cygwin distribution. Please keep it in sync. + * The differences should be within __MINGW32__ guard. + */ +/* If compiler doesn't inline, at least avoid passing args on the stack. */ +#define _MCOUNT_CALL __attribute__ ((regparm (2))) +#define _MCOUNT_DECL static __inline__ void _MCOUNT_CALL _mcount + +/* FIXME: This works, but it would be cleaner to convert mcount into an + assembler stub that calls an extern _mcount. + Older versions of GCC (pre-4.1) will still fail with regparm since the + compiler used %edx to store an unneeded counter variable. */ #define MCOUNT \ void \ mcount() \ { \ - int selfpc, frompcindex; \ + u_long selfpc, frompcindex; \ + /* \ + * Save registers, since this may be called from \ + * the prologue of a regparm function. \ + */ \ + __asm __volatile__ ("pushl %eax\n\t" \ + "pushl %ecx\n\t" \ + "pushl %edx"); \ /* \ * find the return address for mcount, \ * and the return address for mcount's caller. \ * \ * selfpc = pc pushed by mcount call \ */ \ - __asm __volatile ("movl 4(%%ebp),%0" : "=r" (selfpc)); \ + /* __asm ("movl 4(%%ebp),%0" : "=r" (selfpc)); */ \ + selfpc = (u_long) __builtin_return_address (0); \ /* \ * frompcindex = pc pushed by call into self. \ */ \ - __asm __volatile ("movl (%%ebp),%0;movl 4(%0),%0" : "=r" (frompcindex));\ + /* __asm ("movl (%%ebp),%0;movl 4(%0),%0" : "=r" (frompcindex)); */ \ + frompcindex = (u_long) __builtin_return_address (1); \ _mcount(frompcindex, selfpc); \ + /* \ + * Restore registers. \ + */ \ + __asm __volatile__ ("popl %edx\n\t" \ + "popl %ecx\n\t" \ + "popl %eax"); \ } - |