1 /* Copyright (C) 2003-2017 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
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 <http://www.gnu.org/licenses/>. */
27 static pthread_cond_t cond
= PTHREAD_COND_INITIALIZER
;
28 static pthread_mutex_t mut
= PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
;
34 int err
= pthread_cond_wait (&cond
, &mut
);
37 puts ("cond_wait did not fail");
43 printf ("cond_wait didn't return EPERM but %d\n", err
);
50 (void) gettimeofday (&tv
, NULL
);
51 /* +1000 seconds in correct format. */
53 TIMEVAL_TO_TIMESPEC (&tv
, &ts
);
56 err
= pthread_cond_timedwait (&cond
, &mut
, &ts
);
59 puts ("cond_timedwait did not fail");
65 printf ("cond_timedwait didn't return EPERM but %d\n", err
);
79 printf ("&cond = %p\n&mut = %p\n", &cond
, &mut
);
81 err
= pthread_cond_wait (&cond
, &mut
);
84 puts ("cond_wait did not fail");
90 printf ("cond_wait didn't return EPERM but %d\n", err
);
97 (void) gettimeofday (&tv
, NULL
);
98 /* +1000 seconds in correct format. */
100 TIMEVAL_TO_TIMESPEC (&tv
, &ts
);
103 err
= pthread_cond_timedwait (&cond
, &mut
, &ts
);
106 puts ("cond_timedwait did not fail");
112 printf ("cond_timedwait didn't return EPERM but %d\n", err
);
116 if (pthread_mutex_lock (&mut
) != 0)
118 puts ("parent: mutex_lock failed");
122 puts ("creating thread");
124 if (pthread_create (&th
, NULL
, tf
, NULL
) != 0)
126 puts ("create failed");
131 if (pthread_join (th
, &r
) != 0)
133 puts ("join failed");
136 if (r
!= (void *) 1l)
138 puts ("thread has wrong return value");
148 #define TEST_FUNCTION do_test ()
149 #include "../test-skeleton.c"