OSDN Git Service

* config/i386/profile.h: Sync with Mingw.
authorcorinna <corinna>
Mon, 14 Feb 2011 18:42:18 +0000 (18:42 +0000)
committercorinna <corinna>
Mon, 14 Feb 2011 18:42:18 +0000 (18:42 +0000)
winsup/cygwin/ChangeLog
winsup/cygwin/config/i386/profile.h

index afd9cd1..92f2715 100644 (file)
@@ -1,3 +1,7 @@
+2011-02-14  Corinna Vinschen  <corinna@vinschen.de>
+
+       * config/i386/profile.h: Sync with Mingw.
+
 2011-02-13  Corinna Vinschen  <corinna@vinschen.de>
 
        * path.cc (struct _FAST_CWD): Redefine to new layout used since patch
index 748b89a..d1de0f9 100644 (file)
  *     @(#)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");                               \
 }
-