Add issubnormal.
[glibc.git] / nptl / tst-cancel4-common.h
blob06ed0dc1ba12f6807d8be020cafad8de4fbdd819
1 /* Common definition for tst-cancel4_* tests.
3 Copyright (C) 2016 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library 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 GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
20 #include <pthread.h>
22 /* Pipe descriptors. */
23 static int fds[2];
25 /* Temporary file descriptor, to be closed after each round. */
26 static int tempfd = -1;
27 static int tempfd2 = -1;
28 /* Name of temporary file to be removed after each round. */
29 static char *tempfname;
30 /* Temporary message queue. */
31 static int tempmsg = -1;
33 /* Often used barrier for two threads. */
34 static pthread_barrier_t b2;
36 /* The WRITE_BUFFER_SIZE value needs to be chosen such that if we set
37 the socket send buffer size to '1', a write of this size on that
38 socket will block.
40 The Linux kernel imposes a minimum send socket buffer size which
41 has changed over the years. As of Linux 3.10 the value is:
43 2 * (2048 + SKB_DATA_ALIGN(sizeof(struct sk_buff)))
45 which is attempting to make sure that with standard MTUs,
46 TCP can always queue up at least 2 full sized packets.
48 Furthermore, there is logic in the socket send paths that
49 will allow one more packet (of any size) to be queued up as
50 long as some socket buffer space remains. Blocking only
51 occurs when we try to queue up a new packet and the send
52 buffer space has already been fully consumed.
54 Therefore we must set this value to the largest possible value of
55 the formula above (and since it depends upon the size of "struct
56 sk_buff", it is dependent upon machine word size etc.) plus some
57 slack space. */
59 #define WRITE_BUFFER_SIZE 16384
61 /* Cleanup handling test. */
62 static int cl_called;
64 static void
65 cl (void *arg)
67 ++cl_called;
70 /* Named pipe used to check for blocking open. It should be closed
71 after the cancellation handling. */
72 static char fifoname[] = "/tmp/tst-cancel4-fifo-XXXXXX";
73 static int fifofd;
75 static void
76 __attribute__ ((used))
77 cl_fifo (void *arg)
79 ++cl_called;
81 unlink (fifoname);
82 close (fifofd);
83 fifofd = -1;
86 struct cancel_tests
88 const char *name;
89 void *(*tf) (void *);
90 int nb;
91 int only_early;
93 #define ADD_TEST(name, nbar, early) { #name, tf_##name, nbar, early }