177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
return copy;
}
if (block->isa == (Class)&_NSConcreteMallocBlock) {
#if defined(OF_ATOMIC_OPS)
of_atomic_inc_int(&block->flags);
#else
# ifdef OF_THREADS
unsigned hash = SPINLOCK_HASH(block);
assert(of_spinlock_lock(&spinlocks[hash]));
# endif
block->flags++;
# ifdef OF_THREADS
assert(of_spinlock_unlock(&spinlocks[hash]));
# endif
#endif
}
return block;
}
void
|
<
<
<
<
<
<
|
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
return copy;
}
if (block->isa == (Class)&_NSConcreteMallocBlock) {
#if defined(OF_ATOMIC_OPS)
of_atomic_inc_int(&block->flags);
#else
unsigned hash = SPINLOCK_HASH(block);
assert(of_spinlock_lock(&spinlocks[hash]));
block->flags++;
assert(of_spinlock_unlock(&spinlocks[hash]));
#endif
}
return block;
}
void
|
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
|
if ((of_atomic_dec_int(&block->flags) & OF_BLOCK_REFCOUNT_MASK) == 0) {
if (block->flags & OF_BLOCK_HAS_COPY_DISPOSE)
block->descriptor->dispose_helper(block);
free(block);
}
#else
# ifdef OF_THREADS
unsigned hash = SPINLOCK_HASH(block);
assert(of_spinlock_lock(&spinlocks[hash]));
# endif
if ((--block->flags & OF_BLOCK_REFCOUNT_MASK) == 0) {
# ifdef OF_THREADS
assert(of_spinlock_unlock(&spinlocks[hash]));
# endif
if (block->flags & OF_BLOCK_HAS_COPY_DISPOSE)
block->descriptor->dispose_helper(block);
free(block);
}
# ifdef OF_THREADS
assert(of_spinlock_unlock(&spinlocks[hash]));
# endif
#endif
}
void
_Block_object_assign(void *dst_, const void *src_, const int flags_)
{
int flags = flags_ & (OF_BLOCK_FIELD_IS_BLOCK |
|
<
<
<
<
<
<
<
<
|
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
if ((of_atomic_dec_int(&block->flags) & OF_BLOCK_REFCOUNT_MASK) == 0) {
if (block->flags & OF_BLOCK_HAS_COPY_DISPOSE)
block->descriptor->dispose_helper(block);
free(block);
}
#else
unsigned hash = SPINLOCK_HASH(block);
assert(of_spinlock_lock(&spinlocks[hash]));
if ((--block->flags & OF_BLOCK_REFCOUNT_MASK) == 0) {
assert(of_spinlock_unlock(&spinlocks[hash]));
if (block->flags & OF_BLOCK_HAS_COPY_DISPOSE)
block->descriptor->dispose_helper(block);
free(block);
}
assert(of_spinlock_unlock(&spinlocks[hash]));
#endif
}
void
_Block_object_assign(void *dst_, const void *src_, const int flags_)
{
int flags = flags_ & (OF_BLOCK_FIELD_IS_BLOCK |
|
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
|
@throw [OFInitializationFailedException newWithClass: self];
memcpy(&_NSConcreteMallocBlock, tmp, sizeof(_NSConcreteMallocBlock));
free(tmp);
objc_registerClassPair((Class)&_NSConcreteMallocBlock);
}
#endif
#if !defined(OF_ATOMIC_OPS) && defined(OF_THREADS)
+ (void)initialize
{
size_t i;
for (i = 0; i < NUM_SPINLOCKS; i++)
if (!of_spinlock_new(&spinlocks[i]))
@throw [OFInitializationFailedException
|
|
|
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
|
@throw [OFInitializationFailedException newWithClass: self];
memcpy(&_NSConcreteMallocBlock, tmp, sizeof(_NSConcreteMallocBlock));
free(tmp);
objc_registerClassPair((Class)&_NSConcreteMallocBlock);
}
#endif
#if !defined(OF_ATOMIC_OPS)
+ (void)initialize
{
size_t i;
for (i = 0; i < NUM_SPINLOCKS; i++)
if (!of_spinlock_new(&spinlocks[i]))
@throw [OFInitializationFailedException
|