2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A#ifndef _SIGEV_THREAD_H
2N/A#define _SIGEV_THREAD_H
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A#include <signal.h>
2N/A#include <port.h>
2N/A#include <mqueue.h>
2N/A#include <time.h>
2N/A#include <limits.h>
2N/A#include <semaphore.h>
2N/A#include <thread_pool.h>
2N/A
2N/A#define SIGEV_THREAD_TERM 1
2N/A
2N/Atypedef enum {TIMER = 1, MQ, AIO} subsystem_t; /* Calling sub-system */
2N/A
2N/Atypedef struct {
2N/A void (*std_func)(union sigval); /* User-defined notification function */
2N/A union sigval std_arg; /* Parameter of user-defined notification fct */
2N/A} sigev_thread_data_t;
2N/A
2N/Atypedef struct thread_communication_data {
2N/A struct thread_communication_data *tcd_next;
2N/A struct sigevent tcd_notif; /* encapsulates usr fct and usr vals */
2N/A pthread_attr_t tcd_user_attr; /* copy of caller's attributes */
2N/A pthread_attr_t *tcd_attrp; /* NULL if caller passed NULL */
2N/A int tcd_port; /* port this spawner is controlling */
2N/A thread_t tcd_server_id; /* thread id of server thread */
2N/A subsystem_t tcd_subsystem; /* event generating subsystem */
2N/A tpool_t *tcd_poolp; /* worker thread pool */
2N/A /* for creation/termination synchronization protocol */
2N/A mutex_t tcd_lock;
2N/A cond_t tcd_cv;
2N/A /* subsystem-specific data */
2N/A union {
2N/A struct {
2N/A int overruns; /* number of overruns */
2N/A } timer;
2N/A struct {
2N/A int msg_enabled; /* notification enabled */
2N/A int msg_closing; /* mq_close() is waiting */
2N/A sem_t *msg_avail; /* wait for message available */
2N/A void *msg_object; /* mqd_t */
2N/A void *msg_userval; /* notification user value */
2N/A } mqueue;
2N/A } tcd_object;
2N/A} thread_communication_data_t;
2N/A
2N/A#define tcd_overruns tcd_object.timer.overruns
2N/A
2N/A#define tcd_msg_enabled tcd_object.mqueue.msg_enabled
2N/A#define tcd_msg_closing tcd_object.mqueue.msg_closing
2N/A#define tcd_msg_avail tcd_object.mqueue.msg_avail
2N/A#define tcd_msg_object tcd_object.mqueue.msg_object
2N/A#define tcd_msg_userval tcd_object.mqueue.msg_userval
2N/A
2N/A/* Generic functions common to all entities */
2N/Aextern thread_communication_data_t *setup_sigev_handler(
2N/A const struct sigevent *, subsystem_t);
2N/Aextern void free_sigev_handler(thread_communication_data_t *);
2N/Aextern int launch_spawner(thread_communication_data_t *);
2N/Aextern void tcd_teardown(thread_communication_data_t *);
2N/A
2N/A/* Additional functions for different entities */
2N/Aextern void *timer_spawner(void *);
2N/Aextern int del_sigev_timer(timer_t);
2N/Aextern int sigev_timer_getoverrun(timer_t);
2N/Aextern void *mqueue_spawner(void *);
2N/Aextern void del_sigev_mq(thread_communication_data_t *);
2N/Aextern void *aio_spawner(void *);
2N/A
2N/A/* Private interfaces elsewhere in libc */
2N/Aextern int pthread_attr_clone(pthread_attr_t *, const pthread_attr_t *);
2N/Aextern int pthread_attr_equal(const pthread_attr_t *, const pthread_attr_t *);
2N/Aextern int _port_dispatch(int, int, int, int, uintptr_t, void *);
2N/A
2N/Aextern thread_communication_data_t *sigev_aio_tcd;
2N/A
2N/Aextern int timer_max;
2N/Aextern thread_communication_data_t **timer_tcd;
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _SIGEV_THREAD_H */