348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
|
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
|
-
+
+
-
+
+
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
|
/*
* There is no objc_initializeClassPair in 10.5.
* However, objc_allocateClassPair does not register the new class with
* the subclass in the ObjC1 runtime like the ObjC2 runtime does, so
* this workaround should be fine.
*/
if ((tmp = objc_allocateClassPair(self, "OFStackBlock", 0)) == NULL)
@throw [OFInitializationFailedException newWithClass: self];
@throw [OFInitializationFailedException
exceptionWithClass: self];
memcpy(&_NSConcreteStackBlock, tmp, sizeof(_NSConcreteStackBlock));
free(tmp);
objc_registerClassPair((Class)&_NSConcreteStackBlock);
if ((tmp = objc_allocateClassPair(self, "OFGlobalBlock", 0)) == NULL)
@throw [OFInitializationFailedException newWithClass: self];
@throw [OFInitializationFailedException
exceptionWithClass: self];
memcpy(&_NSConcreteGlobalBlock, tmp, sizeof(_NSConcreteGlobalBlock));
free(tmp);
objc_registerClassPair((Class)&_NSConcreteGlobalBlock);
if ((tmp = objc_allocateClassPair(self, "OFMallocBlock", 0)) == NULL)
@throw [OFInitializationFailedException newWithClass: self];
@throw [OFInitializationFailedException
exceptionWithClass: 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
newWithClass: self];
exceptionWithClass: self];
}
#endif
+ alloc
{
@throw [OFNotImplementedException newWithClass: self
selector: _cmd];
@throw [OFNotImplementedException exceptionWithClass: self
selector: _cmd];
}
- init
{
@throw [OFNotImplementedException newWithClass: isa
selector: _cmd];
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)addMemoryToPool: (void*)ptr
{
@throw [OFNotImplementedException newWithClass: isa
selector: _cmd];
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void*)allocMemoryWithSize: (size_t)size
{
@throw [OFNotImplementedException newWithClass: isa
selector: _cmd];
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void*)allocMemoryForNItems: (size_t)nitems
withSize: (size_t)size
{
@throw [OFNotImplementedException newWithClass: isa
selector: _cmd];
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void*)resizeMemory: (void*)ptr
toSize: (size_t)size
{
@throw [OFNotImplementedException newWithClass: isa
selector: _cmd];
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void*)resizeMemory: (void*)ptr
toNItems: (size_t)nitems
withSize: (size_t)size
{
@throw [OFNotImplementedException newWithClass: isa
selector: _cmd];
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)freeMemory: (void*)ptr
{
@throw [OFNotImplementedException newWithClass: isa
selector: _cmd];
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- retain
{
if (isa == (Class)&_NSConcreteMallocBlock)
return Block_copy(self);
|
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
|
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
|
-
-
+
+
|
{
if (isa == (Class)&_NSConcreteMallocBlock)
Block_release(self);
}
- (void)dealloc
{
@throw [OFNotImplementedException newWithClass: isa
selector: _cmd];
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
@end
#if defined(OF_APPLE_RUNTIME) && defined(__OBJC2__)
@implementation OFStackBlock
+ (void)load
|