xref: /freebsd/tools/regression/capsicum/syscalls/misc.h (revision 5c2bc3db201a4fe8d7911cf816bea104d5dc2138)
1*de503941SPawel Jakub Dawidek /*-
2*de503941SPawel Jakub Dawidek  * Copyright (c) 2012 The FreeBSD Foundation
3*de503941SPawel Jakub Dawidek  *
4*de503941SPawel Jakub Dawidek  * This software was developed by Pawel Jakub Dawidek under sponsorship from
5*de503941SPawel Jakub Dawidek  * the FreeBSD Foundation.
6*de503941SPawel Jakub Dawidek  *
7*de503941SPawel Jakub Dawidek  * Redistribution and use in source and binary forms, with or without
8*de503941SPawel Jakub Dawidek  * modification, are permitted provided that the following conditions
9*de503941SPawel Jakub Dawidek  * are met:
10*de503941SPawel Jakub Dawidek  * 1. Redistributions of source code must retain the above copyright
11*de503941SPawel Jakub Dawidek  *    notice, this list of conditions and the following disclaimer.
12*de503941SPawel Jakub Dawidek  * 2. Redistributions in binary form must reproduce the above copyright
13*de503941SPawel Jakub Dawidek  *    notice, this list of conditions and the following disclaimer in the
14*de503941SPawel Jakub Dawidek  *    documentation and/or other materials provided with the distribution.
15*de503941SPawel Jakub Dawidek  *
16*de503941SPawel Jakub Dawidek  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
17*de503941SPawel Jakub Dawidek  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18*de503941SPawel Jakub Dawidek  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19*de503941SPawel Jakub Dawidek  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
20*de503941SPawel Jakub Dawidek  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21*de503941SPawel Jakub Dawidek  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22*de503941SPawel Jakub Dawidek  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23*de503941SPawel Jakub Dawidek  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24*de503941SPawel Jakub Dawidek  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25*de503941SPawel Jakub Dawidek  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26*de503941SPawel Jakub Dawidek  * SUCH DAMAGE.
27*de503941SPawel Jakub Dawidek  */
28*de503941SPawel Jakub Dawidek 
29*de503941SPawel Jakub Dawidek #ifndef _MISC_H_
30*de503941SPawel Jakub Dawidek #define	_MISC_H_
31*de503941SPawel Jakub Dawidek 
32*de503941SPawel Jakub Dawidek #define	OK()	do {							\
33*de503941SPawel Jakub Dawidek 	int _serrno = errno;						\
34*de503941SPawel Jakub Dawidek 	printf("ok # line %u\n", __LINE__);				\
35*de503941SPawel Jakub Dawidek 	fflush(stdout);							\
36*de503941SPawel Jakub Dawidek 	errno = _serrno;						\
37*de503941SPawel Jakub Dawidek } while (0)
38*de503941SPawel Jakub Dawidek #define	NOK()	do {							\
39*de503941SPawel Jakub Dawidek 	int _serrno = errno;						\
40*de503941SPawel Jakub Dawidek 	printf("not ok # line %u\n", __LINE__);				\
41*de503941SPawel Jakub Dawidek 	fflush(stdout);							\
42*de503941SPawel Jakub Dawidek 	errno = _serrno;						\
43*de503941SPawel Jakub Dawidek } while (0)
44*de503941SPawel Jakub Dawidek #define	CHECK(cond)	do {						\
45*de503941SPawel Jakub Dawidek 	if ((cond))							\
46*de503941SPawel Jakub Dawidek 		OK();							\
47*de503941SPawel Jakub Dawidek 	else								\
48*de503941SPawel Jakub Dawidek 		NOK();							\
49*de503941SPawel Jakub Dawidek } while (0)
50*de503941SPawel Jakub Dawidek 
51*de503941SPawel Jakub Dawidek /*
52*de503941SPawel Jakub Dawidek  * This can be removed once pdwait4(2) is implemented.
53*de503941SPawel Jakub Dawidek  */
54*de503941SPawel Jakub Dawidek int pdwait(int pfd);
55*de503941SPawel Jakub Dawidek 
56*de503941SPawel Jakub Dawidek int descriptor_send(int sock, int fd);
57*de503941SPawel Jakub Dawidek int descriptor_recv(int sock, int *fdp);
58*de503941SPawel Jakub Dawidek 
59*de503941SPawel Jakub Dawidek #endif	/* !_MISC_H_ */
60