BRL-CAD
bsocket.h
Go to the documentation of this file.
1 /* B S O C K E T . H
2  * BRL-CAD
3  *
4  * Copyright (c) 2011-2024 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 /** @addtogroup bu_bsocket
21  *
22  * @brief
23  * BRL-CAD system compatibility wrapper header that provides declarations for
24  * native and standard system select() routines.
25  *
26  * This header is commonly used in lieu of including the following:
27  * sys/select.h, winsock2.h (select, fd_set)
28  */
29 
30 /** @{ */
31 /** @file bsocket.h */
32 
33 #ifndef BSOCKET_H
34 #define BSOCKET_H
35 
36 #include "common.h"
37 
38 #ifdef HAVE_SYS_SELECT_H
39 # include <sys/select.h>
40 #endif
41 
42 #ifdef HAVE_SYS_SOCKET_H
43 # include <sys/socket.h>
44 #endif
45 
46 /* Windows Sockets provides select() and friends */
47 #if defined(_WIN32) && !defined(__CYGWIN__)
48 # ifndef _WINSOCKAPI_
49 # include <winsock2.h>
50 # endif
51 #endif
52 
53 /* compatibility for pedantic bug/limitation in gcc 4.6.2, need to
54  * mark macros as extensions else they may emit "ISO C forbids
55  * braced-groups within expressions" warnings.
56  */
57 #if defined(__extension__) && GCC_PREREQ(4, 6) && !GCC_PREREQ(4, 7)
58 
59 # if defined(FD_SET) && defined(__FD_SET)
60 # undef FD_SET
61 # define FD_SET(x, y) __extension__ __FD_SET((x), (y))
62 # endif
63 
64 # if defined(FD_CLR) && defined(__FD_CLR)
65 # undef FD_CLR
66 # define FD_CLR(x, y) __extension__ __FD_CLR((x), (y))
67 # endif
68 
69 # if defined(FD_ISSET) && defined(__FD_ISSET)
70 # undef FD_ISSET
71 # define FD_ISSET(x, y) __extension__ __FD_ISSET((x), (y))
72 # endif
73 
74 #endif /* GCC_PREREQ */
75 
76 #endif /* BSOCKET_H */
77 
78 /** @} */
79 
80 /*
81  * Local Variables:
82  * tab-width: 8
83  * mode: C
84  * indent-tabs-mode: t
85  * c-file-style: "stroustrup"
86  * End:
87  * ex: shiftwidth=4 tabstop=8
88  */
Header file for the BRL-CAD common definitions.