ObjFW  Check-in [482698c5be]

Overview
Comment:runtime: Make Amiga library work with -fbaserel

This currently uses __saveds on all exported functions for simplicity.
As an optimization, __saveds can be removed from some functions later
after careful verification that no code path starting from that function
accesses any data.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 482698c5beb3d3403cdf5f312bde33aca29227baf15c080b1ff84a6933545537
User & Date: js on 2018-05-06 21:39:06
Other Links: manifest | tags
Context
2018-05-11
17:59
runtime: Support to open Amiga lib multiple times check-in: 2376865a0f user: js tags: trunk
2018-05-06
21:39
runtime: Make Amiga library work with -fbaserel check-in: 482698c5be user: js tags: trunk
18:42
runtime: Add ARC methods to headers and Amiga lib check-in: 3ed710dc03 user: js tags: trunk
Changes

Modified src/runtime/Makefile from [32b60048e1] to [846f7565d8].

56
57
58
59
60
61
62
63
64
	    -DOBJFW_RT_LIB_MINOR=${OBJFW_RT_LIB_MINOR}
AMIGA_LIB_CFLAGS += -DOBJC_COMPILING_AMIGA_LIBRARY
LD = ${OBJC}
FRAMEWORK_LIBS = ${LIBS}

# For 68000, GCC emits calls to helper functions that expect a4 to be set.
# Remove this once the library is using -fbaserel.
AMIGA_LIB_CFLAGS += -mcpu=68020
AMIGA_LIB_LDFLAGS += -mcpu=68020 -nostdlib -lnix







|
|
56
57
58
59
60
61
62
63
64
	    -DOBJFW_RT_LIB_MINOR=${OBJFW_RT_LIB_MINOR}
AMIGA_LIB_CFLAGS += -DOBJC_COMPILING_AMIGA_LIBRARY
LD = ${OBJC}
FRAMEWORK_LIBS = ${LIBS}

# For 68000, GCC emits calls to helper functions that expect a4 to be set.
# Remove this once the library is using -fbaserel.
AMIGA_LIB_CFLAGS += -mcpu=68020 -fbaserel
AMIGA_LIB_LDFLAGS += -mcpu=68020 -fbaserel -nostdlib -lnix

Modified src/runtime/ObjFW_RT.h from [e761c23ace] to [18895befa5].

341
342
343
344
345
346
347
348

349
350
351
352
353
354
355
356
357
358
359
extern id _Nullable objc_retainAutoreleaseReturnValue(id _Nullable object);
extern id _Nullable objc_retainAutoreleasedReturnValue(id _Nullable object);
extern id _Nullable objc_storeStrong(id _Nullable *_Nonnull object,
    id _Nullable value);
extern id _Nullable objc_storeWeak(id _Nullable *_Nonnull object,
    id _Nullable value);
extern id _Nullable objc_loadWeakRetained(id _Nullable *_Nonnull object);
extern id objc_initWeak(id _Nullable *_Nonnull object, id _Nullable value);

extern void objc_destroyWeak(id _Nullable *_Nonnull object);
extern id _Nullable objc_loadWeak(id _Nullable *_Nonnull object);
extern void objc_copyWeak(id _Nullable *_Nonnull dest,
    id _Nullable *_Nonnull src);
extern void objc_moveWeak(id _Nullable *_Nonnull dest,
    id _Nullable *_Nonnull src);
#ifdef __cplusplus
}
#endif

#endif







|
>











341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
extern id _Nullable objc_retainAutoreleaseReturnValue(id _Nullable object);
extern id _Nullable objc_retainAutoreleasedReturnValue(id _Nullable object);
extern id _Nullable objc_storeStrong(id _Nullable *_Nonnull object,
    id _Nullable value);
extern id _Nullable objc_storeWeak(id _Nullable *_Nonnull object,
    id _Nullable value);
extern id _Nullable objc_loadWeakRetained(id _Nullable *_Nonnull object);
extern _Nullable id objc_initWeak(id _Nullable *_Nonnull object,
    id _Nullable value);
extern void objc_destroyWeak(id _Nullable *_Nonnull object);
extern id _Nullable objc_loadWeak(id _Nullable *_Nonnull object);
extern void objc_copyWeak(id _Nullable *_Nonnull dest,
    id _Nullable *_Nonnull src);
extern void objc_moveWeak(id _Nullable *_Nonnull dest,
    id _Nullable *_Nonnull src);
#ifdef __cplusplus
}
#endif

#endif

Modified src/runtime/ObjFW_RT.sfd from [ea9196920a] to [eb7972f642].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
==base _ObjFWRTBase
==basetype struct Library *
==libname objfw_rt.library
==bias 30
==public
* Functions for the linklib
void objc_init(struct objc_libc *libc)(a0)
* Used by the compiler - these need glue code
void glue___objc_exec_class(void *_Nonnull module)(a0)
IMP _Nonnull glue_objc_msg_lookup(id _Nullable obj, SEL _Nonnull sel)(a0,a1)
IMP _Nonnull glue_objc_msg_lookup_stret(id _Nullable obj, SEL _Nonnull sel)(a0,a1)
IMP _Nonnull glue_objc_msg_lookup_super(struct objc_super *_Nonnull super, SEL _Nonnull sel)(a0,a1)
IMP _Nonnull glue_objc_msg_lookup_super_stret(struct objc_super *_Nonnull super, SEL _Nonnull sel)(a0,a1)
Class _Nullable glue_objc_lookUpClass(const char *_Nonnull name)(a0)






|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
==base _ObjFWRTBase
==basetype struct Library *
==libname objfw_rt.library
==bias 30
==public
* Functions for the linklib
void objc_init(struct objc_libc *libc, FILE *stdout, FILE *stdin)(a0,a1,a2)
* Used by the compiler - these need glue code
void glue___objc_exec_class(void *_Nonnull module)(a0)
IMP _Nonnull glue_objc_msg_lookup(id _Nullable obj, SEL _Nonnull sel)(a0,a1)
IMP _Nonnull glue_objc_msg_lookup_stret(id _Nullable obj, SEL _Nonnull sel)(a0,a1)
IMP _Nonnull glue_objc_msg_lookup_super(struct objc_super *_Nonnull super, SEL _Nonnull sel)(a0,a1)
IMP _Nonnull glue_objc_msg_lookup_super_stret(struct objc_super *_Nonnull super, SEL _Nonnull sel)(a0,a1)
Class _Nullable glue_objc_lookUpClass(const char *_Nonnull name)(a0)
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
id _Nullable glue_objc_autorelease(id _Nullable object)(a0)
id _Nullable glue_objc_autoreleaseReturnValue(id _Nullable object)(a0)
id _Nullable glue_objc_retainAutoreleaseReturnValue(id _Nullable object)(a0)
id _Nullable glue_objc_retainAutoreleasedReturnValue(id _Nullable object)(a0)
id _Nullable glue_objc_storeStrong(id _Nullable *_Nonnull object, id _Nullable value)(a0/a1)
id _Nullable glue_objc_storeWeak(id _Nullable *_Nonnull object, id _Nullable value)(a0,a1)
id _Nullable glue_objc_loadWeakRetained(id _Nullable *_Nonnull object)(a0)
id glue_objc_initWeak(id _Nullable *_Nonnull object, id _Nullable value)(a0,a1)
void glue_objc_destroyWeak(id _Nullable *_Nonnull object)(a0)
id _Nullable glue_objc_loadWeak(id _Nullable *_Nonnull object)(a0)
void glue_objc_copyWeak(id _Nullable *_Nonnull dest, id _Nullable *_Nonnull src)(a0,a1)
void glue_objc_moveWeak(id _Nullable *_Nonnull dest, id _Nullable *_Nonnull src)(a0,a1)
* Functions declared in ObjFW_RT.h
SEL _Nonnull sel_registerName(const char *_Nonnull name)(a0)
const char *_Nonnull sel_getName(SEL _Nonnull sel)(a0)







|







32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
id _Nullable glue_objc_autorelease(id _Nullable object)(a0)
id _Nullable glue_objc_autoreleaseReturnValue(id _Nullable object)(a0)
id _Nullable glue_objc_retainAutoreleaseReturnValue(id _Nullable object)(a0)
id _Nullable glue_objc_retainAutoreleasedReturnValue(id _Nullable object)(a0)
id _Nullable glue_objc_storeStrong(id _Nullable *_Nonnull object, id _Nullable value)(a0/a1)
id _Nullable glue_objc_storeWeak(id _Nullable *_Nonnull object, id _Nullable value)(a0,a1)
id _Nullable glue_objc_loadWeakRetained(id _Nullable *_Nonnull object)(a0)
id _Nullable glue_objc_initWeak(id _Nullable *_Nonnull object, id _Nullable value)(a0,a1)
void glue_objc_destroyWeak(id _Nullable *_Nonnull object)(a0)
id _Nullable glue_objc_loadWeak(id _Nullable *_Nonnull object)(a0)
void glue_objc_copyWeak(id _Nullable *_Nonnull dest, id _Nullable *_Nonnull src)(a0,a1)
void glue_objc_moveWeak(id _Nullable *_Nonnull dest, id _Nullable *_Nonnull src)(a0,a1)
* Functions declared in ObjFW_RT.h
SEL _Nonnull sel_registerName(const char *_Nonnull name)(a0)
const char *_Nonnull sel_getName(SEL _Nonnull sel)(a0)

Modified src/runtime/amiga-glue.m from [25dbff61eb] to [3114ab4ae0].

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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
202
203
204
205
206
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256

#include "config.h"

#import "ObjFW_RT.h"
#import "private.h"
#import "macros.h"

void
glue___objc_exec_class(void *module OBJC_M68K_REG("a0"))
{
	__objc_exec_class(module);
}

IMP
glue_objc_msg_lookup(id obj OBJC_M68K_REG("a0"), SEL sel OBJC_M68K_REG("a1"))
{
	return objc_msg_lookup(obj, sel);
}

IMP
glue_objc_msg_lookup_stret(id obj OBJC_M68K_REG("a0"),
    SEL sel OBJC_M68K_REG("a1"))
{
	return objc_msg_lookup_stret(obj, sel);
}

IMP
glue_objc_msg_lookup_super(struct objc_super *super OBJC_M68K_REG("a0"),
    SEL sel OBJC_M68K_REG("a1"))
{
	return objc_msg_lookup_super(super, sel);
}

IMP
glue_objc_msg_lookup_super_stret(struct objc_super *super OBJC_M68K_REG("a0"),
    SEL sel OBJC_M68K_REG("a1"))
{
	return objc_msg_lookup_super_stret(super, sel);
}

Class
glue_objc_lookUpClass(const char *name OBJC_M68K_REG("a0"))
{
	return objc_lookUpClass(name);
}

Class
glue_objc_getClass(const char *name OBJC_M68K_REG("a0"))
{
	return objc_getClass(name);
}

Class
glue_objc_getRequiredClass(const char *name OBJC_M68K_REG("a0"))
{
	return objc_getRequiredClass(name);
}

Class
glue_objc_lookup_class(const char *name OBJC_M68K_REG("a0"))
{
	return objc_lookup_class(name);
}

Class
glue_objc_get_class(const char *name OBJC_M68K_REG("a0"))
{
	return objc_get_class(name);
}

void
glue_objc_exception_throw(id object OBJC_M68K_REG("a0"))
{
	objc_exception_throw(object);

	OF_UNREACHABLE
}

int
glue_objc_sync_enter(id object OBJC_M68K_REG("a0"))
{
	return objc_sync_enter(object);
}

int
glue_objc_sync_exit(id object OBJC_M68K_REG("a0"))
{
	return objc_sync_exit(object);
}

id
glue_objc_getProperty(id self OBJC_M68K_REG("a0"), SEL _cmd OBJC_M68K_REG("a1"),
    ptrdiff_t offset OBJC_M68K_REG("d0"), bool atomic OBJC_M68K_REG("d1"))
{
	return objc_getProperty(self, _cmd, offset, atomic);
}

void
glue_objc_setProperty(id self OBJC_M68K_REG("a0"), SEL _cmd OBJC_M68K_REG("a1"),
    ptrdiff_t offset OBJC_M68K_REG("d0"), id value OBJC_M68K_REG("a2"),
    bool atomic OBJC_M68K_REG("d1"), signed char copy OBJC_M68K_REG("d2"))
{
	objc_setProperty(self, _cmd, offset, value, atomic, copy);
}

void
glue_objc_getPropertyStruct(void *dest OBJC_M68K_REG("a0"),
    const void *src OBJC_M68K_REG("a1"), ptrdiff_t size OBJC_M68K_REG("d0"),
    bool atomic OBJC_M68K_REG("d1"), bool strong OBJC_M68K_REG("d2"))
{
	objc_getPropertyStruct(dest, src, size, atomic, strong);
}

void
glue_objc_setPropertyStruct(void *dest OBJC_M68K_REG("a0"),
    const void *src OBJC_M68K_REG("a1"), ptrdiff_t size OBJC_M68K_REG("d0"),
    bool atomic OBJC_M68K_REG("d1"), bool strong OBJC_M68K_REG("d2"))
{
	objc_setPropertyStruct(dest, src, size, atomic, strong);
}

void
glue_objc_enumerationMutation(id obj OBJC_M68K_REG("a0"))
{
	objc_enumerationMutation(obj);
}

int
glue___gnu_objc_personality_v0(int version OBJC_M68K_REG("d0"),
    int actions OBJC_M68K_REG("d1"), uint64_t *ex_class OBJC_M68K_REG("d2"),
    void *ex OBJC_M68K_REG("a0"), void *ctx OBJC_M68K_REG("a1"))
{
	return __gnu_objc_personality_v0(version, actions, *ex_class, ex, ctx);
}

id
_Nullable glue_objc_retain(id _Nullable object OBJC_M68K_REG("a0"))
{
	return objc_retain(object);
}

id
_Nullable glue_objc_retainBlock(id _Nullable block OBJC_M68K_REG("a0"))
{
	return objc_retainBlock(block);
}

id
_Nullable glue_objc_retainAutorelease(id _Nullable object OBJC_M68K_REG("a0"))
{
	return objc_retainAutorelease(object);
}

void
glue_objc_release(id _Nullable object OBJC_M68K_REG("a0"))
{
	objc_release(object);
}

id
_Nullable glue_objc_autorelease(id _Nullable object OBJC_M68K_REG("a0"))
{
	return objc_autorelease(object);
}

id
_Nullable glue_objc_autoreleaseReturnValue(
    id _Nullable object OBJC_M68K_REG("a0"))
{
	return objc_autoreleaseReturnValue(object);
}

id
_Nullable glue_objc_retainAutoreleaseReturnValue(
    id _Nullable object OBJC_M68K_REG("a0"))
{
	return objc_retainAutoreleaseReturnValue(object);
}

id
_Nullable glue_objc_retainAutoreleasedReturnValue(
    id _Nullable object OBJC_M68K_REG("a0"))
{
	return objc_retainAutoreleasedReturnValue(object);
}

id
_Nullable glue_objc_storeStrong(
    id _Nullable *_Nonnull object OBJC_M68K_REG("a0"),
    id _Nullable value OBJC_M68K_REG("a1"))
{
	return objc_storeStrong(object, value);
}

id
_Nullable glue_objc_storeWeak(id _Nullable *_Nonnull object OBJC_M68K_REG("a0"),
    id _Nullable value OBJC_M68K_REG("a1"))
{
	return objc_storeWeak(object, value);
}

id
_Nullable glue_objc_loadWeakRetained(
    id _Nullable *_Nonnull object OBJC_M68K_REG("a0"))
{
	return objc_loadWeakRetained(object);
}

id
glue_objc_initWeak(id _Nullable *_Nonnull object OBJC_M68K_REG("a0"),
    id _Nullable value OBJC_M68K_REG("a1"))
{
	return objc_initWeak(object, value);
}

void
glue_objc_destroyWeak(id _Nullable *_Nonnull object OBJC_M68K_REG("a0"))
{
	objc_destroyWeak(object);
}

id
_Nullable glue_objc_loadWeak(id _Nullable *_Nonnull object OBJC_M68K_REG("a0"))
{
	return objc_loadWeak(object);
}

void
glue_objc_copyWeak(id _Nullable *_Nonnull dest OBJC_M68K_REG("a0"),
    id _Nullable *_Nonnull src OBJC_M68K_REG("a1"))
{
	objc_copyWeak(dest, src);
}

void
glue_objc_moveWeak(id _Nullable *_Nonnull dest OBJC_M68K_REG("a0"),
    id _Nullable *_Nonnull src OBJC_M68K_REG("a1"))
{
	objc_moveWeak(dest, src);
}







|





|





|






|






|






|





|





|





|





|





|







|





|





|






|







|







|







|





|







|
|




|
|




|
|




|
|




|
|




|
|
<




|
|
<




|
|
<




|
|
<
|




|
|
|




|
|
<




|
<
|




|
|




|
|




|
<
|




|
<
|



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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

202
203
204
205
206
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
233
234
235
236
237
238

239
240
241
242
243
244

245
246
247
248

#include "config.h"

#import "ObjFW_RT.h"
#import "private.h"
#import "macros.h"

void __saveds
glue___objc_exec_class(void *module OBJC_M68K_REG("a0"))
{
	__objc_exec_class(module);
}

IMP __saveds
glue_objc_msg_lookup(id obj OBJC_M68K_REG("a0"), SEL sel OBJC_M68K_REG("a1"))
{
	return objc_msg_lookup(obj, sel);
}

IMP __saveds
glue_objc_msg_lookup_stret(id obj OBJC_M68K_REG("a0"),
    SEL sel OBJC_M68K_REG("a1"))
{
	return objc_msg_lookup_stret(obj, sel);
}

IMP __saveds
glue_objc_msg_lookup_super(struct objc_super *super OBJC_M68K_REG("a0"),
    SEL sel OBJC_M68K_REG("a1"))
{
	return objc_msg_lookup_super(super, sel);
}

IMP __saveds
glue_objc_msg_lookup_super_stret(struct objc_super *super OBJC_M68K_REG("a0"),
    SEL sel OBJC_M68K_REG("a1"))
{
	return objc_msg_lookup_super_stret(super, sel);
}

Class __saveds
glue_objc_lookUpClass(const char *name OBJC_M68K_REG("a0"))
{
	return objc_lookUpClass(name);
}

Class __saveds
glue_objc_getClass(const char *name OBJC_M68K_REG("a0"))
{
	return objc_getClass(name);
}

Class __saveds
glue_objc_getRequiredClass(const char *name OBJC_M68K_REG("a0"))
{
	return objc_getRequiredClass(name);
}

Class __saveds
glue_objc_lookup_class(const char *name OBJC_M68K_REG("a0"))
{
	return objc_lookup_class(name);
}

Class __saveds
glue_objc_get_class(const char *name OBJC_M68K_REG("a0"))
{
	return objc_get_class(name);
}

void __saveds
glue_objc_exception_throw(id object OBJC_M68K_REG("a0"))
{
	objc_exception_throw(object);

	OF_UNREACHABLE
}

int __saveds
glue_objc_sync_enter(id object OBJC_M68K_REG("a0"))
{
	return objc_sync_enter(object);
}

int __saveds
glue_objc_sync_exit(id object OBJC_M68K_REG("a0"))
{
	return objc_sync_exit(object);
}

id __saveds
glue_objc_getProperty(id self OBJC_M68K_REG("a0"), SEL _cmd OBJC_M68K_REG("a1"),
    ptrdiff_t offset OBJC_M68K_REG("d0"), bool atomic OBJC_M68K_REG("d1"))
{
	return objc_getProperty(self, _cmd, offset, atomic);
}

void __saveds
glue_objc_setProperty(id self OBJC_M68K_REG("a0"), SEL _cmd OBJC_M68K_REG("a1"),
    ptrdiff_t offset OBJC_M68K_REG("d0"), id value OBJC_M68K_REG("a2"),
    bool atomic OBJC_M68K_REG("d1"), signed char copy OBJC_M68K_REG("d2"))
{
	objc_setProperty(self, _cmd, offset, value, atomic, copy);
}

void __saveds
glue_objc_getPropertyStruct(void *dest OBJC_M68K_REG("a0"),
    const void *src OBJC_M68K_REG("a1"), ptrdiff_t size OBJC_M68K_REG("d0"),
    bool atomic OBJC_M68K_REG("d1"), bool strong OBJC_M68K_REG("d2"))
{
	objc_getPropertyStruct(dest, src, size, atomic, strong);
}

void __saveds
glue_objc_setPropertyStruct(void *dest OBJC_M68K_REG("a0"),
    const void *src OBJC_M68K_REG("a1"), ptrdiff_t size OBJC_M68K_REG("d0"),
    bool atomic OBJC_M68K_REG("d1"), bool strong OBJC_M68K_REG("d2"))
{
	objc_setPropertyStruct(dest, src, size, atomic, strong);
}

void __saveds
glue_objc_enumerationMutation(id obj OBJC_M68K_REG("a0"))
{
	objc_enumerationMutation(obj);
}

int __saveds
glue___gnu_objc_personality_v0(int version OBJC_M68K_REG("d0"),
    int actions OBJC_M68K_REG("d1"), uint64_t *ex_class OBJC_M68K_REG("d2"),
    void *ex OBJC_M68K_REG("a0"), void *ctx OBJC_M68K_REG("a1"))
{
	return __gnu_objc_personality_v0(version, actions, *ex_class, ex, ctx);
}

id __saveds
glue_objc_retain(id object OBJC_M68K_REG("a0"))
{
	return objc_retain(object);
}

id __saveds
glue_objc_retainBlock(id block OBJC_M68K_REG("a0"))
{
	return objc_retainBlock(block);
}

id __saveds
glue_objc_retainAutorelease(id object OBJC_M68K_REG("a0"))
{
	return objc_retainAutorelease(object);
}

void __saveds
glue_objc_release(id object OBJC_M68K_REG("a0"))
{
	objc_release(object);
}

id __saveds
glue_objc_autorelease(id object OBJC_M68K_REG("a0"))
{
	return objc_autorelease(object);
}

id __saveds
glue_objc_autoreleaseReturnValue(id object OBJC_M68K_REG("a0"))

{
	return objc_autoreleaseReturnValue(object);
}

id __saveds
glue_objc_retainAutoreleaseReturnValue(id object OBJC_M68K_REG("a0"))

{
	return objc_retainAutoreleaseReturnValue(object);
}

id __saveds
glue_objc_retainAutoreleasedReturnValue(id object OBJC_M68K_REG("a0"))

{
	return objc_retainAutoreleasedReturnValue(object);
}

id __saveds
glue_objc_storeStrong(id *object OBJC_M68K_REG("a0"),

    id value OBJC_M68K_REG("a1"))
{
	return objc_storeStrong(object, value);
}

id __saveds
glue_objc_storeWeak(id *object OBJC_M68K_REG("a0"),
    id value OBJC_M68K_REG("a1"))
{
	return objc_storeWeak(object, value);
}

id __saveds
glue_objc_loadWeakRetained(id *object OBJC_M68K_REG("a0"))

{
	return objc_loadWeakRetained(object);
}

id __saveds

glue_objc_initWeak(id *object OBJC_M68K_REG("a0"), id value OBJC_M68K_REG("a1"))
{
	return objc_initWeak(object, value);
}

void __saveds
glue_objc_destroyWeak(id *object OBJC_M68K_REG("a0"))
{
	objc_destroyWeak(object);
}

id __saveds
glue_objc_loadWeak(id *object OBJC_M68K_REG("a0"))
{
	return objc_loadWeak(object);
}

void __saveds

glue_objc_copyWeak(id *dest OBJC_M68K_REG("a0"), id *src OBJC_M68K_REG("a1"))
{
	objc_copyWeak(dest, src);
}

void __saveds

glue_objc_moveWeak(id *dest OBJC_M68K_REG("a0"), id *src OBJC_M68K_REG("a1"))
{
	objc_moveWeak(dest, src);
}

Modified src/runtime/amiga-library.m from [3eba26b1b7] to [7a454ada46].

41
42
43
44
45
46
47


48
49
50
51
52

53
54
55
56
57
58
59
60
61




















62
63
64
65
66

67

68
69

70
71
72
73
74
75
76
	return -1;
}

struct ObjFWRTBase {
	struct Library library;
	void *seg_list;
	bool initialized;


};

extern uintptr_t __CTOR_LIST__[], __DTOR_LIST__[];
extern const void *_EH_FRAME_BEGINS__;
extern void *_EH_FRAME_OBJECTS__;


struct ExecBase *SysBase;
#ifdef OF_MORPHOS
const ULONG __abox__ = 1;
#endif
struct objc_libc *libc;
FILE *stdout;
FILE *stderr;





















static struct Library *
lib_init(struct ExecBase *exec_base OBJC_M68K_REG("a6"),
    void *seg_list OBJC_M68K_REG("a0"),
    struct ObjFWRTBase *base OBJC_M68K_REG("d0"))
{

	SysBase = exec_base;


	base->seg_list = seg_list;


	return &base->library;
}

static struct Library *
OBJC_M68K_FUNC(lib_open, struct ObjFWRTBase *base OBJC_M68K_REG("a6"))
{







>
>





>





<



>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

|



>
|
>


>







41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
	return -1;
}

struct ObjFWRTBase {
	struct Library library;
	void *seg_list;
	bool initialized;
	void *data_seg;
	struct objc_libc libc;
};

extern uintptr_t __CTOR_LIST__[], __DTOR_LIST__[];
extern const void *_EH_FRAME_BEGINS__;
extern void *_EH_FRAME_OBJECTS__;
extern void *__a4_init;

struct ExecBase *SysBase;
#ifdef OF_MORPHOS
const ULONG __abox__ = 1;
#endif

FILE *stdout;
FILE *stderr;

__asm__ (
    ".text\n"
    ".globl ___restore_a4\n"
    "___restore_a4:\n"
    "	movea.l	40(a6), a4\n"
    "	rts"
);

static OF_INLINE void *
get_data_seg(void)
{
	void *data_seg;

	__asm__ __volatile__ (
	    "lea.l	___a4_init, %0" : "=a"(data_seg)
	);

	return data_seg;
}

static struct Library *
lib_init(struct ExecBase *sys_base OBJC_M68K_REG("a6"),
    void *seg_list OBJC_M68K_REG("a0"),
    struct ObjFWRTBase *base OBJC_M68K_REG("d0"))
{
	__asm__ __volatile__ (
	    "move.l	a6, _SysBase" :: "a"(sys_base)
	);

	base->seg_list = seg_list;
	base->data_seg = get_data_seg();

	return &base->library;
}

static struct Library *
OBJC_M68K_FUNC(lib_open, struct ObjFWRTBase *base OBJC_M68K_REG("a6"))
{
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164


165
166
167
168
169
170


171
172
173
174
175
176


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


202
203
204
205
206
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
233
234
235
236
237


238
239
240
241
242
243


244
245
246
247
248
249


250
251
252
253
254
255


256
257
258
259
260
261


262
263
264
265
266
267


268
269
270
271
272
273


274
275
276
277
278
279


280
281
282
283
284
285
286
287
	Remove(&base->library.lib_Node);
	FreeMem((char *)base - base->library.lib_NegSize,
	    base->library.lib_NegSize + base->library.lib_PosSize);

	return seg_list;
}

static void *
OBJC_M68K_FUNC(lib_expunge, struct ObjFWRTBase *base OBJC_M68K_REG("a6"))
{
	OBJC_M68K_ARG(struct ObjFWRTBase *, base, REG_A6)

	return expunge(base);
}

static void *
OBJC_M68K_FUNC(lib_close, struct ObjFWRTBase *base OBJC_M68K_REG("a6"))
{
	OBJC_M68K_ARG(struct ObjFWRTBase *, base, REG_A6)

	if (base->initialized &&
	    (size_t)_EH_FRAME_BEGINS__ == (size_t)_EH_FRAME_OBJECTS__)
		for (size_t i = 1; i <= (size_t)_EH_FRAME_BEGINS__; i++)

			libc->__deregister_frame_info((&_EH_FRAME_BEGINS__)[i]);

	if (--base->library.lib_OpenCnt == 0 &&
	    (base->library.lib_Flags & LIBF_DELEXP))
		return expunge(base);

	return 0;
}

static void *
lib_null(void)
{
	return 0;
}

static void
objc_init(struct ObjFWRTBase *base OBJC_M68K_REG("a6"),
    struct objc_libc *libc_ OBJC_M68K_REG("a0"))

{
	uintptr_t *iter, *iter0;

	libc = libc_;

	stdout = libc->stdout_;
	stderr = libc->stderr_;

	if ((size_t)_EH_FRAME_BEGINS__ == (size_t)_EH_FRAME_OBJECTS__)
		for (size_t i = 1; i <= (size_t)_EH_FRAME_BEGINS__; i++)

			libc->__register_frame_info((&_EH_FRAME_BEGINS__)[i],
			    (&_EH_FRAME_OBJECTS__)[i]);

	iter0 = &__CTOR_LIST__[1];
	for (iter = iter0; *iter != 0; iter++);

	while (iter > iter0) {
		void (*ctor)(void) = (void (*)(void))*--iter;
		ctor();
	}

	base->initialized = true;
}

void *
malloc(size_t size)
{


	return libc->malloc(size);
}

void *
calloc(size_t count, size_t size)
{


	return libc->calloc(count, size);
}

void *
realloc(void *ptr, size_t size)
{


	return libc->realloc(ptr, size);
}

void
free(void *ptr)
{


	libc->free(ptr);
}

int
fprintf(FILE *restrict stream, const char *restrict fmt, ...)
{

	int ret;
	va_list args;

	va_start(args, fmt);
	ret = libc->vfprintf(stream, fmt, args);
	va_end(args);

	return ret;
}

int
fputs(const char *restrict s, FILE *restrict stream)
{


	return libc->fputs(s, stream);
}

void
exit(int status)
{


	libc->exit(status);
}

void
abort(void)
{


	libc->abort();
}

int
_Unwind_RaiseException(void *ex)
{


	return libc->_Unwind_RaiseException(ex);
}

void
_Unwind_DeleteException(void *ex)
{


	libc->_Unwind_DeleteException(ex);
}

void *
_Unwind_GetLanguageSpecificData(void *ctx)
{


	return libc->_Unwind_GetLanguageSpecificData(ctx);
}

uintptr_t
_Unwind_GetRegionStart(void *ctx)
{


	return libc->_Unwind_GetRegionStart(ctx);
}

uintptr_t
_Unwind_GetDataRelBase(void *ctx)
{


	return libc->_Unwind_GetDataRelBase(ctx);
}

uintptr_t
_Unwind_GetTextRelBase(void *ctx)
{


	return libc->_Unwind_GetTextRelBase(ctx);
}

uintptr_t
_Unwind_GetIP(void *ctx)
{


	return libc->_Unwind_GetIP(ctx);
}

uintptr_t
_Unwind_GetGR(void *ctx, int gr)
{


	return libc->_Unwind_GetGR(ctx, gr);
}

void
_Unwind_SetIP(void *ctx, uintptr_t ip)
{


	libc->_Unwind_SetIP(ctx, ip);
}

void
_Unwind_SetGR(void *ctx, int gr, uintptr_t value)
{


	libc->_Unwind_SetGR(ctx, gr, value);
}

void
_Unwind_Resume(void *ex)
{


	libc->_Unwind_Resume(ex);
}

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
static CONST_APTR function_table[] = {
	(CONST_APTR)lib_open,
	(CONST_APTR)lib_close,







|







|







>
|














|

|
>



|

|
|



>
|
















>
>
|





>
>
|





>
>
|





>
>
|





>




|








>
>
|





>
>
|





>
>
|





>
>
|





>
>
|





>
>
|





>
>
|





>
>
|





>
>
|





>
>
|





>
>
|





>
>
|





>
>
|





>
>
|







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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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
202
203
204
205
206
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
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
340
341
342
343
344
345
346
347
348
349
350
351
352
	Remove(&base->library.lib_Node);
	FreeMem((char *)base - base->library.lib_NegSize,
	    base->library.lib_NegSize + base->library.lib_PosSize);

	return seg_list;
}

static void *__saveds
OBJC_M68K_FUNC(lib_expunge, struct ObjFWRTBase *base OBJC_M68K_REG("a6"))
{
	OBJC_M68K_ARG(struct ObjFWRTBase *, base, REG_A6)

	return expunge(base);
}

static void *__saveds
OBJC_M68K_FUNC(lib_close, struct ObjFWRTBase *base OBJC_M68K_REG("a6"))
{
	OBJC_M68K_ARG(struct ObjFWRTBase *, base, REG_A6)

	if (base->initialized &&
	    (size_t)_EH_FRAME_BEGINS__ == (size_t)_EH_FRAME_OBJECTS__)
		for (size_t i = 1; i <= (size_t)_EH_FRAME_BEGINS__; i++)
			base->libc.__deregister_frame_info(
			    (&_EH_FRAME_BEGINS__)[i]);

	if (--base->library.lib_OpenCnt == 0 &&
	    (base->library.lib_Flags & LIBF_DELEXP))
		return expunge(base);

	return 0;
}

static void *
lib_null(void)
{
	return 0;
}

static void __saveds
objc_init(struct ObjFWRTBase *base OBJC_M68K_REG("a6"),
    struct objc_libc *libc OBJC_M68K_REG("a0"),
    FILE *stdout_ OBJC_M68K_REG("a1"), FILE *stderr_ OBJC_M68K_REG("a2"))
{
	uintptr_t *iter, *iter0;

	memcpy(&base->libc, libc, sizeof(base->libc));

	stdout = stdout_;
	stderr = stderr_;

	if ((size_t)_EH_FRAME_BEGINS__ == (size_t)_EH_FRAME_OBJECTS__)
		for (size_t i = 1; i <= (size_t)_EH_FRAME_BEGINS__; i++)
			base->libc.__register_frame_info(
			    (&_EH_FRAME_BEGINS__)[i],
			    (&_EH_FRAME_OBJECTS__)[i]);

	iter0 = &__CTOR_LIST__[1];
	for (iter = iter0; *iter != 0; iter++);

	while (iter > iter0) {
		void (*ctor)(void) = (void (*)(void))*--iter;
		ctor();
	}

	base->initialized = true;
}

void *
malloc(size_t size)
{
	register struct ObjFWRTBase *base OBJC_M68K_REG("a6");

	return base->libc.malloc(size);
}

void *
calloc(size_t count, size_t size)
{
	register struct ObjFWRTBase *base OBJC_M68K_REG("a6");

	return base->libc.calloc(count, size);
}

void *
realloc(void *ptr, size_t size)
{
	register struct ObjFWRTBase *base OBJC_M68K_REG("a6");

	return base->libc.realloc(ptr, size);
}

void
free(void *ptr)
{
	register struct ObjFWRTBase *base OBJC_M68K_REG("a6");

	base->libc.free(ptr);
}

int
fprintf(FILE *restrict stream, const char *restrict fmt, ...)
{
	register struct ObjFWRTBase *base OBJC_M68K_REG("a6");
	int ret;
	va_list args;

	va_start(args, fmt);
	ret = base->libc.vfprintf(stream, fmt, args);
	va_end(args);

	return ret;
}

int
fputs(const char *restrict s, FILE *restrict stream)
{
	register struct ObjFWRTBase *base OBJC_M68K_REG("a6");

	return base->libc.fputs(s, stream);
}

void
exit(int status)
{
	register struct ObjFWRTBase *base OBJC_M68K_REG("a6");

	base->libc.exit(status);
}

void
abort(void)
{
	register struct ObjFWRTBase *base OBJC_M68K_REG("a6");

	base->libc.abort();
}

int
_Unwind_RaiseException(void *ex)
{
	register struct ObjFWRTBase *base OBJC_M68K_REG("a6");

	return base->libc._Unwind_RaiseException(ex);
}

void
_Unwind_DeleteException(void *ex)
{
	register struct ObjFWRTBase *base OBJC_M68K_REG("a6");

	base->libc._Unwind_DeleteException(ex);
}

void *
_Unwind_GetLanguageSpecificData(void *ctx)
{
	register struct ObjFWRTBase *base OBJC_M68K_REG("a6");

	return base->libc._Unwind_GetLanguageSpecificData(ctx);
}

uintptr_t
_Unwind_GetRegionStart(void *ctx)
{
	register struct ObjFWRTBase *base OBJC_M68K_REG("a6");

	return base->libc._Unwind_GetRegionStart(ctx);
}

uintptr_t
_Unwind_GetDataRelBase(void *ctx)
{
	register struct ObjFWRTBase *base OBJC_M68K_REG("a6");

	return base->libc._Unwind_GetDataRelBase(ctx);
}

uintptr_t
_Unwind_GetTextRelBase(void *ctx)
{
	register struct ObjFWRTBase *base OBJC_M68K_REG("a6");

	return base->libc._Unwind_GetTextRelBase(ctx);
}

uintptr_t
_Unwind_GetIP(void *ctx)
{
	register struct ObjFWRTBase *base OBJC_M68K_REG("a6");

	return base->libc._Unwind_GetIP(ctx);
}

uintptr_t
_Unwind_GetGR(void *ctx, int gr)
{
	register struct ObjFWRTBase *base OBJC_M68K_REG("a6");

	return base->libc._Unwind_GetGR(ctx, gr);
}

void
_Unwind_SetIP(void *ctx, uintptr_t ip)
{
	register struct ObjFWRTBase *base OBJC_M68K_REG("a6");

	base->libc._Unwind_SetIP(ctx, ip);
}

void
_Unwind_SetGR(void *ctx, int gr, uintptr_t value)
{
	register struct ObjFWRTBase *base OBJC_M68K_REG("a6");

	base->libc._Unwind_SetGR(ctx, gr, value);
}

void
_Unwind_Resume(void *ex)
{
	register struct ObjFWRTBase *base OBJC_M68K_REG("a6");

	base->libc._Unwind_Resume(ex);
}

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
static CONST_APTR function_table[] = {
	(CONST_APTR)lib_open,
	(CONST_APTR)lib_close,

Modified src/runtime/arc.m from [82272ab977] to [de0851a9ba].

266
267
268
269
270
271
272
273
274
275
276
277
278
279
280

#ifdef OF_HAVE_THREADS
	if (!of_spinlock_unlock(&spinlock))
		OBJC_ERROR("Failed to unlock spinlock!")
#endif
}

void
objc_zero_weak_references(id value OBJC_M68K_REG("a0"))
{
	struct weak_ref *ref;

#ifdef OF_HAVE_THREADS
	if (!of_spinlock_lock(&spinlock))
		OBJC_ERROR("Failed to lock spinlock!")







|







266
267
268
269
270
271
272
273
274
275
276
277
278
279
280

#ifdef OF_HAVE_THREADS
	if (!of_spinlock_unlock(&spinlock))
		OBJC_ERROR("Failed to unlock spinlock!")
#endif
}

void __saveds
objc_zero_weak_references(id value OBJC_M68K_REG("a0"))
{
	struct weak_ref *ref;

#ifdef OF_HAVE_THREADS
	if (!of_spinlock_lock(&spinlock))
		OBJC_ERROR("Failed to lock spinlock!")

Modified src/runtime/class.m from [6fa07e9231] to [973ed6f5e5].

412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
		} else
			cls->info |= OBJC_CLASS_INFO_LOADED;
	}

	process_load_queue();
}

Class
objc_allocateClassPair(Class superclass OBJC_M68K_REG("a0"),
    const char *name OBJC_M68K_REG("a1"),
    size_t extra_bytes OBJC_M68K_REG("d0"))
{
	struct objc_class *cls, *metaclass;
	Class iter, rootclass = Nil;








|







412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
		} else
			cls->info |= OBJC_CLASS_INFO_LOADED;
	}

	process_load_queue();
}

Class __saveds
objc_allocateClassPair(Class superclass OBJC_M68K_REG("a0"),
    const char *name OBJC_M68K_REG("a1"),
    size_t extra_bytes OBJC_M68K_REG("d0"))
{
	struct objc_class *cls, *metaclass;
	Class iter, rootclass = Nil;

448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
	metaclass->info = OBJC_CLASS_INFO_CLASS;
	metaclass->instance_size = (superclass != Nil ?
	    superclass->isa->instance_size : 0) + (long)extra_bytes;

	return cls;
}

void
objc_registerClassPair(Class cls OBJC_M68K_REG("a0"))
{
	objc_global_mutex_lock();

	register_class((struct objc_abi_class *)cls);

	if (cls->superclass != Nil) {







|







448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
	metaclass->info = OBJC_CLASS_INFO_CLASS;
	metaclass->instance_size = (superclass != Nil ?
	    superclass->isa->instance_size : 0) + (long)extra_bytes;

	return cls;
}

void __saveds
objc_registerClassPair(Class cls OBJC_M68K_REG("a0"))
{
	objc_global_mutex_lock();

	register_class((struct objc_abi_class *)cls);

	if (cls->superclass != Nil) {
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539

Class
objc_get_class(const char *name)
{
	return objc_getRequiredClass(name);
}

unsigned int
objc_getClassList(Class *buf OBJC_M68K_REG("a0"),
    unsigned int count OBJC_M68K_REG("d0"))
{
	unsigned int j;
	objc_global_mutex_lock();

	if (buf == NULL)







|







525
526
527
528
529
530
531
532
533
534
535
536
537
538
539

Class
objc_get_class(const char *name)
{
	return objc_getRequiredClass(name);
}

unsigned int __saveds
objc_getClassList(Class *buf OBJC_M68K_REG("a0"),
    unsigned int count OBJC_M68K_REG("d0"))
{
	unsigned int j;
	objc_global_mutex_lock();

	if (buf == NULL)
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
	}

	objc_global_mutex_unlock();

	return j;
}

Class *
objc_copyClassList(unsigned int *len OBJC_M68K_REG("a0"))
{
	Class *ret;
	unsigned int count;

	objc_global_mutex_lock();








|







566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
	}

	objc_global_mutex_unlock();

	return j;
}

Class *__saveds
objc_copyClassList(unsigned int *len OBJC_M68K_REG("a0"))
{
	Class *ret;
	unsigned int count;

	objc_global_mutex_lock();

590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
		*len = count;

	objc_global_mutex_unlock();

	return ret;
}

bool
class_isMetaClass(Class cls OBJC_M68K_REG("a0"))
{
	if (cls == Nil)
		return false;

	return (cls->info & OBJC_CLASS_INFO_METACLASS);
}

const char *
class_getName(Class cls OBJC_M68K_REG("a0"))
{
	if (cls == Nil)
		return "";

	return cls->name;
}

Class
class_getSuperclass(Class cls OBJC_M68K_REG("a0"))
{
	if (cls == Nil)
		return Nil;

	return cls->superclass;
}

unsigned long
class_getInstanceSize(Class cls OBJC_M68K_REG("a0"))
{
	if (cls == Nil)
		return 0;

	return cls->instance_size;
}

IMP
class_getMethodImplementation(Class cls OBJC_M68K_REG("a0"),
    SEL sel OBJC_M68K_REG("a1"))
{
	/*
	 * We use a dummy object here so that the normal lookup is used, even
	 * though we don't have an object. Doing so is safe, as objc_msg_lookup
	 * does not access the object, but only its class.







|








|








|








|








|







590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
		*len = count;

	objc_global_mutex_unlock();

	return ret;
}

bool __saveds
class_isMetaClass(Class cls OBJC_M68K_REG("a0"))
{
	if (cls == Nil)
		return false;

	return (cls->info & OBJC_CLASS_INFO_METACLASS);
}

const char *__saveds
class_getName(Class cls OBJC_M68K_REG("a0"))
{
	if (cls == Nil)
		return "";

	return cls->name;
}

Class __saveds
class_getSuperclass(Class cls OBJC_M68K_REG("a0"))
{
	if (cls == Nil)
		return Nil;

	return cls->superclass;
}

unsigned long __saveds
class_getInstanceSize(Class cls OBJC_M68K_REG("a0"))
{
	if (cls == Nil)
		return 0;

	return cls->instance_size;
}

IMP __saveds
class_getMethodImplementation(Class cls OBJC_M68K_REG("a0"),
    SEL sel OBJC_M68K_REG("a1"))
{
	/*
	 * We use a dummy object here so that the normal lookup is used, even
	 * though we don't have an object. Doing so is safe, as objc_msg_lookup
	 * does not access the object, but only its class.
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
	if (cls == Nil)
		return NULL;

	dummy.isa = cls;
	return objc_msg_lookup((id)&dummy, sel);
}

IMP
class_getMethodImplementation_stret(Class cls OBJC_M68K_REG("a0"),
    SEL sel OBJC_M68K_REG("a1"))
{
	/*
	 * Same as above, but use objc_msg_lookup_stret instead, so that the
	 * correct forwarding handler is returned.
	 */







|







651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
	if (cls == Nil)
		return NULL;

	dummy.isa = cls;
	return objc_msg_lookup((id)&dummy, sel);
}

IMP __saveds
class_getMethodImplementation_stret(Class cls OBJC_M68K_REG("a0"),
    SEL sel OBJC_M68K_REG("a1"))
{
	/*
	 * Same as above, but use objc_msg_lookup_stret instead, so that the
	 * correct forwarding handler is returned.
	 */
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
	ml->methods[0].imp = imp;

	cls->methodlist = ml;

	objc_update_dtable(cls);
}

const char *
class_getMethodTypeEncoding(Class cls OBJC_M68K_REG("a0"),
    SEL sel OBJC_M68K_REG("a1"))
{
	struct objc_method *method;

	if (cls == Nil)
		return NULL;







|







719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
	ml->methods[0].imp = imp;

	cls->methodlist = ml;

	objc_update_dtable(cls);
}

const char *__saveds
class_getMethodTypeEncoding(Class cls OBJC_M68K_REG("a0"),
    SEL sel OBJC_M68K_REG("a1"))
{
	struct objc_method *method;

	if (cls == Nil)
		return NULL;
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777

	if (cls->superclass != Nil)
		return class_getMethodTypeEncoding(cls->superclass, sel);

	return NULL;
}

bool
class_addMethod(Class cls OBJC_M68K_REG("a0"), SEL sel OBJC_M68K_REG("a1"),
    IMP imp OBJC_M68K_REG("a2"), const char *types OBJC_M68K_REG("a3"))
{
	bool ret;

	objc_global_mutex_lock();

	if (get_method(cls, sel) == NULL) {
		add_method(cls, sel, imp, types);
		ret = true;
	} else
		ret = false;

	objc_global_mutex_unlock();

	return ret;
}

IMP
class_replaceMethod(Class cls OBJC_M68K_REG("a0"), SEL sel OBJC_M68K_REG("a1"),
    IMP newimp OBJC_M68K_REG("a2"), const char *types OBJC_M68K_REG("a3"))
{
	struct objc_method *method;
	IMP oldimp;

	objc_global_mutex_lock();







|


















|







744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777

	if (cls->superclass != Nil)
		return class_getMethodTypeEncoding(cls->superclass, sel);

	return NULL;
}

bool __saveds
class_addMethod(Class cls OBJC_M68K_REG("a0"), SEL sel OBJC_M68K_REG("a1"),
    IMP imp OBJC_M68K_REG("a2"), const char *types OBJC_M68K_REG("a3"))
{
	bool ret;

	objc_global_mutex_lock();

	if (get_method(cls, sel) == NULL) {
		add_method(cls, sel, imp, types);
		ret = true;
	} else
		ret = false;

	objc_global_mutex_unlock();

	return ret;
}

IMP __saveds
class_replaceMethod(Class cls OBJC_M68K_REG("a0"), SEL sel OBJC_M68K_REG("a1"),
    IMP newimp OBJC_M68K_REG("a2"), const char *types OBJC_M68K_REG("a3"))
{
	struct objc_method *method;
	IMP oldimp;

	objc_global_mutex_lock();
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
	}

	objc_global_mutex_unlock();

	return oldimp;
}

Class
object_getClass(id obj_ OBJC_M68K_REG("a0"))
{
	struct objc_object *obj;

	if (obj_ == nil)
		return Nil;

	obj = (struct objc_object *)obj_;

	return obj->isa;
}

Class
object_setClass(id obj_ OBJC_M68K_REG("a0"), Class cls OBJC_M68K_REG("a1"))
{
	struct objc_object *obj;
	Class old;

	if (obj_ == nil)
		return Nil;

	obj = (struct objc_object *)obj_;

	old = obj->isa;
	obj->isa = cls;

	return old;
}

const char *
object_getClassName(id obj OBJC_M68K_REG("a0"))
{
	return class_getName(object_getClass(obj));
}

static void
unregister_class(Class rcls)







|












|
















|







786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
	}

	objc_global_mutex_unlock();

	return oldimp;
}

Class __saveds
object_getClass(id obj_ OBJC_M68K_REG("a0"))
{
	struct objc_object *obj;

	if (obj_ == nil)
		return Nil;

	obj = (struct objc_object *)obj_;

	return obj->isa;
}

Class __saveds
object_setClass(id obj_ OBJC_M68K_REG("a0"), Class cls OBJC_M68K_REG("a1"))
{
	struct objc_object *obj;
	Class old;

	if (obj_ == nil)
		return Nil;

	obj = (struct objc_object *)obj_;

	old = obj->isa;
	obj->isa = cls;

	return old;
}

const char *__saveds
object_getClassName(id obj OBJC_M68K_REG("a0"))
{
	return class_getName(object_getClass(obj));
}

static void
unregister_class(Class rcls)

Modified src/runtime/exception.m from [537d308f3a] to [2ef4db4bbd].

756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
	if (_Unwind_RaiseException(&e->exception) == _URC_END_OF_STACK &&
	    uncaught_exception_handler != NULL)
		uncaught_exception_handler(object);

	OBJC_ERROR("_Unwind_RaiseException() returned!")
}

objc_uncaught_exception_handler
objc_setUncaughtExceptionHandler(
    objc_uncaught_exception_handler handler OBJC_M68K_REG("a0"))
{
	objc_uncaught_exception_handler old = uncaught_exception_handler;
	uncaught_exception_handler = handler;

	return old;







|







756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
	if (_Unwind_RaiseException(&e->exception) == _URC_END_OF_STACK &&
	    uncaught_exception_handler != NULL)
		uncaught_exception_handler(object);

	OBJC_ERROR("_Unwind_RaiseException() returned!")
}

objc_uncaught_exception_handler __saveds
objc_setUncaughtExceptionHandler(
    objc_uncaught_exception_handler handler OBJC_M68K_REG("a0"))
{
	objc_uncaught_exception_handler old = uncaught_exception_handler;
	uncaught_exception_handler = handler;

	return old;

Modified src/runtime/linklib/linklib.m from [478a2413e5] to [6215304d3d].

74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
		._Unwind_GetIP = _Unwind_GetIP,
		._Unwind_GetGR = _Unwind_GetGR,
		._Unwind_SetIP = _Unwind_SetIP,
		._Unwind_SetGR = _Unwind_SetGR,
		._Unwind_Resume = _Unwind_Resume,
		.__register_frame_info = __register_frame_info,
		.__deregister_frame_info = __deregister_frame_info,
		.stdout_ = stdout,
		.stderr_ = stderr
	};
	objc_init(&libc);

	initialized = true;
}

OF_DESTRUCTOR()
{
	CloseLibrary(ObjFWRTBase);







<
<

|







74
75
76
77
78
79
80


81
82
83
84
85
86
87
88
89
		._Unwind_GetIP = _Unwind_GetIP,
		._Unwind_GetGR = _Unwind_GetGR,
		._Unwind_SetIP = _Unwind_SetIP,
		._Unwind_SetGR = _Unwind_SetGR,
		._Unwind_Resume = _Unwind_Resume,
		.__register_frame_info = __register_frame_info,
		.__deregister_frame_info = __deregister_frame_info,


	};
	objc_init(&libc, stdout, stderr);

	initialized = true;
}

OF_DESTRUCTOR()
{
	CloseLibrary(ObjFWRTBase);
166
167
168
169
170
171
172

173
174

175
176
177
178
179
180
181
	 * When using the generated inline stubs, the compiler does not emit
	 * any frame information, making the unwind fail. As unwind always
	 * starts from objc_exception_throw(), this means exceptions would
	 * never work. If, however, we're using a function pointer instead of
	 * the inline stub, the compiler does generate a frame and everything
	 * works fine.
	 */

	uintptr_t throw = (((uintptr_t)ObjFWRTBase) - 0x60);
	((void (*)(id OBJC_M68K_REG("a0")))throw)(object);


	OF_UNREACHABLE
}

int
objc_sync_enter(id object)
{







>


>







164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
	 * When using the generated inline stubs, the compiler does not emit
	 * any frame information, making the unwind fail. As unwind always
	 * starts from objc_exception_throw(), this means exceptions would
	 * never work. If, however, we're using a function pointer instead of
	 * the inline stub, the compiler does generate a frame and everything
	 * works fine.
	 */
	register void *a6 OBJC_M68K_REG("a6") = ObjFWRTBase;
	uintptr_t throw = (((uintptr_t)ObjFWRTBase) - 0x60);
	((void (*)(id OBJC_M68K_REG("a0")))throw)(object);
	(void)a6;

	OF_UNREACHABLE
}

int
objc_sync_enter(id object)
{
224
225
226
227
228
229
230

231
232



233
234
235
236
237
238
239
240
241
	 * When using the generated inline stubs, the compiler does not emit
	 * any frame information, making the unwind fail. As a result
	 * objc_enumerationMutation() might throw an exception that could never
	 * be caught. If, however, we're using a function pointer instead of
	 * the inline stub, the compiler does generate a frame and everything
	 * works fine.
	 */

	uintptr_t throw = (((uintptr_t)ObjFWRTBase) - 0x8A);
	((void (*)(id OBJC_M68K_REG("a0")))throw)(object);



}

int
__gnu_objc_personality_v0(int version, int actions, uint64_t ex_class,
    void *ex, void *ctx)
{
	return glue___gnu_objc_personality_v0(version, actions, &ex_class,
	    ex, ctx);
}







>
|
|
>
>
>









224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
	 * When using the generated inline stubs, the compiler does not emit
	 * any frame information, making the unwind fail. As a result
	 * objc_enumerationMutation() might throw an exception that could never
	 * be caught. If, however, we're using a function pointer instead of
	 * the inline stub, the compiler does generate a frame and everything
	 * works fine.
	 */
	register void *a6 OBJC_M68K_REG("a6") = ObjFWRTBase;
	uintptr_t enumerationMutation = (((uintptr_t)ObjFWRTBase) - 0x8A);
	((void (*)(id OBJC_M68K_REG("a0")))enumerationMutation)(object);
	(void)a6;

	OF_UNREACHABLE
}

int
__gnu_objc_personality_v0(int version, int actions, uint64_t ex_class,
    void *ex, void *ctx)
{
	return glue___gnu_objc_personality_v0(version, actions, &ex_class,
	    ex, ctx);
}

Modified src/runtime/lookup.m from [61e54bb565] to [2d11be3866].

112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
IMP
objc_method_not_found_stret(id obj, SEL sel)
{
	return common_method_not_found(obj, sel, objc_msg_lookup_stret,
	    forward_handler_stret);
}

void
objc_setForwardHandler(IMP forward OBJC_M68K_REG("a0"),
    IMP forward_stret OBJC_M68K_REG("a1"))
{
	forward_handler = forward;
	forward_handler_stret = forward_stret;
}

bool
class_respondsToSelector(Class cls OBJC_M68K_REG("a0"),
    SEL sel OBJC_M68K_REG("a1"))
{
	if (cls == Nil)
		return false;

	return (objc_dtable_get(cls->dtable, (uint32_t)sel->uid) != (IMP)0);







|







|







112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
IMP
objc_method_not_found_stret(id obj, SEL sel)
{
	return common_method_not_found(obj, sel, objc_msg_lookup_stret,
	    forward_handler_stret);
}

void __saveds
objc_setForwardHandler(IMP forward OBJC_M68K_REG("a0"),
    IMP forward_stret OBJC_M68K_REG("a1"))
{
	forward_handler = forward;
	forward_handler_stret = forward_stret;
}

bool __saveds
class_respondsToSelector(Class cls OBJC_M68K_REG("a0"),
    SEL sel OBJC_M68K_REG("a1"))
{
	if (cls == Nil)
		return false;

	return (objc_dtable_get(cls->dtable, (uint32_t)sel->uid) != (IMP)0);

Modified src/runtime/misc.m from [938c4e7c92] to [ad6038421d].

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdlib.h>

#include "ObjFW_RT.h"
#include "private.h"

static objc_enumeration_mutation_handler enumeration_mutation_handler = NULL;

void
objc_enumerationMutation(id obj)
{
	if (enumeration_mutation_handler != NULL)
		enumeration_mutation_handler(obj);
	else
		OBJC_ERROR("Object was mutated during enumeration!");
}







|







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdlib.h>

#include "ObjFW_RT.h"
#include "private.h"

static objc_enumeration_mutation_handler enumeration_mutation_handler = NULL;

void __saveds
objc_enumerationMutation(id obj)
{
	if (enumeration_mutation_handler != NULL)
		enumeration_mutation_handler(obj);
	else
		OBJC_ERROR("Object was mutated during enumeration!");
}

Modified src/runtime/private.h from [b79f584910] to [5f7c093a7a].

154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
	uintptr_t (*_Unwind_GetIP)(void *_Nonnull);
	uintptr_t (*_Unwind_GetGR)(void *_Nonnull, int);
	void (*_Unwind_SetIP)(void *_Nonnull, uintptr_t);
	void (*_Unwind_SetGR)(void *_Nonnull, int, uintptr_t);
	void (*_Unwind_Resume)(void *);
	void (*__register_frame_info)(const void *, void *);
	void (*__deregister_frame_info)(const void *);
	FILE *stdout_;
	FILE *stderr_;
} *objc_libc;
#endif

#ifdef OBJC_COMPILING_AMIGA_LIBRARY
# undef stdout
# undef stderr
extern FILE *stdout, *stderr;







<
<







154
155
156
157
158
159
160


161
162
163
164
165
166
167
	uintptr_t (*_Unwind_GetIP)(void *_Nonnull);
	uintptr_t (*_Unwind_GetGR)(void *_Nonnull, int);
	void (*_Unwind_SetIP)(void *_Nonnull, uintptr_t);
	void (*_Unwind_SetGR)(void *_Nonnull, int, uintptr_t);
	void (*_Unwind_Resume)(void *);
	void (*__register_frame_info)(const void *, void *);
	void (*__deregister_frame_info)(const void *);


} *objc_libc;
#endif

#ifdef OBJC_COMPILING_AMIGA_LIBRARY
# undef stdout
# undef stderr
extern FILE *stdout, *stderr;
231
232
233
234
235
236
237

238
239
240
241
242
243
244
245
246
247





248
249
250
251
252
253
254
    id _Nullable *_Nonnull object OBJC_M68K_REG("a0"),
    id _Nullable value OBJC_M68K_REG("a1"));
extern id _Nullable glue_objc_storeWeak(
    id _Nullable *_Nonnull object OBJC_M68K_REG("a0"),
    id _Nullable value OBJC_M68K_REG("a1"));
extern id _Nullable glue_objc_loadWeakRetained(
    id _Nullable *_Nonnull object OBJC_M68K_REG("a0"));

extern id glue_objc_initWeak(id _Nullable *_Nonnull object OBJC_M68K_REG("a0"),
    id _Nullable value OBJC_M68K_REG("a1"));
extern void glue_objc_destroyWeak(
    id _Nullable *_Nonnull object OBJC_M68K_REG("a0"));
extern id _Nullable glue_objc_loadWeak(
    id _Nullable *_Nonnull object OBJC_M68K_REG("a0"));
extern void glue_objc_copyWeak(id _Nullable *_Nonnull dest OBJC_M68K_REG("a0"),
    id _Nullable *_Nonnull src OBJC_M68K_REG("a1"));
extern void glue_objc_moveWeak(id _Nullable *_Nonnull dest OBJC_M68K_REG("a0"),
    id _Nullable *_Nonnull src OBJC_M68K_REG("a1"));





#endif

extern void objc_register_all_categories(struct objc_abi_symtab *_Nonnull);
extern struct objc_category *_Nullable *_Nullable
    objc_categories_for_class(Class _Nonnull);
extern void objc_unregister_all_categories(void);
extern void objc_initialize_class(Class _Nonnull);







>
|









>
>
>
>
>







229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
    id _Nullable *_Nonnull object OBJC_M68K_REG("a0"),
    id _Nullable value OBJC_M68K_REG("a1"));
extern id _Nullable glue_objc_storeWeak(
    id _Nullable *_Nonnull object OBJC_M68K_REG("a0"),
    id _Nullable value OBJC_M68K_REG("a1"));
extern id _Nullable glue_objc_loadWeakRetained(
    id _Nullable *_Nonnull object OBJC_M68K_REG("a0"));
extern id _Nullable glue_objc_initWeak(
    id _Nullable *_Nonnull object OBJC_M68K_REG("a0"),
    id _Nullable value OBJC_M68K_REG("a1"));
extern void glue_objc_destroyWeak(
    id _Nullable *_Nonnull object OBJC_M68K_REG("a0"));
extern id _Nullable glue_objc_loadWeak(
    id _Nullable *_Nonnull object OBJC_M68K_REG("a0"));
extern void glue_objc_copyWeak(id _Nullable *_Nonnull dest OBJC_M68K_REG("a0"),
    id _Nullable *_Nonnull src OBJC_M68K_REG("a1"));
extern void glue_objc_moveWeak(id _Nullable *_Nonnull dest OBJC_M68K_REG("a0"),
    id _Nullable *_Nonnull src OBJC_M68K_REG("a1"));
#else
# ifdef __saveds
#  undef __saveds
# endif
# define __saveds
#endif

extern void objc_register_all_categories(struct objc_abi_symtab *_Nonnull);
extern struct objc_category *_Nullable *_Nullable
    objc_categories_for_class(Class _Nonnull);
extern void objc_unregister_all_categories(void);
extern void objc_initialize_class(Class _Nonnull);

Modified src/runtime/protocol.m from [17dd02bdde] to [35e4a9c6cb].

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64

#import "ObjFW_RT.h"
#import "private.h"

@implementation Protocol
@end

const char *
protocol_getName(Protocol *p OBJC_M68K_REG("a0"))
{
	return p->name;
}

bool
protocol_isEqual(Protocol *a OBJC_M68K_REG("a0"),
    Protocol *b OBJC_M68K_REG("a1"))
{
	return (strcmp(protocol_getName(a), protocol_getName(b)) == 0);
}

bool
protocol_conformsToProtocol(Protocol *a OBJC_M68K_REG("a0"),
    Protocol *b OBJC_M68K_REG("a1"))
{
	if (protocol_isEqual(a, b))
		return true;

	for (struct objc_protocol_list *pl = a->protocol_list;
	    pl != NULL; pl = pl->next)
		for (long i = 0; i < pl->count; i++)
			if (protocol_conformsToProtocol(pl->list[i], b))
				return true;

	return false;
}

bool
class_conformsToProtocol(Class cls OBJC_M68K_REG("a0"),
    Protocol *p OBJC_M68K_REG("a1"))
{
	struct objc_category **cats;

	if (cls == Nil)
		return false;







|





|






|















|







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64

#import "ObjFW_RT.h"
#import "private.h"

@implementation Protocol
@end

const char *__saveds
protocol_getName(Protocol *p OBJC_M68K_REG("a0"))
{
	return p->name;
}

bool __saveds
protocol_isEqual(Protocol *a OBJC_M68K_REG("a0"),
    Protocol *b OBJC_M68K_REG("a1"))
{
	return (strcmp(protocol_getName(a), protocol_getName(b)) == 0);
}

bool __saveds
protocol_conformsToProtocol(Protocol *a OBJC_M68K_REG("a0"),
    Protocol *b OBJC_M68K_REG("a1"))
{
	if (protocol_isEqual(a, b))
		return true;

	for (struct objc_protocol_list *pl = a->protocol_list;
	    pl != NULL; pl = pl->next)
		for (long i = 0; i < pl->count; i++)
			if (protocol_conformsToProtocol(pl->list[i], b))
				return true;

	return false;
}

bool __saveds
class_conformsToProtocol(Class cls OBJC_M68K_REG("a0"),
    Protocol *p OBJC_M68K_REG("a1"))
{
	struct objc_category **cats;

	if (cls == Nil)
		return false;

Modified src/runtime/selector.m from [7ee8175e8f] to [7ad9a1d734].

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

static struct objc_hashtable *selectors = NULL;
static uint32_t selectors_cnt = 0;
static struct objc_sparsearray *selector_names = NULL;
static void **free_list = NULL;
static size_t free_list_cnt = 0;

void
objc_register_selector(struct objc_abi_selector *sel)
{
	struct objc_selector *rsel;
	const char *name;

	if (selectors_cnt > SEL_MAX)
		OBJC_ERROR("Out of selector slots!");







|







36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

static struct objc_hashtable *selectors = NULL;
static uint32_t selectors_cnt = 0;
static struct objc_sparsearray *selector_names = NULL;
static void **free_list = NULL;
static size_t free_list_cnt = 0;

void __saveds
objc_register_selector(struct objc_abi_selector *sel)
{
	struct objc_selector *rsel;
	const char *name;

	if (selectors_cnt > SEL_MAX)
		OBJC_ERROR("Out of selector slots!");
111
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
	if (symtab->sel_refs == NULL)
		return;

	for (sel = symtab->sel_refs; sel->name != NULL; sel++)
		objc_register_selector(sel);
}

const char *
sel_getName(SEL sel OBJC_M68K_REG("a0"))
{
	const char *ret;

	objc_global_mutex_lock();
	ret = objc_sparsearray_get(selector_names, (uint32_t)sel->uid);
	objc_global_mutex_unlock();

	return ret;
}

bool
sel_isEqual(SEL sel1 OBJC_M68K_REG("a0"), SEL sel2 OBJC_M68K_REG("a1"))
{
	return (sel1->uid == sel2->uid);
}

void
objc_unregister_all_selectors(void)







|











|







111
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
	if (symtab->sel_refs == NULL)
		return;

	for (sel = symtab->sel_refs; sel->name != NULL; sel++)
		objc_register_selector(sel);
}

const char *__saveds
sel_getName(SEL sel OBJC_M68K_REG("a0"))
{
	const char *ret;

	objc_global_mutex_lock();
	ret = objc_sparsearray_get(selector_names, (uint32_t)sel->uid);
	objc_global_mutex_unlock();

	return ret;
}

bool __saveds
sel_isEqual(SEL sel1 OBJC_M68K_REG("a0"), SEL sel2 OBJC_M68K_REG("a1"))
{
	return (sel1->uid == sel2->uid);
}

void
objc_unregister_all_selectors(void)