57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
unsigned long version, info, instance_size;
void *ivars, *methodlist, *dtable, *subclass_list, *sibling_class;
void *protocols, *gc_object_type;
long abi_version;
void *ivar_offsets, *properties;
};
enum objc_abi_class_info {
OBJC_CLASS_INFO_CLASS = 0x01,
OBJC_CLASS_INFO_METACLASS = 0x02
};
extern void __objc_exec_class(void*);
/* Begin of ObjC module */
static struct objc_abi_metaclass _NSConcreteStackBlock_metaclass = {
"OFBlock", "OFBlock", "OFStackBlock", 8, OBJC_CLASS_INFO_METACLASS,
sizeof(struct objc_class), NULL, NULL
|
>
>
>
|
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
unsigned long version, info, instance_size;
void *ivars, *methodlist, *dtable, *subclass_list, *sibling_class;
void *protocols, *gc_object_type;
long abi_version;
void *ivar_offsets, *properties;
};
#ifndef OF_OBJFW_RUNTIME
/* ObjFW-RT already defines those */
enum objc_abi_class_info {
OBJC_CLASS_INFO_CLASS = 0x01,
OBJC_CLASS_INFO_METACLASS = 0x02
};
#endif
extern void __objc_exec_class(void*);
/* Begin of ObjC module */
static struct objc_abi_metaclass _NSConcreteStackBlock_metaclass = {
"OFBlock", "OFBlock", "OFStackBlock", 8, OBJC_CLASS_INFO_METACLASS,
sizeof(struct objc_class), NULL, NULL
|
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
|
<
<
<
<
<
<
|
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
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 |
|
<
<
<
<
<
<
<
<
|
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
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
|
|
|
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
|
@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
|