View | Details | Raw Unified | Return to bug 11588 | Differences between
and this patch

Collapse All | Expand All

(-)a/nptl/Makefile (+1 lines)
Lines 217-222 tests = tst-typesizes \ Link Here
217
	tst-cond14 tst-cond15 tst-cond16 tst-cond17 tst-cond18 tst-cond19 \
217
	tst-cond14 tst-cond15 tst-cond16 tst-cond17 tst-cond18 tst-cond19 \
218
	tst-cond20 tst-cond21 tst-cond22 tst-cond23 tst-cond24 tst-cond25 \
218
	tst-cond20 tst-cond21 tst-cond22 tst-cond23 tst-cond24 tst-cond25 \
219
	tst-cond-except \
219
	tst-cond-except \
220
	tst-condpi1 \
220
	tst-robust1 tst-robust2 tst-robust3 tst-robust4 tst-robust5 \
221
	tst-robust1 tst-robust2 tst-robust3 tst-robust4 tst-robust5 \
221
	tst-robust6 tst-robust7 tst-robust8 tst-robust9 \
222
	tst-robust6 tst-robust7 tst-robust8 tst-robust9 \
222
	tst-robustpi1 tst-robustpi2 tst-robustpi3 tst-robustpi4 tst-robustpi5 \
223
	tst-robustpi1 tst-robustpi2 tst-robustpi3 tst-robustpi4 tst-robustpi5 \
(-)a/nptl/tst-condpi1.c (-1 / +121 lines)
Line 0 Link Here
0
- 
1
/* Copyright (C) 2002, 2010, 2013 Free Software Foundation, Inc.
2
   This file is part of the GNU C Library.
3
   Contributed by Darren Hart <dvhltc@us.ibm.com>
4
   Based on test-cond1.c by Ulrich Drepper <drepper@redhat.com>
5
6
   The GNU C Library is free software; you can redistribute it and/or
7
   modify it under the terms of the GNU Lesser General Public
8
   License as published by the Free Software Foundation; either
9
   version 2.1 of the License, or (at your option) any later version.
10
11
   The GNU C Library is distributed in the hope that it will be useful,
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
   Lesser General Public License for more details.
15
16
   You should have received a copy of the GNU Lesser General Public
17
   License along with the GNU C Library; if not, see
18
   <http://www.gnu.org/licenses/>.  */
19
20
#include <error.h>
21
#include <pthread.h>
22
#include <stdio.h>
23
#include <stdlib.h>
24
25
26
static pthread_cond_t cond;
27
static pthread_mutex_t mut;
28
29
30
static void *
31
tf (void *p)
32
{
33
  int err;
34
35
  err = pthread_mutex_lock (&mut);
36
  if (err != 0)
37
    error (EXIT_FAILURE, err, "child: cannot get mutex");
38
39
  puts ("child: got mutex; signalling");
40
41
  pthread_cond_signal (&cond);
42
43
  puts ("child: unlock");
44
45
  err = pthread_mutex_unlock (&mut);
46
  if (err != 0)
47
    error (EXIT_FAILURE, err, "child: cannot unlock");
48
49
  puts ("child: done");
50
51
  return NULL;
52
}
53
54
55
static int
56
do_test (void)
57
{
58
  pthread_t th;
59
  int err;
60
61
  pthread_mutexattr_t ma;
62
  pthread_condattr_t ca;
63
64
  printf ("&cond = %p\n&mut = %p\n", &cond, &mut);
65
66
  puts ("parent: setup condvar");
67
68
  err = pthread_condattr_init(&ca);
69
  if (err != 0)
70
    error (EXIT_FAILURE, err, "parent: failed to init condattr");
71
  err = pthread_condattr_setprotocol_np(&ca, PTHREAD_PRIO_INHERIT);
72
  if (err != 0)
73
    error (EXIT_FAILURE, err, "parent: failed to set condattr protocol");
74
  err = pthread_cond_init(&cond, &ca);
75
  if (err != 0)
76
    error (EXIT_FAILURE, err, "parent: failed to init condvar");
77
78
  puts ("parent: setup mutex");
79
80
  err = pthread_mutexattr_init(&ma);
81
  if (err != 0)
82
    error (EXIT_FAILURE, err, "parent: failed to init mutexattr");
83
  err = pthread_mutexattr_setprotocol(&ma, PTHREAD_PRIO_INHERIT);
84
  if (err != 0)
85
    error (EXIT_FAILURE, err, "parent: failed to set mutexattr protocol");
86
  err = pthread_mutex_init(&mut, &ma);
87
  if (err != 0)
88
    error (EXIT_FAILURE, err, "parent: failed to init mutex");
89
90
  puts ("parent: get mutex");
91
92
  err = pthread_mutex_lock (&mut);
93
  if (err != 0)
94
    error (EXIT_FAILURE, err, "parent: cannot get mutex");
95
96
  puts ("parent: create child");
97
98
  err = pthread_create (&th, NULL, tf, NULL);
99
  if (err != 0)
100
    error (EXIT_FAILURE, err, "parent: cannot create thread");
101
102
  puts ("parent: wait for condition");
103
104
  err = pthread_cond_wait (&cond, &mut);
105
  if (err != 0)
106
    error (EXIT_FAILURE, err, "parent: cannot wait fir signal");
107
108
  puts ("parent: got signal");
109
110
  err = pthread_join (th, NULL);
111
  if (err != 0)
112
    error (EXIT_FAILURE, err, "parent: failed to join");
113
114
  puts ("done");
115
116
  return 0;
117
}
118
119
120
#define TEST_FUNCTION do_test ()
121
#include "../test-skeleton.c"

Return to bug 11588