xapian-core  1.4.27
safesysselect.h
Go to the documentation of this file.
1 
4 /* Copyright (C) 2007,2011,2018 Olly Betts
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of the
9  * License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef XAPIAN_INCLUDED_SAFESYSSELECT_H
22 #define XAPIAN_INCLUDED_SAFESYSSELECT_H
23 
24 #ifndef PACKAGE
25 # error You must #include <config.h> before #include "safesysselect.h"
26 #endif
27 
28 #ifndef __WIN32__
29 # ifdef HAVE_SYS_SELECT_H
30 // According to POSIX 1003.1-2001.
31 # include <sys/select.h>
32 # else
33 // According to earlier standards.
34 # include <sys/time.h>
35 # include <sys/types.h>
36 # include <unistd.h>
37 # endif
38 
39 // On Solaris FD_SET uses memset but fails to prototype it.
40 # include <cstring>
41 
42 #else
43 
44 // select() and FD_SET() are defined in <winsock2.h>:
45 //
46 // The FD_SET macro expects an unsigned type (SOCKET) for the fd and passing
47 // an int can result in a warning about comparing signed and unsigned, so we
48 // add a wrapper to cast the fd argument of FD_SET to unsigned.
49 # include "safewinsock2.h"
50 inline void xapian_FD_SET_(int fd, fd_set *set) {
51  FD_SET(unsigned(fd), set);
52 }
53 # ifdef FD_SET
54 # undef FD_SET
55 # endif
56 # define FD_SET(FD,SET) xapian_FD_SET_(FD,SET)
57 #endif
58 
59 #endif // XAPIAN_INCLUDED_SAFESYSSELECT_H
include <winsock2.h> but working around problems.