LoongArch: Use "$fcsr0" instead of "$r0" in _FPU_{GET,SET}CW
[glibc.git] / sysdeps / pthread / tst-join15.c
blobd1f57cd572c27e2e66231f5d257e5c36e14f75dd
1 /* Check pthread_clockjoin_np clock support.
2 Copyright (C) 2020-2024 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/>. */
19 #include <pthread.h>
20 #include <sys/time.h>
21 #include <unistd.h>
22 #include <errno.h>
24 #include <array_length.h>
25 #include <support/check.h>
26 #include <support/timespec.h>
27 #include <support/xthread.h>
29 static void *
30 tf (void *arg)
32 pause ();
33 return NULL;
37 static int
38 do_test (void)
40 const clockid_t clocks[] = {
41 CLOCK_REALTIME,
42 CLOCK_MONOTONIC,
43 CLOCK_PROCESS_CPUTIME_ID,
44 CLOCK_THREAD_CPUTIME_ID,
45 CLOCK_THREAD_CPUTIME_ID,
46 CLOCK_MONOTONIC_RAW,
47 CLOCK_REALTIME_COARSE,
48 CLOCK_MONOTONIC_COARSE,
49 #ifdef CLOCK_BOOTTIME
50 CLOCK_BOOTTIME,
51 #endif
52 #ifdef CLOCK_REALTIME_ALARM
53 CLOCK_REALTIME_ALARM,
54 #endif
55 #ifdef CLOCK_BOOTTIME_ALARM
56 CLOCK_BOOTTIME_ALARM,
57 #endif
58 #ifdef CLOCK_TAI
59 CLOCK_TAI
60 #endif
63 pthread_t thr = xpthread_create (NULL, tf, NULL);
65 for (int t = 0; t < array_length (clocks); t++)
67 /* Create a valid timeout to check for ETIMEDOUT on valid clocks. */
68 struct timespec tmo;
69 if (clock_gettime (clocks[t], &tmo) == -1)
70 /* For clocks not supported, create a large timeout (it should
71 fail early with EINVAL). */
72 tmo = make_timespec (-1, 0);
73 else
74 tmo = timespec_add (tmo, make_timespec (0, 100000000));
76 int ret = clocks[t] == CLOCK_REALTIME || clocks[t] == CLOCK_MONOTONIC
77 ? ETIMEDOUT : EINVAL;
79 TEST_COMPARE (pthread_clockjoin_np (thr, NULL, clocks[t], &tmo), ret);
82 return 0;
85 #include <support/test-driver.c>