sparc: Fix .udiv plt on libc
[glibc.git] / nptl / tst-cancel4_1.c
blob05b5f7bfd02d7db70ddf27cd68c7b0b672468251
1 /* Check sendmmsg cancellation.
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 <stdio.h>
21 #include <stddef.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <sys/types.h>
25 #include <sys/socket.h>
26 #include <sys/un.h>
27 #include <sys/ipc.h>
28 #include <sys/msg.h>
29 #include <unistd.h>
30 #include <errno.h>
31 #include <pthread.h>
33 #include "tst-cancel4-common.h"
35 static void *
36 tf_sendmmsg (void *arg)
38 if (arg == NULL)
39 // XXX If somebody can provide a portable test case in which sendmmsg()
40 // blocks we can enable this test to run in both rounds.
41 abort ();
43 struct sockaddr_un sun;
45 tempfd = socket (AF_UNIX, SOCK_DGRAM, 0);
46 if (tempfd == -1)
48 printf ("%s: first socket call failed\n", __FUNCTION__);
49 exit (1);
52 int tries = 0;
55 if (++tries > 10)
57 printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
60 strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-7-XXXXXX");
61 if (mktemp (sun.sun_path) == NULL)
63 printf ("%s: cannot generate temp file name\n", __FUNCTION__);
64 exit (1);
67 sun.sun_family = AF_UNIX;
69 while (bind (tempfd, (struct sockaddr *) &sun,
70 offsetof (struct sockaddr_un, sun_path)
71 + strlen (sun.sun_path) + 1) != 0);
72 tempfname = strdup (sun.sun_path);
74 tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0);
75 if (tempfd2 == -1)
77 printf ("%s: second socket call failed\n", __FUNCTION__);
78 exit (1);
81 int r = pthread_barrier_wait (&b2);
82 if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
84 printf ("%s: barrier_wait failed\n", __FUNCTION__);
85 exit (1);
88 r = pthread_barrier_wait (&b2);
89 if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
91 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
92 exit (1);
95 pthread_cleanup_push (cl, NULL);
97 char mem[1];
98 struct iovec iov[1];
99 iov[0].iov_base = mem;
100 iov[0].iov_len = 1;
102 struct mmsghdr mm;
103 mm.msg_hdr.msg_name = &sun;
104 mm.msg_hdr.msg_namelen = (offsetof (struct sockaddr_un, sun_path)
105 + strlen (sun.sun_path) + 1);
106 mm.msg_hdr.msg_iov = iov;
107 mm.msg_hdr.msg_iovlen = 1;
108 mm.msg_hdr.msg_control = NULL;
109 mm.msg_hdr.msg_controllen = 0;
111 ssize_t ret = sendmmsg (tempfd2, &mm, 1, 0);
112 if (ret == -1 && errno == ENOSYS)
113 exit (77);
115 pthread_cleanup_pop (0);
117 printf ("%s: sendmmsg returned\n", __FUNCTION__);
119 exit (1);
122 struct cancel_tests tests[] =
124 ADD_TEST (sendmmsg, 2, 1),
126 #define ntest_tf (sizeof (tests) / sizeof (tests[0]))
128 #include "tst-cancel4-common.c"