xref: /titanic_51/usr/src/uts/common/sys/signalfd.h (revision 3d729aecc03ea6ebb9bd5d56b8dccd24f57daa41)
1*3d729aecSJerry Jelinek /*
2*3d729aecSJerry Jelinek  * This file and its contents are supplied under the terms of the
3*3d729aecSJerry Jelinek  * Common Development and Distribution License ("CDDL"), version 1.0.
4*3d729aecSJerry Jelinek  * You may only use this file in accordance with the terms of version
5*3d729aecSJerry Jelinek  * 1.0 of the CDDL.
6*3d729aecSJerry Jelinek  *
7*3d729aecSJerry Jelinek  * A full copy of the text of the CDDL should have accompanied this
8*3d729aecSJerry Jelinek  * source.  A copy of the CDDL is also available via the Internet at
9*3d729aecSJerry Jelinek  * http://www.illumos.org/license/CDDL.
10*3d729aecSJerry Jelinek  */
11*3d729aecSJerry Jelinek 
12*3d729aecSJerry Jelinek /*
13*3d729aecSJerry Jelinek  * Copyright 2015 Joyent, Inc.
14*3d729aecSJerry Jelinek  */
15*3d729aecSJerry Jelinek 
16*3d729aecSJerry Jelinek /*
17*3d729aecSJerry Jelinek  * Header file to support the signalfd facility. Note that this facility
18*3d729aecSJerry Jelinek  * is designed to be binary compatible with the Linux signalfd facility, modulo
19*3d729aecSJerry Jelinek  * the signals themselves; values for constants here should therefore exactly
20*3d729aecSJerry Jelinek  * match those found in Linux, and this facility shouldn't be extended
21*3d729aecSJerry Jelinek  * independently of Linux.
22*3d729aecSJerry Jelinek  */
23*3d729aecSJerry Jelinek 
24*3d729aecSJerry Jelinek #ifndef _SYS_SIGNALFD_H
25*3d729aecSJerry Jelinek #define	_SYS_SIGNALFD_H
26*3d729aecSJerry Jelinek 
27*3d729aecSJerry Jelinek #include <sys/types.h>
28*3d729aecSJerry Jelinek 
29*3d729aecSJerry Jelinek #ifdef	__cplusplus
30*3d729aecSJerry Jelinek extern "C" {
31*3d729aecSJerry Jelinek #endif
32*3d729aecSJerry Jelinek 
33*3d729aecSJerry Jelinek /*
34*3d729aecSJerry Jelinek  * To assure binary compatibility with Linux, these values are fixed at their
35*3d729aecSJerry Jelinek  * Linux equivalents, not their native ones.
36*3d729aecSJerry Jelinek  */
37*3d729aecSJerry Jelinek #define	SFD_CLOEXEC		02000000		/* LX_O_CLOEXEC */
38*3d729aecSJerry Jelinek #define	SFD_NONBLOCK		04000			/* LX_O_NONBLOCK */
39*3d729aecSJerry Jelinek 
40*3d729aecSJerry Jelinek /*
41*3d729aecSJerry Jelinek  * These ioctl values are specific to the native implementation; applications
42*3d729aecSJerry Jelinek  * shouldn't be using them directly, and they should therefore be safe to
43*3d729aecSJerry Jelinek  * change without breaking apps.
44*3d729aecSJerry Jelinek  */
45*3d729aecSJerry Jelinek #define	SIGNALFDIOC		(('s' << 24) | ('f' << 16) | ('d' << 8))
46*3d729aecSJerry Jelinek #define	SIGNALFDIOC_MASK	(SIGNALFDIOC | 1)	/* set mask */
47*3d729aecSJerry Jelinek 
48*3d729aecSJerry Jelinek typedef struct signalfd_siginfo {
49*3d729aecSJerry Jelinek 	uint32_t ssi_signo;	/* signal from signal.h */
50*3d729aecSJerry Jelinek 	int32_t  ssi_errno;	/* error from errno.h */
51*3d729aecSJerry Jelinek 	int32_t  ssi_code;	/* signal code */
52*3d729aecSJerry Jelinek 	uint32_t ssi_pid;	/* PID of sender */
53*3d729aecSJerry Jelinek 	uint32_t ssi_uid;	/* real UID of sender */
54*3d729aecSJerry Jelinek 	int32_t  ssi_fd;	/* File descriptor (SIGIO) */
55*3d729aecSJerry Jelinek 	uint32_t ssi_tid;	/* unused */
56*3d729aecSJerry Jelinek 	uint32_t ssi_band;	/* band event (SIGIO) */
57*3d729aecSJerry Jelinek 	uint32_t ssi_overrun;	/* unused */
58*3d729aecSJerry Jelinek 	uint32_t ssi_trapno;	/* trap number that caused signal */
59*3d729aecSJerry Jelinek 	int32_t  ssi_status;	/* exit status or signal (SIGCHLD) */
60*3d729aecSJerry Jelinek 	int32_t  ssi_int;	/* unused */
61*3d729aecSJerry Jelinek 	uint64_t ssi_ptr;	/* unused */
62*3d729aecSJerry Jelinek 	uint64_t ssi_utime;	/* user CPU time consumed (SIGCHLD) */
63*3d729aecSJerry Jelinek 	uint64_t ssi_stime;	/* system CPU time consumed (SIGCHLD) */
64*3d729aecSJerry Jelinek 	uint64_t ssi_addr;	/* address that generated signal */
65*3d729aecSJerry Jelinek 	uint8_t  ssi_pad[48];	/* Pad size to 128 bytes to allow for */
66*3d729aecSJerry Jelinek 				/* additional fields in the future. */
67*3d729aecSJerry Jelinek } signalfd_siginfo_t;
68*3d729aecSJerry Jelinek 
69*3d729aecSJerry Jelinek #ifndef _KERNEL
70*3d729aecSJerry Jelinek 
71*3d729aecSJerry Jelinek extern int signalfd(int, const sigset_t *, int);
72*3d729aecSJerry Jelinek 
73*3d729aecSJerry Jelinek #else
74*3d729aecSJerry Jelinek 
75*3d729aecSJerry Jelinek #define	SIGNALFDMNRN_SIGNALFD	0
76*3d729aecSJerry Jelinek #define	SIGNALFDMNRN_CLONE	1
77*3d729aecSJerry Jelinek 
78*3d729aecSJerry Jelinek typedef struct sigfd_wake_list {
79*3d729aecSJerry Jelinek 	list_node_t sigfd_wl_lst;
80*3d729aecSJerry Jelinek 	void *sigfd_wl_state;
81*3d729aecSJerry Jelinek } sigfd_wake_list_t;
82*3d729aecSJerry Jelinek 
83*3d729aecSJerry Jelinek /*
84*3d729aecSJerry Jelinek  * This holds the proc_t state for a process which is using signalfd.
85*3d729aecSJerry Jelinek  */
86*3d729aecSJerry Jelinek typedef struct sigfd_proc_state {
87*3d729aecSJerry Jelinek 	void (*sigfd_pollwake_cb)(void *, int);
88*3d729aecSJerry Jelinek 	list_t sigfd_list;
89*3d729aecSJerry Jelinek } sigfd_proc_state_t;
90*3d729aecSJerry Jelinek 
91*3d729aecSJerry Jelinek 
92*3d729aecSJerry Jelinek extern void (*sigfd_exit_helper)();
93*3d729aecSJerry Jelinek 
94*3d729aecSJerry Jelinek #endif /* _KERNEL */
95*3d729aecSJerry Jelinek 
96*3d729aecSJerry Jelinek #ifdef	__cplusplus
97*3d729aecSJerry Jelinek }
98*3d729aecSJerry Jelinek #endif
99*3d729aecSJerry Jelinek 
100*3d729aecSJerry Jelinek #endif	/* _SYS_SIGNALFD_H */
101