xref: /netbsd-src/sys/compat/linux/common/linux_sigevent.h (revision 8b56e9b928507070a9d533d596a3f03f96b47810)
133e6ca90Sfvdl /*-
233e6ca90Sfvdl  * Copyright (c) 2005 The NetBSD Foundation, Inc.
333e6ca90Sfvdl  * All rights reserved.
433e6ca90Sfvdl  *
533e6ca90Sfvdl  * This code is derived from software contributed to The NetBSD Foundation
633e6ca90Sfvdl  * by Frank van der Linden.
733e6ca90Sfvdl  *
833e6ca90Sfvdl  * Redistribution and use in source and binary forms, with or without
933e6ca90Sfvdl  * modification, are permitted provided that the following conditions
1033e6ca90Sfvdl  * are met:
1133e6ca90Sfvdl  * 1. Redistributions of source code must retain the above copyright
1233e6ca90Sfvdl  *    notice, this list of conditions and the following disclaimer.
1333e6ca90Sfvdl  * 2. Redistributions in binary form must reproduce the above copyright
1433e6ca90Sfvdl  *    notice, this list of conditions and the following disclaimer in the
1533e6ca90Sfvdl  *    documentation and/or other materials provided with the distribution.
1633e6ca90Sfvdl  *
1733e6ca90Sfvdl  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1833e6ca90Sfvdl  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1933e6ca90Sfvdl  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2033e6ca90Sfvdl  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2133e6ca90Sfvdl  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2233e6ca90Sfvdl  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2333e6ca90Sfvdl  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2433e6ca90Sfvdl  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2533e6ca90Sfvdl  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2633e6ca90Sfvdl  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2733e6ca90Sfvdl  * POSSIBILITY OF SUCH DAMAGE.
2833e6ca90Sfvdl  */
2933e6ca90Sfvdl 
3033e6ca90Sfvdl #ifndef _LINUX_SIGEVENT_H
3133e6ca90Sfvdl #define _LINUX_SIGEVENT_H
3233e6ca90Sfvdl 
3333e6ca90Sfvdl #define LINUX_SIGEV_SIGNAL    0       /* notify via signal */
3433e6ca90Sfvdl #define LINUX_SIGEV_NONE      1       /* other notification: meaningless */
3533e6ca90Sfvdl #define LINUX_SIGEV_THREAD    2       /* deliver via thread creation */
3633e6ca90Sfvdl #define LINUX_SIGEV_THREAD_ID 4       /* deliver to thread */
3733e6ca90Sfvdl 
3833e6ca90Sfvdl #define LINUX_SIGEV_MAX  64
3933e6ca90Sfvdl #ifndef LINUX_SIGEV_PAD
40*8b56e9b9Sthorpej #define LINUX_SIGEV_PAD  ((LINUX_SIGEV_MAX -				\
41*8b56e9b9Sthorpej 			   (sizeof(sigval_t) + (sizeof(int) * 2))) /	\
42*8b56e9b9Sthorpej 			  sizeof(int))
4333e6ca90Sfvdl #endif
4433e6ca90Sfvdl 
4533e6ca90Sfvdl typedef struct linux_sigevent {
46*8b56e9b9Sthorpej 	sigval_t sigev_value;		/* sizeof(pointer) */
4733e6ca90Sfvdl 	int sigev_signo;
4833e6ca90Sfvdl 	int sigev_notify;
49*8b56e9b9Sthorpej 	/* guaranteed to have natural pointer alignment */
5033e6ca90Sfvdl 	union {
5133e6ca90Sfvdl 		int pad[LINUX_SIGEV_PAD];
5233e6ca90Sfvdl 		int tid;
5333e6ca90Sfvdl 		struct {
5433e6ca90Sfvdl 			void (*func)(sigval_t);
5533e6ca90Sfvdl 			void *attr;
5633e6ca90Sfvdl 		} _sigev_thread;
5733e6ca90Sfvdl 	} _sigev_un;
5833e6ca90Sfvdl } linux_sigevent_t;
5933e6ca90Sfvdl 
60*8b56e9b9Sthorpej int	linux_to_native_sigevent(struct sigevent *,
61*8b56e9b9Sthorpej 	    const struct linux_sigevent *);
62*8b56e9b9Sthorpej int	linux_sigevent_copyin(const void *, void *, size_t);
63*8b56e9b9Sthorpej 
6433e6ca90Sfvdl #endif /* _LINUX_SIGEVENT_H */
65