Fix misspelled yesexpr/day/abday/mon/abmon/date_fmt fields in sc_IT
[glibc.git] / nptl / tst-cancel4-common.h
blob54b2f1e2d95eca5ee150355d022a795af202f11e
1 /* Common definition for tst-cancel4_* tests.
3 Copyright (C) 2016-2017 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 #include <support/check.h>
23 #include <support/xthread.h>
24 #include <support/xunistd.h>
26 /* Pipe descriptors. */
27 static int fds[2];
29 /* Temporary file descriptor, to be closed after each round. */
30 static int tempfd = -1;
31 static int tempfd2 = -1;
32 /* Name of temporary file to be removed after each round. */
33 static char *tempfname;
34 /* Temporary message queue. */
35 static int tempmsg = -1;
37 /* Often used barrier for two threads. */
38 static pthread_barrier_t b2;
40 /* The WRITE_BUFFER_SIZE value needs to be chosen such that if we set
41 the socket send buffer size to '1', a write of this size on that
42 socket will block.
44 The Linux kernel imposes a minimum send socket buffer size which
45 has changed over the years. As of Linux 3.10 the value is:
47 2 * (2048 + SKB_DATA_ALIGN(sizeof(struct sk_buff)))
49 which is attempting to make sure that with standard MTUs,
50 TCP can always queue up at least 2 full sized packets.
52 Furthermore, there is logic in the socket send paths that
53 will allow one more packet (of any size) to be queued up as
54 long as some socket buffer space remains. Blocking only
55 occurs when we try to queue up a new packet and the send
56 buffer space has already been fully consumed.
58 Therefore we must set this value to the largest possible value of
59 the formula above (and since it depends upon the size of "struct
60 sk_buff", it is dependent upon machine word size etc.) plus some
61 slack space. */
63 #define WRITE_BUFFER_SIZE 16384
65 /* Cleanup handling test. */
66 static int cl_called;
68 static void
69 cl (void *arg)
71 ++cl_called;
74 /* Named pipe used to check for blocking open. It should be closed
75 after the cancellation handling. */
76 static char fifoname[] = "/tmp/tst-cancel4-fifo-XXXXXX";
77 static int fifofd;
79 static void
80 __attribute__ ((used))
81 cl_fifo (void *arg)
83 ++cl_called;
85 unlink (fifoname);
86 close (fifofd);
87 fifofd = -1;
90 struct cancel_tests
92 const char *name;
93 void *(*tf) (void *);
94 int nb;
95 int only_early;
97 #define ADD_TEST(name, nbar, early) { #name, tf_##name, nbar, early }