* profile/profile.h (_MCOUNT_CALL): Define as regparm(2)

(_MCOUNT_DECL): Use it.
	(MCOUNT): Save and restore eax, ecx, edx registers.
	* profile/mcount.c (_mcount): ANSI-fy.
This commit is contained in:
Danny Smith 2005-06-16 12:14:21 +00:00
parent dcd6cb4308
commit 842db59275
3 changed files with 32 additions and 8 deletions

View File

@ -1,3 +1,10 @@
2005-06-16 Danny Smith <dannysmith@users.sourceforge.net>
* profile/profile.h (_MCOUNT_CALL): Define as regparm(2)
(_MCOUNT_DECL): Use it.
(MCOUNT): Save and restore eax, ecx, edx registers.
* profile/mcount.c (_mcount): ANSI-fy.
2005-06-16 Danny Smith <dannysmith@users.sourceforge.net>
* include/_mingw.h (__MINGW_GNUC_PREREQ): Define. Use to

View File

@ -61,9 +61,8 @@ static char rcsid[] = "$OpenBSD: mcount.c,v 1.6 1997/07/23 21:11:27 kstailey Exp
* both frompcindex and frompc. Any reasonable, modern compiler will
* perform this optimization.
*/
//_MCOUNT_DECL __P((u_long frompc, u_long selfpc));
_MCOUNT_DECL(frompc, selfpc) /* _mcount; may be static, inline, etc */
register u_long frompc, selfpc;
/* _mcount; may be static, inline, etc */
_MCOUNT_DECL (u_long frompc, u_long selfpc)
{
register u_short *frompcindex;
register struct tostruct *top, *prevtop;

View File

@ -39,27 +39,45 @@
* 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
#define _MCOUNT_DECL static inline void _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() \
{ \
u_long 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 ("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"); \
}