maint: update copyright
[gnulib.git] / tests / test-nonblocking-socket.h
1 /* Test for nonblocking read and write.
2
3    Copyright (C) 2011-2014 Free Software Foundation, Inc.
4
5    This program is free software: you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 3 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17
18 /* A data block ought to be larger than the size of the in-kernel buffer.
19    Working values of SOCKET_DATA_BLOCK_SIZE, depending on kernel:
20
21      Platform                        SOCKET_DATA_BLOCK_SIZE
22
23      Linux                           >= 7350000 (depends on circumstances)
24      FreeBSD                         >= 107521
25      OpenBSD                         >= 28673
26      Mac OS X                        >= 680000 (depends on circumstances)
27      AIX 5.1                         >= 125713
28      AIX 7.1                         >= 200000 (depends on circumstances)
29      HP-UX                           >= 114689
30      IRIX                            >= 61089
31      OSF/1                           >= 122881
32      Solaris 7                       >= 63000 (depends on circumstances)
33      Solaris 8                       >= 49153
34      Solaris 9                       >= 73729
35      Solaris 10                      >= 98305
36      Solaris 11 2010-11              >= 73729
37      Cygwin 1.5.x                    >= 66294401 but then write() fails with ENOBUFS
38      Cygwin 1.7.x                    >= 163838 (depends on circumstances)
39      native Windows                  >= 66294401
40  */
41 #if defined __OpenBSD__
42 # define SOCKET_DATA_BLOCK_SIZE  100000
43 #else
44 # define SOCKET_DATA_BLOCK_SIZE 1000000
45 #endif
46
47 /* On Linux, Mac OS X, Cygwin 1.5.x, native Windows,
48    sockets have very large buffers in the kernel, so that write() calls
49    succeed before the reader has started reading, even if fd is blocking
50    and the amount of data is larger than 1 MB.  */
51 #if defined __linux__ || (defined __APPLE__ && defined __MACH__) || (defined _WIN32 || defined __WIN32__) || defined __CYGWIN__
52 # define SOCKET_HAS_LARGE_BUFFER 1
53 #else
54 # define SOCKET_HAS_LARGE_BUFFER 0
55 #endif