ObjFW  Diff

Differences From Artifact [e9bfb6f639]:

  • File src/runtime/property.m — part of check-in [fe2cbe0021] at 2018-04-22 16:13:04 on branch trunk — runtime: Define BOOL to be the same as bool

    As we define the ABI, we can just replace BOOL with bool everywhere,
    including in ObjFW itself. For the Apple platforms where BOOL and bool
    are different, this is not a problem as BOOL and bool are passed and
    returned the same way in the ABI.

    This still defines BOOL to bool for compatibility, except on AmigaOS and
    Wii, which both have its own BOOL type. (user: js, size: 3293) [annotate] [blame] [check-ins using] [more...]

To Artifact [d73c3bd6a6]:


37
38
39
40
41
42
43


44

45
46
47
48
49
50
51
	for (size_t i = 0; i < NUM_SPINLOCKS; i++)
		if (!of_spinlock_new(&spinlocks[i]))
			OBJC_ERROR("Failed to initialize spinlocks!")
}
#endif

id


objc_getProperty(id self, SEL _cmd, ptrdiff_t offset, bool atomic)

{
	if (atomic) {
		id *ptr = (id *)(void *)((char *)self + offset);
#ifdef OF_HAVE_THREADS
		unsigned hash = SPINLOCK_HASH(ptr);

		OF_ENSURE(of_spinlock_lock(&spinlocks[hash]));







>
>
|
>







37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
	for (size_t i = 0; i < NUM_SPINLOCKS; i++)
		if (!of_spinlock_new(&spinlocks[i]))
			OBJC_ERROR("Failed to initialize spinlocks!")
}
#endif

id
OBJC_GLUE(objc_getProperty, id self OBJC_GLUE_M68K_REG("a0"),
    SEL _cmd OBJC_GLUE_M68K_REG("a1"),
    ptrdiff_t offset OBJC_GLUE_M68K_REG("d0"),
    bool atomic OBJC_GLUE_M68K_REG("d1"))
{
	if (atomic) {
		id *ptr = (id *)(void *)((char *)self + offset);
#ifdef OF_HAVE_THREADS
		unsigned hash = SPINLOCK_HASH(ptr);

		OF_ENSURE(of_spinlock_lock(&spinlocks[hash]));
59
60
61
62
63
64
65


66

67
68
69
70
71
72
73
74
#endif
	}

	return *(id *)(void *)((char *)self + offset);
}

void


objc_setProperty(id self, SEL _cmd, ptrdiff_t offset, id value, bool atomic,

    signed char copy)
{
	if (atomic) {
		id *ptr = (id *)(void *)((char *)self + offset);
#ifdef OF_HAVE_THREADS
		unsigned hash = SPINLOCK_HASH(ptr);

		OF_ENSURE(of_spinlock_lock(&spinlocks[hash]));







>
>
|
>
|







62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#endif
	}

	return *(id *)(void *)((char *)self + offset);
}

void
OBJC_GLUE(objc_setProperty, id self OBJC_GLUE_M68K_REG("a0"),
    SEL _cmd OBJC_GLUE_M68K_REG("a1"),
    ptrdiff_t offset OBJC_GLUE_M68K_REG("d0"),
    id value OBJC_GLUE_M68K_REG("a2"), bool atomic OBJC_GLUE_M68K_REG("d1"),
    signed char copy OBJC_GLUE_M68K_REG("d2"))
{
	if (atomic) {
		id *ptr = (id *)(void *)((char *)self + offset);
#ifdef OF_HAVE_THREADS
		unsigned hash = SPINLOCK_HASH(ptr);

		OF_ENSURE(of_spinlock_lock(&spinlocks[hash]));
112
113
114
115
116
117
118
119


120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140


141
142
143
144
145
146
147
148
	}

	[old release];
}

/* The following methods are only required for GCC >= 4.6 */
void
objc_getPropertyStruct(void *dest, const void *src, ptrdiff_t size, bool atomic,


    bool strong)
{
	if (atomic) {
#ifdef OF_HAVE_THREADS
		unsigned hash = SPINLOCK_HASH(src);

		OF_ENSURE(of_spinlock_lock(&spinlocks[hash]));
#endif
		memcpy(dest, src, size);
#ifdef OF_HAVE_THREADS
		OF_ENSURE(of_spinlock_unlock(&spinlocks[hash]));
#endif

		return;
	}

	memcpy(dest, src, size);
}

void
objc_setPropertyStruct(void *dest, const void *src, ptrdiff_t size, bool atomic,


    bool strong)
{
	if (atomic) {
#ifdef OF_HAVE_THREADS
		unsigned hash = SPINLOCK_HASH(src);

		OF_ENSURE(of_spinlock_lock(&spinlocks[hash]));
#endif







|
>
>
|



















|
>
>
|







118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
	}

	[old release];
}

/* The following methods are only required for GCC >= 4.6 */
void
OBJC_GLUE(objc_getPropertyStruct, void *dest OBJC_GLUE_M68K_REG("a0"),
    const void *src OBJC_GLUE_M68K_REG("a1"),
    ptrdiff_t size OBJC_GLUE_M68K_REG("d0"),
    bool atomic OBJC_GLUE_M68K_REG("d1"), bool strong OBJC_GLUE_M68K_REG("d2"))
{
	if (atomic) {
#ifdef OF_HAVE_THREADS
		unsigned hash = SPINLOCK_HASH(src);

		OF_ENSURE(of_spinlock_lock(&spinlocks[hash]));
#endif
		memcpy(dest, src, size);
#ifdef OF_HAVE_THREADS
		OF_ENSURE(of_spinlock_unlock(&spinlocks[hash]));
#endif

		return;
	}

	memcpy(dest, src, size);
}

void
OBJC_GLUE(objc_setPropertyStruct, void *dest OBJC_GLUE_M68K_REG("a0"),
    const void *src OBJC_GLUE_M68K_REG("a1"),
    ptrdiff_t size OBJC_GLUE_M68K_REG("d0"),
    bool atomic OBJC_GLUE_M68K_REG("d1"), bool strong OBJC_GLUE_M68K_REG("d2"))
{
	if (atomic) {
#ifdef OF_HAVE_THREADS
		unsigned hash = SPINLOCK_HASH(src);

		OF_ENSURE(of_spinlock_lock(&spinlocks[hash]));
#endif