1 /* Copyright (C) 2003-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/>. */
26 static pthread_cond_t cond
= PTHREAD_COND_INITIALIZER
;
27 static pthread_mutex_t mut
= PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
;
33 int err
= pthread_cond_wait (&cond
, &mut
);
36 puts ("cond_wait did not fail");
42 printf ("cond_wait didn't return EPERM but %d\n", err
);
49 (void) gettimeofday (&tv
, NULL
);
50 /* +1000 seconds in correct format. */
52 TIMEVAL_TO_TIMESPEC (&tv
, &ts
);
55 err
= pthread_cond_timedwait (&cond
, &mut
, &ts
);
58 puts ("cond_timedwait did not fail");
64 printf ("cond_timedwait didn't return EPERM but %d\n", err
);
78 printf ("&cond = %p\n&mut = %p\n", &cond
, &mut
);
80 err
= pthread_cond_wait (&cond
, &mut
);
83 puts ("cond_wait did not fail");
89 printf ("cond_wait didn't return EPERM but %d\n", err
);
96 (void) gettimeofday (&tv
, NULL
);
97 /* +1000 seconds in correct format. */
99 TIMEVAL_TO_TIMESPEC (&tv
, &ts
);
102 err
= pthread_cond_timedwait (&cond
, &mut
, &ts
);
105 puts ("cond_timedwait did not fail");
111 printf ("cond_timedwait didn't return EPERM but %d\n", err
);
115 if (pthread_mutex_lock (&mut
) != 0)
117 puts ("parent: mutex_lock failed");
121 puts ("creating thread");
123 if (pthread_create (&th
, NULL
, tf
, NULL
) != 0)
125 puts ("create failed");
130 if (pthread_join (th
, &r
) != 0)
132 puts ("join failed");
135 if (r
!= (void *) 1l)
137 puts ("thread has wrong return value");
147 #define TEST_FUNCTION do_test ()
148 #include "../test-skeleton.c"