ObjFW  Diff

Differences From Artifact [7ae92c5eec]:

To Artifact [695579ca2f]:


26
27
28
29
30
31
32

33
34

35
36
37
38
39
40
41
42
26
27
28
29
30
31
32
33
34

35

36
37
38
39
40
41
42







+

-
+
-







#ifdef OF_APPLE_RUNTIME
# import <objc/runtime.h>
#endif
#ifdef OF_GNU_RUNTIME
# import <objc/sarray.h>
#endif

#ifdef OF_ATOMIC_OPS
#import "atomic.h"

#else
#ifndef OF_ATOMIC_OPS
#import "threading.h"
#endif

struct pre_ivar {
	void	      **memchunks;
	size_t	      memchunks_size;
	int32_t	      retain_count; /* int32_t because atomic ops use int32_t */
508
509
510
511
512
513
514
515

516

517

518
519
520
521
522
523

524
525
526

527
528
529
530
531
532
533
508
509
510
511
512
513
514

515
516
517

518
519
520
521
522
523

524
525
526

527
528
529
530
531
532
533
534







-
+

+
-
+





-
+


-
+







	PRE_IVAR->retain_count++;
	assert(of_spinlock_unlock(&PRE_IVAR->retain_spinlock));
#endif

	return self;
}

- (int32_t)retainCount
- (size_t)retainCount
{
	assert(PRE_IVAR->retain_count >= 0);
	return PRE_IVAR->retain_count;
	return (size_t)PRE_IVAR->retain_count;
}

- (void)release
{
#ifdef OF_ATOMIC_OPS
	if (!of_atomic_dec32(&PRE_IVAR->retain_count))
	if (of_atomic_dec32(&PRE_IVAR->retain_count) <= 0)
		[self dealloc];
#else
	int32_t c;
	size_t c;

	assert(of_spinlock_lock(&PRE_IVAR->retain_spinlock));
	c = --PRE_IVAR->retain_count;
	assert(of_spinlock_unlock(&PRE_IVAR->retain_spinlock));

	if (!c)
		[self dealloc];
623
624
625
626
627
628
629
630

631
632

633
634
635
636
637
638
639
624
625
626
627
628
629
630

631
632

633
634
635
636
637
638
639
640







-
+

-
+







}

+ autorelease
{
	return self;
}

+ (int32_t)retainCount
+ (size_t)retainCount
{
	return INT32_MAX;
	return SIZE_MAX;
}

+ (void)release
{
}

+ (void)dealloc