Lines Matching full:sn

193 	struct sigev_node *sn;  in __sigev_alloc()  local
195 sn = calloc(1, sizeof(*sn)); in __sigev_alloc()
196 if (sn != NULL) { in __sigev_alloc()
197 sn->sn_value = evp->sigev_value; in __sigev_alloc()
198 sn->sn_func = evp->sigev_notify_function; in __sigev_alloc()
199 sn->sn_gen = atomic_fetch_add_explicit(&sigev_generation, 1, in __sigev_alloc()
201 sn->sn_type = type; in __sigev_alloc()
202 _pthread_attr_init(&sn->sn_attr); in __sigev_alloc()
203 _pthread_attr_setdetachstate(&sn->sn_attr, PTHREAD_CREATE_DETACHED); in __sigev_alloc()
205 attrcopy(evp->sigev_notify_attributes, &sn->sn_attr); in __sigev_alloc()
210 sn->sn_tn = prev->sn_tn; in __sigev_alloc()
212 sn->sn_tn = sigev_thread_create(usedefault); in __sigev_alloc()
213 if (sn->sn_tn == NULL) { in __sigev_alloc()
214 _pthread_attr_destroy(&sn->sn_attr); in __sigev_alloc()
215 free(sn); in __sigev_alloc()
216 sn = NULL; in __sigev_alloc()
220 return (sn); in __sigev_alloc()
224 __sigev_get_sigevent(struct sigev_node *sn, struct sigevent *newevp, in __sigev_get_sigevent() argument
233 newevp->sigev_notify_thread_id = (lwpid_t)sn->sn_tn->tn_lwpid; in __sigev_get_sigevent()
238 __sigev_free(struct sigev_node *sn) in __sigev_free() argument
240 _pthread_attr_destroy(&sn->sn_attr); in __sigev_free()
241 free(sn); in __sigev_free()
247 struct sigev_node *sn; in __sigev_find() local
250 LIST_FOREACH(sn, &sigev_hash[chain], sn_link) { in __sigev_find()
251 if (sn->sn_type == type && sn->sn_id == id) in __sigev_find()
254 return (sn); in __sigev_find()
258 __sigev_register(struct sigev_node *sn) in __sigev_register() argument
260 int chain = HASH(sn->sn_type, sn->sn_id); in __sigev_register()
262 LIST_INSERT_HEAD(&sigev_hash[chain], sn, sn_link); in __sigev_register()
269 struct sigev_node *sn; in __sigev_delete() local
271 sn = __sigev_find(type, id); in __sigev_delete()
272 if (sn != NULL) in __sigev_delete()
273 return (__sigev_delete_node(sn)); in __sigev_delete()
278 __sigev_delete_node(struct sigev_node *sn) in __sigev_delete_node() argument
280 LIST_REMOVE(sn, sn_link); in __sigev_delete_node()
282 if (--sn->sn_tn->tn_refcount == 0) in __sigev_delete_node()
283 _pthread_kill(sn->sn_tn->tn_thread, SIGLIBRT); in __sigev_delete_node()
284 if (sn->sn_flags & SNF_WORKING) in __sigev_delete_node()
285 sn->sn_flags |= SNF_REMOVED; in __sigev_delete_node()
287 __sigev_free(sn); in __sigev_delete_node()
370 struct sigev_node *sn; in sigev_service_loop() local
400 sn = __sigev_find(si.si_code, id); in sigev_service_loop()
401 if (sn == NULL) { in sigev_service_loop()
406 sn->sn_info = si; in sigev_service_loop()
407 if (sn->sn_flags & SNF_SYNC) in sigev_service_loop()
408 tn->tn_cur = sn; in sigev_service_loop()
411 sn->sn_flags |= SNF_WORKING; in sigev_service_loop()
414 ret = _pthread_create(&td, &sn->sn_attr, worker_routine, sn); in sigev_service_loop()
421 sn->sn_flags &= ~SNF_WORKING; in sigev_service_loop()
422 if (sn->sn_flags & SNF_REMOVED) in sigev_service_loop()
423 __sigev_free(sn); in sigev_service_loop()
441 struct sigev_node *sn = arg; in worker_routine() local
443 pthread_cleanup_push(worker_cleanup, sn); in worker_routine()
444 sn->sn_dispatch(sn); in worker_routine()
454 struct sigev_node *sn = arg; in worker_cleanup() local
457 if (sn->sn_flags & SNF_SYNC) { in worker_cleanup()
458 sn->sn_tn->tn_cur = NULL; in worker_cleanup()
459 _pthread_cond_broadcast(&sn->sn_tn->tn_cv); in worker_cleanup()
461 if (sn->sn_flags & SNF_REMOVED) in worker_cleanup()
462 __sigev_free(sn); in worker_cleanup()
464 sn->sn_flags &= ~SNF_WORKING; in worker_cleanup()