aboutsummaryrefslogtreecommitdiff
path: root/sys/i386
diff options
context:
space:
mode:
Diffstat (limited to 'sys/i386')
-rw-r--r--sys/i386/i386/prof_machdep.c26
-rw-r--r--sys/i386/include/profile.h4
2 files changed, 24 insertions, 6 deletions
diff --git a/sys/i386/i386/prof_machdep.c b/sys/i386/i386/prof_machdep.c
index a6b4a9a24e56..9c71f49f14fe 100644
--- a/sys/i386/i386/prof_machdep.c
+++ b/sys/i386/i386/prof_machdep.c
@@ -67,6 +67,20 @@ static int cputime_prof_active;
#endif /* GUPROF */
#ifdef __GNUCLIKE_ASM
+#if defined(SMP) && defined(GUPROF)
+#define MPLOCK " \n\
+ movl $1,%edx \n\
+9: \n\
+ xorl %eax,%eax \n\
+ lock \n\
+ cmpxchgl %edx,mcount_lock \n\
+ jne 9b \n"
+#define MPUNLOCK "movl $0,mcount_lock \n"
+#else /* !(SMP && GUPROF) */
+#define MPLOCK
+#define MPUNLOCK
+#endif /* SMP && GUPROF */
+
__asm(" \n\
GM_STATE = 0 \n\
GMON_PROF_OFF = 3 \n\
@@ -110,8 +124,10 @@ __mcount: \n\
pushfl \n\
pushl %eax \n\
pushl %edx \n\
- cli \n\
- call mcount \n\
+ cli \n"
+ MPLOCK " \n\
+ call mcount \n"
+ MPUNLOCK " \n\
addl $8,%esp \n\
popfl \n\
.mcount_exit: \n\
@@ -155,8 +171,10 @@ GMON_PROF_HIRES = 4 \n\
movl 8(%esp),%eax \n\
pushfl \n\
pushl %eax \n\
- cli \n\
- call mexitcount \n\
+ cli \n"
+ MPLOCK " \n\
+ call mexitcount \n"
+ MPUNLOCK " \n\
addl $4,%esp \n\
popfl \n\
popl %eax \n\
diff --git a/sys/i386/include/profile.h b/sys/i386/include/profile.h
index 78b55a4463e1..665d5ab0ce72 100644
--- a/sys/i386/include/profile.h
+++ b/sys/i386/include/profile.h
@@ -64,11 +64,11 @@
__asm __volatile("pushl %0; call __mcount; popl %%ecx" \
: \
: "i" (label) \
- : "ax", "dx", "cx", "memory")
+ : "cx", "memory")
#define MEXITCOUNT_OVERHEAD() \
__asm __volatile("call .mexitcount; 1:" \
: : \
- : "ax", "dx", "cx", "memory")
+ : "cx", "memory")
#define MEXITCOUNT_OVERHEAD_GETLABEL(labelp) \
__asm __volatile("movl $1b,%0" : "=rm" (labelp))
#else