diff options
| author | David Xu <davidxu@FreeBSD.org> | 2005-05-06 07:37:01 +0000 |
|---|---|---|
| committer | David Xu <davidxu@FreeBSD.org> | 2005-05-06 07:37:01 +0000 |
| commit | 0fa2f943161d778564757470e050259c66cd256c (patch) | |
| tree | 8789a630d24784bf05ab9999d13d859e0efbdc30 /lib/libc | |
| parent | fd94099ec208321d81b8e997b185156b9af828d4 (diff) | |
Notes
Diffstat (limited to 'lib/libc')
| -rw-r--r-- | lib/libc/gmon/mcount.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libc/gmon/mcount.c b/lib/libc/gmon/mcount.c index d4faba21788a..b3b561c285e8 100644 --- a/lib/libc/gmon/mcount.c +++ b/lib/libc/gmon/mcount.c @@ -49,6 +49,7 @@ void btrap(void); void eintr(void); void user(void); #endif +#include <machine/atomic.h> /* * mcount is called on entry to each function compiled with the profiling @@ -92,7 +93,8 @@ _MCOUNT_DECL(uintfptr_t frompc, uintfptr_t selfpc) #ifdef _KERNEL MCOUNT_ENTER(s); #else - p->state = GMON_PROF_BUSY; + if (!atomic_cmpset_acq_int(&p->state, GMON_PROF_ON, GMON_PROF_BUSY)) + return; #endif frompci = frompc - p->lowpc; @@ -260,11 +262,11 @@ done: #ifdef _KERNEL MCOUNT_EXIT(s); #else - p->state = GMON_PROF_ON; + atomic_store_rel_int(&p->state, GMON_PROF_ON); #endif return; overflow: - p->state = GMON_PROF_ERROR; + atomic_store_rel_int(&p->state, GMON_PROF_ERROR); #ifdef _KERNEL MCOUNT_EXIT(s); #endif |
