x86-64: Don't use SSE resolvers for ISA level 3 or above
[glibc.git] / sysdeps / pthread / tst-join3.c
blobea5f37b76fa49d8f4797512e55ffd0f8b68ad4ef
1 /* Copyright (C) 2002-2024 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
18 #include <errno.h>
19 #include <pthread.h>
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23 #include <sys/time.h>
24 #include <support/check.h>
25 #include <support/timespec.h>
26 #include <support/xthread.h>
27 #include <support/xtime.h>
30 #define CLOCK_USE_TIMEDJOIN (-1)
32 static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
35 static void *
36 tf (void *arg)
38 xpthread_mutex_lock (&lock);
39 xpthread_mutex_unlock (&lock);
41 return (void *) 42l;
45 static int
46 do_test_clock (clockid_t clockid)
48 const clockid_t clockid_for_get =
49 (clockid == CLOCK_USE_TIMEDJOIN) ? CLOCK_REALTIME : clockid;
51 xpthread_mutex_lock (&lock);
52 pthread_t th = xpthread_create (NULL, tf, NULL);
54 void *status;
55 struct timespec timeout = timespec_add (xclock_now (clockid_for_get),
56 make_timespec (0, 200000000));
58 int val;
59 if (clockid == CLOCK_USE_TIMEDJOIN)
60 val = pthread_timedjoin_np (th, &status, &timeout);
61 else
62 val = pthread_clockjoin_np (th, &status, clockid, &timeout);
64 TEST_COMPARE (val, ETIMEDOUT);
66 xpthread_mutex_unlock (&lock);
68 while (1)
70 timeout = timespec_add (xclock_now (clockid_for_get),
71 make_timespec (0, 200000000));
73 if (clockid == CLOCK_USE_TIMEDJOIN)
74 val = pthread_timedjoin_np (th, &status, &timeout);
75 else
76 val = pthread_clockjoin_np (th, &status, clockid, &timeout);
77 if (val == 0)
78 break;
80 TEST_COMPARE (val, ETIMEDOUT);
83 if (status != (void *) 42l)
84 FAIL_EXIT1 ("return value %p, expected %p\n", status, (void *) 42l);
86 return 0;
89 static int
90 do_test (void)
92 do_test_clock (CLOCK_USE_TIMEDJOIN);
93 do_test_clock (CLOCK_REALTIME);
94 do_test_clock (CLOCK_MONOTONIC);
95 return 0;
98 #include <support/test-driver.c>