]> sourceware.org Git - newlib-cygwin.git/commitdiff
* profile/profile.h (_MCOUNT_CALL): Define as regparm(2)
authorDanny Smith <dannysmith@users.sourceforge.net>
Thu, 16 Jun 2005 12:14:21 +0000 (12:14 +0000)
committerDanny Smith <dannysmith@users.sourceforge.net>
Thu, 16 Jun 2005 12:14:21 +0000 (12:14 +0000)
(_MCOUNT_DECL): Use it.
(MCOUNT): Save and restore eax, ecx, edx registers.
* profile/mcount.c (_mcount): ANSI-fy.

winsup/mingw/ChangeLog
winsup/mingw/profile/mcount.c
winsup/mingw/profile/profile.h

index 9aeb29278c0ad488be98b6f553cc0f116b14a775..a2e6eefb9ae80abb2db5f5bab78032e08d0e7925 100644 (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
index 296f8c89189fa59275bc6287673bb2c7ed05d975..9f1736d3be5f2281deb69cd0539b180c039145a2 100644 (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;
index 6c198d742f05895a7fe010a807f309783fbfba4e..d1de0f98ef90fa7700b7906b87714bdc8eac64c2 100644 (file)
  * 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");                               \
 }
-
This page took 0.034572 seconds and 5 git commands to generate.