1 /* pthread_timedjoin_np, pthread_clockjoin_np NULL timeout test.
2 Copyright (C) 2019-2020 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
25 #include <support/check.h>
26 #include <support/timespec.h>
27 #include <support/xthread.h>
28 #include <support/xtime.h>
31 #define CLOCK_USE_TIMEDJOIN (-1)
37 struct timespec ts
= make_timespec(0, 100000);
44 /* Check that pthread_timedjoin_np and pthread_clockjoin_np wait "forever" if
45 * passed a timeout parameter of NULL. We can't actually wait forever, but we
46 * can be sure that we did at least wait for some time by checking the exit
47 * status of the thread. */
49 do_test_clock (clockid_t clockid
)
51 pthread_t th
= xpthread_create (NULL
, tf
, NULL
);
54 int val
= (clockid
== CLOCK_USE_TIMEDJOIN
)
55 ? pthread_timedjoin_np (th
, &status
, NULL
)
56 : pthread_clockjoin_np (th
, &status
, clockid
, NULL
);
57 TEST_COMPARE (val
, 0);
59 if (status
!= (void *) 42l)
60 FAIL_EXIT1 ("return value %p, expected %p\n", status
, (void *) 42l);
68 do_test_clock (CLOCK_USE_TIMEDJOIN
);
69 do_test_clock (CLOCK_REALTIME
);
70 do_test_clock (CLOCK_MONOTONIC
);
74 #include <support/test-driver.c>