xref: /freebsd/lib/libthr/thread/thr_event.c (revision f8bbbce458194ff4312c610d32a64ff4a3a71d45)
15e53a4f9SPedro F. Giffuni /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
35e53a4f9SPedro F. Giffuni  *
44faae5e9SDavid Xu  * Copyright (c) 2005 David Xu
54faae5e9SDavid Xu  * All rights reserved.
64faae5e9SDavid Xu  *
74faae5e9SDavid Xu  * Redistribution and use in source and binary forms, with or without
84faae5e9SDavid Xu  * modification, are permitted provided that the following conditions
94faae5e9SDavid Xu  * are met:
104faae5e9SDavid Xu  * 1. Redistributions of source code must retain the above copyright
114faae5e9SDavid Xu  *    notice, this list of conditions and the following disclaimer.
124faae5e9SDavid Xu  * 2. Neither the name of the author nor the names of any co-contributors
134faae5e9SDavid Xu  *    may be used to endorse or promote products derived from this software
144faae5e9SDavid Xu  *    without specific prior written permission.
154faae5e9SDavid Xu  *
164faae5e9SDavid Xu  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
174faae5e9SDavid Xu  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
184faae5e9SDavid Xu  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
194faae5e9SDavid Xu  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
204faae5e9SDavid Xu  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
214faae5e9SDavid Xu  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
224faae5e9SDavid Xu  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
234faae5e9SDavid Xu  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
244faae5e9SDavid Xu  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
254faae5e9SDavid Xu  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
264faae5e9SDavid Xu  * SUCH DAMAGE.
274faae5e9SDavid Xu  */
284faae5e9SDavid Xu 
294faae5e9SDavid Xu #include "thr_private.h"
304faae5e9SDavid Xu 
314faae5e9SDavid Xu void
_thread_bp_create(void)324faae5e9SDavid Xu _thread_bp_create(void)
334faae5e9SDavid Xu {
344faae5e9SDavid Xu }
354faae5e9SDavid Xu 
364faae5e9SDavid Xu void
_thread_bp_death(void)374faae5e9SDavid Xu _thread_bp_death(void)
384faae5e9SDavid Xu {
394faae5e9SDavid Xu }
404faae5e9SDavid Xu 
414faae5e9SDavid Xu void
_thr_report_creation(struct pthread * curthread,struct pthread * newthread)424faae5e9SDavid Xu _thr_report_creation(struct pthread *curthread, struct pthread *newthread)
434faae5e9SDavid Xu {
444faae5e9SDavid Xu 	curthread->event_buf.event = TD_CREATE;
4503fad2adSMarcel Moolenaar 	curthread->event_buf.th_p = (uintptr_t)newthread;
464faae5e9SDavid Xu 	curthread->event_buf.data = 0;
47bddd24cdSDavid Xu 	THR_UMUTEX_LOCK(curthread, &_thr_event_lock);
484faae5e9SDavid Xu 	_thread_last_event = curthread;
494faae5e9SDavid Xu 	_thread_bp_create();
504faae5e9SDavid Xu 	_thread_last_event = NULL;
51bddd24cdSDavid Xu 	THR_UMUTEX_UNLOCK(curthread, &_thr_event_lock);
524faae5e9SDavid Xu }
534faae5e9SDavid Xu 
544faae5e9SDavid Xu void
_thr_report_death(struct pthread * curthread)554faae5e9SDavid Xu _thr_report_death(struct pthread *curthread)
564faae5e9SDavid Xu {
574faae5e9SDavid Xu 	curthread->event_buf.event = TD_DEATH;
5803fad2adSMarcel Moolenaar 	curthread->event_buf.th_p = (uintptr_t)curthread;
594faae5e9SDavid Xu 	curthread->event_buf.data = 0;
60bddd24cdSDavid Xu 	THR_UMUTEX_LOCK(curthread, &_thr_event_lock);
614faae5e9SDavid Xu 	_thread_last_event = curthread;
624faae5e9SDavid Xu 	_thread_bp_death();
634faae5e9SDavid Xu 	_thread_last_event = NULL;
64bddd24cdSDavid Xu 	THR_UMUTEX_UNLOCK(curthread, &_thr_event_lock);
654faae5e9SDavid Xu }
66