xref: /freebsd/contrib/ntp/include/iosignal.h (revision 416ba5c74546f32a993436a99516d35008e9f384)
1*2b15cb3dSCy Schubert #ifndef IOSIGNAL_H
2*2b15cb3dSCy Schubert #define IOSIGNAL_H
3c0b746e5SOllivier Robert 
4c0b746e5SOllivier Robert #include "ntp_refclock.h"
5c0b746e5SOllivier Robert 
6*2b15cb3dSCy Schubert  /*
7*2b15cb3dSCy Schubert  * Some systems (MOST) define SIGPOLL == SIGIO, others SIGIO == SIGPOLL, and
8*2b15cb3dSCy Schubert  * a few have separate SIGIO and SIGPOLL signals.  This code checks for the
9*2b15cb3dSCy Schubert  * SIGIO == SIGPOLL case at compile time.
10*2b15cb3dSCy Schubert  * Do not define USE_SIGPOLL or USE_SIGIO.
11*2b15cb3dSCy Schubert  * these are interal only to iosignal.c and ntpd/work_fork.c!
12*2b15cb3dSCy Schubert  */
13*2b15cb3dSCy Schubert #if defined(USE_SIGPOLL)
14*2b15cb3dSCy Schubert # undef USE_SIGPOLL
15c0b746e5SOllivier Robert #endif
16*2b15cb3dSCy Schubert #if defined(USE_SIGIO)
17*2b15cb3dSCy Schubert # undef USE_SIGIO
18*2b15cb3dSCy Schubert #endif
19*2b15cb3dSCy Schubert 
20*2b15cb3dSCy Schubert /* type of input handler function - only shared between iosignal.c and ntp_io.c */
21*2b15cb3dSCy Schubert typedef void (input_handler_t)(l_fp *);
22*2b15cb3dSCy Schubert 
23*2b15cb3dSCy Schubert #if defined(HAVE_SIGNALED_IO)
24*2b15cb3dSCy Schubert # if defined(USE_TTY_SIGPOLL) || defined(USE_UDP_SIGPOLL)
25*2b15cb3dSCy Schubert #  define USE_SIGPOLL
26*2b15cb3dSCy Schubert # endif
27*2b15cb3dSCy Schubert 
28*2b15cb3dSCy Schubert # if !defined(USE_TTY_SIGPOLL) || !defined(USE_UDP_SIGPOLL)
29*2b15cb3dSCy Schubert #  define USE_SIGIO
30*2b15cb3dSCy Schubert # endif
31*2b15cb3dSCy Schubert 
32*2b15cb3dSCy Schubert # if defined(USE_SIGIO) && defined(USE_SIGPOLL)
33*2b15cb3dSCy Schubert #  if SIGIO == SIGPOLL
34*2b15cb3dSCy Schubert #   define USE_SIGIO
35*2b15cb3dSCy Schubert #   undef USE_SIGPOLL
36*2b15cb3dSCy Schubert #  endif	/* SIGIO == SIGPOLL */
37*2b15cb3dSCy Schubert # endif		/* USE_SIGIO && USE_SIGPOLL */
38*2b15cb3dSCy Schubert 
39*2b15cb3dSCy Schubert #define	USING_SIGIO()	using_sigio
40*2b15cb3dSCy Schubert 
41*2b15cb3dSCy Schubert extern int		using_sigio;
42*2b15cb3dSCy Schubert 
43*2b15cb3dSCy Schubert extern void		block_sigio	(void);
44*2b15cb3dSCy Schubert extern void		unblock_sigio	(void);
45*2b15cb3dSCy Schubert extern int		init_clock_sig	(struct refclockio *);
46*2b15cb3dSCy Schubert extern void		init_socket_sig	(int);
47*2b15cb3dSCy Schubert extern void		set_signal	(input_handler_t *);
48*2b15cb3dSCy Schubert 
49*2b15cb3dSCy Schubert # define BLOCKIO()	block_sigio()
50*2b15cb3dSCy Schubert # define UNBLOCKIO()	unblock_sigio()
51*2b15cb3dSCy Schubert 
52*2b15cb3dSCy Schubert #else	/* !HAVE_SIGNALED_IO follows */
53*2b15cb3dSCy Schubert # define BLOCKIO()	do {} while (0)
54*2b15cb3dSCy Schubert # define UNBLOCKIO()	do {} while (0)
55*2b15cb3dSCy Schubert # define USING_SIGIO()	FALSE
56*2b15cb3dSCy Schubert #endif
57*2b15cb3dSCy Schubert 
58*2b15cb3dSCy Schubert #endif	/* IOSIGNAL_H */
59