1 /* Copyright (C) 2003 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, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
28 static pthread_cond_t cond
= PTHREAD_COND_INITIALIZER
;
29 static pthread_mutex_t mut
= PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
;
35 int err
= pthread_cond_wait (&cond
, &mut
);
38 puts ("cond_wait did not fail");
44 printf ("cond_wait didn't return EPERM but %d\n", err
);
51 (void) gettimeofday (&tv
, NULL
);
52 /* +1000 seconds in correct format. */
54 TIMEVAL_TO_TIMESPEC (&tv
, &ts
);
57 err
= pthread_cond_timedwait (&cond
, &mut
, &ts
);
60 puts ("cond_timedwait did not fail");
66 printf ("cond_timedwait didn't return EPERM but %d\n", err
);
80 printf ("&cond = %p\n&mut = %p\n", &cond
, &mut
);
82 err
= pthread_cond_wait (&cond
, &mut
);
85 puts ("cond_wait did not fail");
91 printf ("cond_wait didn't return EPERM but %d\n", err
);
98 (void) gettimeofday (&tv
, NULL
);
99 /* +1000 seconds in correct format. */
101 TIMEVAL_TO_TIMESPEC (&tv
, &ts
);
104 err
= pthread_cond_timedwait (&cond
, &mut
, &ts
);
107 puts ("cond_timedwait did not fail");
113 printf ("cond_timedwait didn't return EPERM but %d\n", err
);
117 if (pthread_mutex_lock (&mut
) != 0)
119 puts ("parent: mutex_lock failed");
123 puts ("creating thread");
125 if (pthread_create (&th
, NULL
, tf
, NULL
) != 0)
127 puts ("create failed");
132 if (pthread_join (th
, &r
) != 0)
134 puts ("join failed");
137 if (r
!= (void *) 1l)
139 puts ("thread has wrong return value");
149 #define TEST_FUNCTION do_test ()
150 #include "../test-skeleton.c"