1 /* Check if pthread_mutex_clocklock with PRIO_INHERIT fails with clock
2 different than CLOCK_REALTIME.
3 Copyright (C) 2020-2021 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/>. */
22 #include <array_length.h>
24 #include <support/check.h>
25 #include <support/xthread.h>
26 #include <support/timespec.h>
33 PTHREAD_MUTEX_ERRORCHECK
,
34 PTHREAD_MUTEX_RECURSIVE
,
35 PTHREAD_MUTEX_ADAPTIVE_NP
37 const int robust
[] = {
38 PTHREAD_MUTEX_STALLED
,
43 for (int t
= 0; t
< array_length (types
); t
++)
44 for (int r
= 0; r
< array_length (robust
); r
++)
46 pthread_mutexattr_t attr
;
48 xpthread_mutexattr_init (&attr
);
49 xpthread_mutexattr_setprotocol (&attr
, PTHREAD_PRIO_INHERIT
);
50 xpthread_mutexattr_settype (&attr
, types
[t
]);
51 xpthread_mutexattr_setrobust (&attr
, robust
[r
]);
54 xpthread_mutex_init (&mtx
, &attr
);
56 struct timespec tmo
= timespec_add (xclock_now (CLOCK_MONOTONIC
),
57 make_timespec (0, 100000000));
59 TEST_COMPARE (pthread_mutex_clocklock (&mtx
, CLOCK_MONOTONIC
, &tmo
),
62 xpthread_mutex_destroy (&mtx
);
68 #include <support/test-driver.c>