PERFORCE change 74891 for review
David Xu
davidxu at FreeBSD.org
Sun Apr 10 16:06:33 PDT 2005
http://perforce.freebsd.org/chv.cgi?CH=74891
Change 74891 by davidxu at davidxu_tiger on 2005/04/10 23:05:43
Introduce SHOULD_REPORT_EVENT macro to test if we should report a
event.
call _thr_report_create for initial thread
Affected files ...
.. //depot/projects/davidxu_thread/src/lib/libthr/thread/thr_create.c#8 edit
.. //depot/projects/davidxu_thread/src/lib/libthr/thread/thr_event.c#9 edit
.. //depot/projects/davidxu_thread/src/lib/libthr/thread/thr_exit.c#6 edit
.. //depot/projects/davidxu_thread/src/lib/libthr/thread/thr_init.c#8 edit
.. //depot/projects/davidxu_thread/src/lib/libthr/thread/thr_private.h#14 edit
Differences ...
==== //depot/projects/davidxu_thread/src/lib/libthr/thread/thr_create.c#8 (text+ko) ====
@@ -158,7 +158,7 @@
_thr_link(curthread, new_thread);
/* Return thread pointer eariler so that new thread can use it. */
(*thread) = new_thread;
- if (1) {// curthread->report_events) {
+ if (SHOULD_REPORT_EVENT(curthread, TD_CREATE)) {
THR_THREAD_LOCK(curthread, new_thread);
locked = 1;
} else
==== //depot/projects/davidxu_thread/src/lib/libthr/thread/thr_event.c#9 (text+ko) ====
@@ -41,32 +41,21 @@
void
_thr_report_create(struct pthread *curthread, struct pthread *newthread)
{
- _thr_report_event(curthread, newthread, TD_CREATE, NULL);
+ THR_UMTX_LOCK(curthread, &_thr_event_lock);
+ _thread_event.event = TD_CREATE;
+ _thread_event.thread = newthread;
+ _thread_event.data = 0;
+ _thread_create_bp();
+ THR_UMTX_UNLOCK(curthread, &_thr_event_lock);
}
void
_thr_report_death(struct pthread *curthread)
{
- _thr_report_event(curthread, curthread, TD_DEATH, NULL);
-}
-
-void
-_thr_report_event(struct pthread *curthread, struct pthread *thread,
- int event, void *data)
-{
- if (!(event & (curthread->event_mask | _thread_event_mask)))
- return;
THR_UMTX_LOCK(curthread, &_thr_event_lock);
- _thread_event.event = event;
- _thread_event.thread = thread;
- _thread_event.data = data;
- switch (event) {
- case TD_CREATE:
- _thread_create_bp();
- break;
- case TD_DEATH:
- _thread_death_bp();
- break;
- }
+ _thread_event.event = TD_DEATH;
+ _thread_event.thread = curthread;
+ _thread_event.data = 0;
+ _thread_death_bp();
THR_UMTX_UNLOCK(curthread, &_thr_event_lock);
}
==== //depot/projects/davidxu_thread/src/lib/libthr/thread/thr_exit.c#6 (text+ko) ====
@@ -130,7 +130,7 @@
THREAD_LIST_UNLOCK(curthread);
if (curthread->joiner)
_thr_umtx_wake(&curthread->state, INT_MAX);
- if (__predict_false(curthread->report_events))
+ if (SHOULD_REPORT_EVENT(curthread, TD_DEATH))
_thr_report_death(curthread);
thr_exit(&curthread->tid);
PANIC("thr_exit() returned");
==== //depot/projects/davidxu_thread/src/lib/libthr/thread/thr_init.c#8 (text+ko) ====
@@ -309,6 +309,7 @@
_thr_initial = curthread;
SIGDELSET(oldset, SIGCANCEL);
__sys_sigprocmask(SIG_SETMASK, &oldset, NULL);
+ _thr_report_create(curthread, curthread);
}
}
==== //depot/projects/davidxu_thread/src/lib/libthr/thread/thr_private.h#14 (text+ko) ====
@@ -583,8 +583,11 @@
};
/* XXX this must match thread_db.h */
-#define TD_CREATE 0x0004
+#define TD_CREATE 0x0004
#define TD_DEATH 0x0008
+#define SHOULD_REPORT_EVENT(curthr, e) \
+ (curthr->report_events && \
+ (((curthr)->event_mask | _thread_event_mask ) & e) != 0)
extern int __isthreaded;
@@ -740,8 +743,6 @@
void _thr_report_create(struct pthread *curthread,
struct pthread *newthread);
void _thr_report_death(struct pthread *curthread);
-void _thr_report_event(struct pthread *curthread, struct pthread *thread,
- int event, void *data);
void _thread_create_bp(void);
void _thread_death_bp(void);
More information about the p4-projects
mailing list