127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
{
return (mutex_new(&mutex) ? YES : NO);
}
int
objc_sync_enter(id obj)
{
size_t i;
if (obj == nil)
return 0;
if (!mutex_lock(&mutex))
return 1;
for (i = 0; i < num_locks; i++) {
if (locks[i].obj == obj) {
if (thread_is_current(locks[i].thread))
locks[i].recursion++;
else {
/* Make sure objc_sync_exit doesn't free it */
locks[i].count++;
|
|
|
|
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
{
return (mutex_new(&mutex) ? YES : NO);
}
int
objc_sync_enter(id obj)
{
int i;
if (obj == nil)
return 0;
if (!mutex_lock(&mutex))
return 1;
for (i = num_locks - 1; i >= 0; i--) {
if (locks[i].obj == obj) {
if (thread_is_current(locks[i].thread))
locks[i].recursion++;
else {
/* Make sure objc_sync_exit doesn't free it */
locks[i].count++;
|
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
return 0;
}
int
objc_sync_exit(id obj)
{
size_t i;
if (obj == nil)
return 0;
if (!mutex_lock(&mutex))
return 1;
for (i = 0; i < num_locks; i++) {
if (locks[i].obj == obj) {
if (locks[i].recursion > 0 &&
thread_is_current(locks[i].thread)) {
locks[i].recursion--;
if (!mutex_unlock(&mutex))
return 1;
|
|
|
|
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
return 0;
}
int
objc_sync_exit(id obj)
{
int i;
if (obj == nil)
return 0;
if (!mutex_lock(&mutex))
return 1;
for (i = num_locks - 1; i >= 0; i--) {
if (locks[i].obj == obj) {
if (locks[i].recursion > 0 &&
thread_is_current(locks[i].thread)) {
locks[i].recursion--;
if (!mutex_unlock(&mutex))
return 1;
|