1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
Index: libpthread/sysdeps/generic/pt-mutex-timedlock.c
===================================================================
RCS file: /sources/hurd/hurd-l4/libpthread/sysdeps/generic/pt-mutex-timedlock.c,v
retrieving revision 1.4
diff -u -p -r1.4 pt-mutex-timedlock.c
--- libpthread/sysdeps/generic/pt-mutex-timedlock.c 22 Jun 2008 08:58:20 -0000 1.4
+++ libpthread/sysdeps/generic/pt-mutex-timedlock.c 1 Oct 2008 10:37:20 -0000
@@ -36,6 +36,7 @@ __pthread_mutex_timedlock_internal (stru
if (__pthread_spin_trylock (&mutex->__held) == 0)
/* Successfully acquired the lock. */
{
+#ifdef ALWAYS_TRACK_OWNER
#ifndef NDEBUG
self = _pthread_self ();
if (self)
@@ -47,6 +48,7 @@ __pthread_mutex_timedlock_internal (stru
mutex->owner = _pthread_self ();
}
#endif
+#endif
if (mutex->attr)
switch (mutex->attr->mutex_type)
@@ -73,14 +75,16 @@ __pthread_mutex_timedlock_internal (stru
self = _pthread_self ();
assert (self);
- if (mutex->attr)
+ if (! mutex->attr || mutex->attr->mutex_type == PTHREAD_MUTEX_NORMAL)
+ {
+#if defined(ALWAYS_TRACK_MUTEX_OWNER)
+ assert (mutex->owner != self);
+#endif
+ }
+ else
{
switch (mutex->attr->mutex_type)
{
- case PTHREAD_MUTEX_NORMAL:
- assert (mutex->owner != self);
- break;
-
case PTHREAD_MUTEX_ERRORCHECK:
if (mutex->owner == self)
{
@@ -102,10 +106,11 @@ __pthread_mutex_timedlock_internal (stru
LOSE;
}
}
- else
- assert (mutex->owner != self);
- assert (mutex->owner);
+#if !defined(ALWAYS_TRACK_MUTEX_OWNER)
+ if (mutex->attr && mutex->attr->mutex_type != PTHREAD_MUTEX_NORMAL)
+#endif
+ assert (mutex->owner);
if (abstime && (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000))
return EINVAL;
@@ -141,9 +146,12 @@ __pthread_mutex_timedlock_internal (stru
else
__pthread_block (self);
-#ifndef NDEBUG
- assert (mutex->owner == self);
+#if !defined(ALWAYS_TRACK_MUTEX_OWNER)
+ if (mutex->attr && mutex->attr->mutex_type != PTHREAD_MUTEX_NORMAL)
#endif
+ {
+ assert (mutex->owner == self);
+ }
if (mutex->attr)
switch (mutex->attr->mutex_type)
Index: libpthread/sysdeps/generic/pt-mutex-transfer-np.c
===================================================================
RCS file: /sources/hurd/hurd-l4/libpthread/sysdeps/generic/pt-mutex-transfer-np.c,v
retrieving revision 1.1
diff -u -p -r1.1 pt-mutex-transfer-np.c
--- libpthread/sysdeps/generic/pt-mutex-transfer-np.c 1 Mar 2008 13:07:22 -0000 1.1
+++ libpthread/sysdeps/generic/pt-mutex-transfer-np.c 1 Oct 2008 10:37:20 -0000
@@ -45,7 +45,12 @@ __pthread_mutex_transfer_np (struct __pt
}
#ifndef NDEBUG
- mutex->owner = thread;
+# if !defined(ALWAYS_TRACK_MUTEX_OWNER)
+ if (mutex->attr && mutex->attr->mutex_type != PTHREAD_MUTEX_NORMAL)
+# endif
+ {
+ mutex->owner = thread;
+ }
#endif
return 0;
Index: libpthread/sysdeps/generic/pt-mutex-unlock.c
===================================================================
RCS file: /sources/hurd/hurd-l4/libpthread/sysdeps/generic/pt-mutex-unlock.c,v
retrieving revision 1.5
diff -u -p -r1.5 pt-mutex-unlock.c
--- libpthread/sysdeps/generic/pt-mutex-unlock.c 22 Jun 2008 09:16:45 -0000 1.5
+++ libpthread/sysdeps/generic/pt-mutex-unlock.c 1 Oct 2008 10:37:20 -0000
@@ -33,7 +33,8 @@ __pthread_mutex_unlock (pthread_mutex_t
if (! mutex->attr || mutex->attr->mutex_type == PTHREAD_MUTEX_NORMAL)
{
-#ifndef NDEBUG
+#if defined(ALWAYS_TRACK_MUTEX_OWNER)
+# ifndef NDEBUG
if (_pthread_self ())
{
assert (mutex->owner);
@@ -45,6 +46,7 @@ __pthread_mutex_unlock (pthread_mutex_t
_pthread_self ()->threadid);
mutex->owner = NULL;
}
+# endif
#endif
}
else
@@ -84,7 +86,12 @@ __pthread_mutex_unlock (pthread_mutex_t
__pthread_dequeue (wakeup);
#ifndef NDEBUG
- mutex->owner = wakeup;
+# if !defined (ALWAYS_TRACK_MUTEX_OWNER)
+ if (mutex->attr && mutex->attr->mutex_type != PTHREAD_MUTEX_NORMAL)
+# endif
+ {
+ mutex->owner = wakeup;
+ }
#endif
/* We do not unlock MUTEX->held: we are transferring the ownership
Index: libpthread/sysdeps/generic/pt-mutex-trylock.c
===================================================================
RCS file: /cvsroot/hurd/hurd/libpthread/sysdeps/generic/pt-mutex-trylock.c,v
retrieving revision 1.7
diff -u -p -r1.7 pt-mutex-trylock.c
--- libpthread/sysdeps/generic/pt-mutex-trylock.c 12 Aug 2008 15:07:49 -0000 1.7
+++ libpthread/sysdeps/generic/pt-mutex-trylock.c 29 Apr 2009 08:20:19 -0000
@@ -34,6 +34,7 @@ __pthread_mutex_trylock (struct __pthrea
if (__pthread_spin_trylock (&mutex->__held) == 0)
/* Acquired the lock. */
{
+#if defined(ALWAYS_TRACK_MUTEX_OWNER)
#ifndef NDEBUG
self = _pthread_self ();
if (self)
@@ -45,6 +46,7 @@ __pthread_mutex_trylock (struct __pthrea
mutex->owner = _pthread_self ();
}
#endif
+#endif
if (mutex->attr)
switch (mutex->attr->mutex_type)
|