usleep tests: Avoid failure due to known Cygwin 3.5.3 bug.
[gnulib.git] / tests / test-nonblocking-socket.h
blob1bab37aa075a4160b8e7fc29f5622fba58b9f100
1 /* Test for nonblocking read and write.
3 Copyright (C) 2011-2024 Free Software Foundation, Inc.
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.
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.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
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:
21 Platform SOCKET_DATA_BLOCK_SIZE
23 Linux >= 7350000 (depends on circumstances)
24 Linux/Android >= 1700000 (approx.)
25 FreeBSD >= 107521
26 OpenBSD >= 106430 (depends on circumstances)
27 Mac OS X >= 680000 (depends on circumstances)
28 AIX 5.1 >= 125713
29 AIX 7.1 >= 200000 (depends on circumstances)
30 HP-UX >= 114689
31 IRIX >= 61089
32 OSF/1 >= 122881
33 Solaris 7 >= 63000 (depends on circumstances)
34 Solaris 8 >= 49153
35 Solaris 9 >= 73729
36 Solaris 10 >= 98305
37 Solaris 11 2010-11 >= 73729
38 Cygwin 1.5.x >= 66294401 but then write() fails with ENOBUFS
39 Cygwin 1.7.x >= 163838 (depends on circumstances)
40 native Windows >= 66294401
42 #define SOCKET_DATA_BLOCK_SIZE 1000000
44 /* On Linux, Mac OS X, Cygwin 1.5.x, native Windows,
45 sockets have very large buffers in the kernel, so that write() calls
46 succeed before the reader has started reading, even if fd is blocking
47 and the amount of data is larger than 1 MB. */
48 #if defined __linux__ || defined __ANDROID__ || (defined __APPLE__ && defined __MACH__) || defined _WIN32 || defined __CYGWIN__
49 # define SOCKET_HAS_LARGE_BUFFER 1
50 #else
51 # define SOCKET_HAS_LARGE_BUFFER 0
52 #endif