ObjFW  Check-in [8fbc6b4e63]

Overview
Comment:OFBlock: Initialize spinlocks in +[load].

As most blocks are static instances, there's a chance +[initialize] is
never called.

As a nice side effect, this also fixes the bug that the spinlocks were
initialized multiple times.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 8fbc6b4e638152b5d465522fbb8952f26983082ddb49ac7c165fc79418496119
User & Date: js on 2013-07-04 14:04:38
Other Links: manifest | tags
Context
2013-07-04
20:49
Fix -[replaceCharactersInRange:withString:]. check-in: 4d892e0db1 user: js tags: trunk
14:04
OFBlock: Initialize spinlocks in +[load]. check-in: 8fbc6b4e63 user: js tags: trunk
13:59
Remove useless barriers. check-in: 0fea69d149 user: js tags: trunk
Changes

Modified src/OFBlock.m from [e7f8997037] to [84017da3fd].

311
312
313
314
315
316
317
318
319
320










321
322
323

324
325
326
327
328
329
330
311
312
313
314
315
316
317

318
319
320
321
322
323
324
325
326
327
328
329
330
331

332
333
334
335
336
337
338
339







-


+
+
+
+
+
+
+
+
+
+


-
+







			free(obj);
		}
		break;
	}
}

@implementation OFBlock
#ifdef OF_APPLE_RUNTIME
+ (void)load
{
#ifndef OF_HAVE_ATOMIC_OPS
	size_t i;

	for (i = 0; i < NUM_SPINLOCKS; i++)
		if (!of_spinlock_new(&spinlocks[i]))
			@throw [OFInitializationFailedException
			    exceptionWithClass: self];
#endif

#ifdef OF_APPLE_RUNTIME
	Class tmp;

#ifdef __OBJC2__
# ifdef __OBJC2__
	tmp = objc_initializeClassPair(self, "OFStackBlock",
	    (Class)&_NSConcreteStackBlock,
	    (Class)&_NSConcreteStackBlock_metaclass);
	if (tmp == Nil)
		@throw [OFInitializationFailedException
		    exceptionWithClass: self];
	objc_registerClassPair(tmp);
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
377
378
379
380
381
382
383

384

385











386
387
388
389
390
391
392







-

-
+
-
-
-
-
-
-
-
-
-
-
-







	if ((tmp = objc_allocateClassPair(self, "OFMallocBlock", 0)) == NULL)
		@throw [OFInitializationFailedException
		    exceptionWithClass: self];
	memcpy(&_NSConcreteMallocBlock, tmp, sizeof(_NSConcreteMallocBlock));
	free(tmp);
	objc_registerClassPair((Class)&_NSConcreteMallocBlock);
# endif
}
#endif

}
#ifndef OF_HAVE_ATOMIC_OPS
+ (void)initialize
{
	size_t i;

	for (i = 0; i < NUM_SPINLOCKS; i++)
		if (!of_spinlock_new(&spinlocks[i]))
			@throw [OFInitializationFailedException
			    exceptionWithClass: self];
}
#endif

+ alloc
{
	[self doesNotRecognizeSelector: _cmd];
	abort();
}