Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Smith <dannysmith@users.sourceforge.net>2005-06-16 16:14:21 +0400
committerDanny Smith <dannysmith@users.sourceforge.net>2005-06-16 16:14:21 +0400
commit842db592751e121068a3676817c54dd5b229dc56 (patch)
treea3406ad7b73550446130a0ca5fa557a359402ad0
parentdcd6cb4308703ef1ed82d90466e31e5d3aff1994 (diff)
* 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.
-rw-r--r--winsup/mingw/ChangeLog7
-rw-r--r--winsup/mingw/profile/mcount.c5
-rw-r--r--winsup/mingw/profile/profile.h28
3 files changed, 32 insertions, 8 deletions
diff --git a/winsup/mingw/ChangeLog b/winsup/mingw/ChangeLog
index 9aeb29278..a2e6eefb9 100644
--- a/winsup/mingw/ChangeLog
+++ b/winsup/mingw/ChangeLog
@@ -1,5 +1,12 @@
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
guard __MINGW_ATTRIB macro definitions.
* include/math.h (logb[fl]): Don't define inlines for
diff --git a/winsup/mingw/profile/mcount.c b/winsup/mingw/profile/mcount.c
index 296f8c891..9f1736d3b 100644
--- a/winsup/mingw/profile/mcount.c
+++ b/winsup/mingw/profile/mcount.c
@@ -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;
diff --git a/winsup/mingw/profile/profile.h b/winsup/mingw/profile/profile.h
index 6c198d742..d1de0f98e 100644
--- a/winsup/mingw/profile/profile.h
+++ b/winsup/mingw/profile/profile.h
@@ -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"); \
}
-