x86-64: Don't use SSE resolvers for ISA level 3 or above
[glibc.git] / sysdeps / pthread / tst-cond27.c
blob71bfb6fa98da3b8f9d39b473782f1475be1f0ef8
1 /* Test pthread_cond_clockwait timeout.
3 Copyright (C) 2019-2024 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 <https://www.gnu.org/licenses/>. */
20 #include <errno.h>
21 #include <pthread.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <time.h>
26 #include <sys/time.h>
27 #include <support/check.h>
28 #include <support/timespec.h>
29 #include <support/xthread.h>
32 static pthread_mutex_t mut = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
33 static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
36 static int
37 do_test_clock (clockid_t clockid)
39 /* Get the mutex. */
40 xpthread_mutex_lock (&mut);
42 /* Waiting for the condition will fail. But we want the timeout here. */
43 const struct timespec ts_now = xclock_now (clockid);
44 const struct timespec ts_timeout =
45 timespec_add (ts_now, make_timespec (0, 500000000));
47 /* In theory pthread_cond_clockwait could return zero here due to
48 spurious wakeup. However that can't happen without a signal or an
49 additional waiter. */
50 TEST_COMPARE (pthread_cond_clockwait (&cond, &mut, clockid, &ts_timeout),
51 ETIMEDOUT);
53 xpthread_mutex_unlock (&mut);
55 return 0;
58 static int
59 do_test (void)
61 do_test_clock (CLOCK_MONOTONIC);
62 do_test_clock (CLOCK_REALTIME);
63 return 0;
66 #include <support/test-driver.c>