ObjFW  Check-in [1cae2c720c]

Overview
Comment:runtime: Make exceptions work in Amiga library
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 1cae2c720c121e8bae2669f7e1b933cdb191695c23233e267857b3445620343a
User & Date: js on 2018-05-05 15:57:32
Other Links: manifest | tags
Context
2018-05-05
17:05
configure: Fix -O2 being dropped from OBJCFLAGS check-in: ae2aa3ef79 user: js tags: trunk
15:57
runtime: Make exceptions work in Amiga library check-in: 1cae2c720c user: js tags: trunk
2018-05-01
15:10
runtime: Add a linklib for the Amiga library check-in: f840649052 user: js tags: trunk
Changes

Modified src/runtime/Makefile from [f41345f3e8] to [a411b1ac5c].

57
58
59
60
61
62
63
64
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







|
57
58
59
60
61
62
63
64
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

Modified src/runtime/ObjFW_RT.h from [df243066af] to [209bda944a].

323
324
325
326
327
328
329




330
331
332
333
334
extern void objc_setProperty(id _Nonnull self, SEL _Nonnull _cmd,
    ptrdiff_t offset, id _Nullable value, bool atomic, signed char copy);
extern void objc_getPropertyStruct(void *_Nonnull dest,
    const void *_Nonnull src, ptrdiff_t size, bool atomic, bool strong);
extern void objc_setPropertyStruct(void *_Nonnull dest,
    const void *_Nonnull src, ptrdiff_t size, bool atomic, bool strong);
extern void objc_enumerationMutation(id _Nonnull obj);




#ifdef __cplusplus
}
#endif

#endif







>
>
>
>





323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
extern void objc_setProperty(id _Nonnull self, SEL _Nonnull _cmd,
    ptrdiff_t offset, id _Nullable value, bool atomic, signed char copy);
extern void objc_getPropertyStruct(void *_Nonnull dest,
    const void *_Nonnull src, ptrdiff_t size, bool atomic, bool strong);
extern void objc_setPropertyStruct(void *_Nonnull dest,
    const void *_Nonnull src, ptrdiff_t size, bool atomic, bool strong);
extern void objc_enumerationMutation(id _Nonnull obj);
# ifndef OBJC_NO_PERSONALITY_DECLARATION
extern int __gnu_objc_personality_v0(int version, int actions,
    uint64_t ex_class, void *_Nonnull ex, void *_Nonnull ctx);
# endif
#ifdef __cplusplus
}
#endif

#endif

Modified src/runtime/ObjFW_RT.sfd from [576423b2b1] to [256d65765a].

20
21
22
23
24
25
26

27
28
29
30
31
32
33
int glue_objc_sync_enter(id _Nullable object)(a0)
int glue_objc_sync_exit(id _Nullable object)(a0)
id glue_objc_getProperty(id _Nonnull self, SEL _Nonnull _cmd, ptrdiff_t offset, bool atomic)(a0,a1,d0,d1)
void glue_objc_setProperty(id _Nonnull self, SEL _Nonnull _cmd, ptrdiff_t offset, id value, bool atomic, signed char copy)(a0,a1,d0,a2,d1,d2)
void glue_objc_getPropertyStruct(void *_Nonnull dest, const void *_Nonnull src, ptrdiff_t size, bool atomic, bool strong)(a0,a1,d0,d1,d2)
void glue_objc_setPropertyStruct(void *_Nonnull dest, const void *_Nonnull src, ptrdiff_t size, bool atomic, bool strong)(a0,a1,d0,d1,d2)
void glue_objc_enumerationMutation(id _Nonnull obj)(a0)

* Functions declared in ObjFW_RT.h
SEL _Nonnull sel_registerName(const char *_Nonnull name)(a0)
const char *_Nonnull sel_getName(SEL _Nonnull sel)(a0)
bool sel_isEqual(SEL _Nonnull sel1, SEL _Nonnull sel2)(a0,a1)
Class _Nonnull objc_allocateClassPair(Class _Nullable superclass, const char *_Nonnull name, size_t extra_bytes)(a0,a1,d0)
void objc_registerClassPair(Class _Nonnull cls)(a0)
unsigned int objc_getClassList(Class _Nonnull *_Nullable buf, unsigned int count)(a0,d0)







>







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
int glue_objc_sync_enter(id _Nullable object)(a0)
int glue_objc_sync_exit(id _Nullable object)(a0)
id glue_objc_getProperty(id _Nonnull self, SEL _Nonnull _cmd, ptrdiff_t offset, bool atomic)(a0,a1,d0,d1)
void glue_objc_setProperty(id _Nonnull self, SEL _Nonnull _cmd, ptrdiff_t offset, id value, bool atomic, signed char copy)(a0,a1,d0,a2,d1,d2)
void glue_objc_getPropertyStruct(void *_Nonnull dest, const void *_Nonnull src, ptrdiff_t size, bool atomic, bool strong)(a0,a1,d0,d1,d2)
void glue_objc_setPropertyStruct(void *_Nonnull dest, const void *_Nonnull src, ptrdiff_t size, bool atomic, bool strong)(a0,a1,d0,d1,d2)
void glue_objc_enumerationMutation(id _Nonnull obj)(a0)
int glue___gnu_objc_personality_v0(int version, int actions, uint64_t *_Nonnull ex_class, void *_Nonnull ex, void *_Nonnull ctx)(d0,d1,d2,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)
bool sel_isEqual(SEL _Nonnull sel1, SEL _Nonnull sel2)(a0,a1)
Class _Nonnull objc_allocateClassPair(Class _Nullable superclass, const char *_Nonnull name, size_t extra_bytes)(a0,a1,d0)
void objc_registerClassPair(Class _Nonnull cls)(a0)
unsigned int objc_getClassList(Class _Nonnull *_Nullable buf, unsigned int count)(a0,d0)

Modified src/runtime/amiga-glue.m from [f6066a455d] to [41f74e1272].

136
137
138
139
140
141
142








}

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















>
>
>
>
>
>
>
>
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
}

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);
}

Modified src/runtime/amiga-library.m from [6c5b775beb] to [3eba26b1b7].

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
_start()
{
	return -1;
}

struct ObjFWRTBase {
	struct Library library;
	BPTR seg_list;
	bool initialized;
};





struct ExecBase *SysBase;
#ifdef OF_MORPHOS
const ULONG __abox__ = 1;
#endif
struct WBStartup *_WBenchMsg;
struct objc_libc *libc;
FILE *stdout;
FILE *stderr;
extern uintptr_t __CTOR_LIST__[];
extern uintptr_t __DTOR_LIST__[];

static struct Library *
lib_init(struct ExecBase *exec_base OBJC_M68K_REG("a6"),
    BPTR 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"))
{
	OBJC_M68K_ARG(struct ObjFWRTBase *, base, REG_A6)

	base->library.lib_OpenCnt++;
	base->library.lib_Flags &= ~LIBF_DELEXP;

	return &base->library;
}

static BPTR
expunge(struct ObjFWRTBase *base)
{
	BPTR seg_list;

	if (base->library.lib_OpenCnt > 0) {
		base->library.lib_Flags |= LIBF_DELEXP;
		return 0;
	}

	seg_list = base->seg_list;

	Remove(&base->library.lib_Node);
	FreeMem((char *)base - base->library.lib_NegSize,
	    base->library.lib_NegSize + base->library.lib_PosSize);

	return seg_list;
}

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

	return expunge(base);
}

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






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

	if (base->initialized) {
		for (uintptr_t *iter = &__DTOR_LIST__[1]; *iter != 0; iter++) {
			void (*dtor)(void) = (void (*)(void))*iter++;
			dtor();
		}
	}

	return 0;
}

static BPTR
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_;






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

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







|


>
>
>
>





<



<
<



|




















|


|















|







|




>
>
>
>
>




<
<
<
<
<
<
<



|















>
>
>
>
>







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
_start()
{
	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"))
{
	OBJC_M68K_ARG(struct ObjFWRTBase *, base, REG_A6)

	base->library.lib_OpenCnt++;
	base->library.lib_Flags &= ~LIBF_DELEXP;

	return &base->library;
}

static void *
expunge(struct ObjFWRTBase *base)
{
	void *seg_list;

	if (base->library.lib_OpenCnt > 0) {
		base->library.lib_Flags |= LIBF_DELEXP;
		return 0;
	}

	seg_list = base->seg_list;

	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();
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
}

void
abort(void)
{
	libc->abort();
}



































































#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
static CONST_APTR function_table[] = {
	(CONST_APTR)lib_open,
	(CONST_APTR)lib_close,
	(CONST_APTR)lib_expunge,
	(CONST_APTR)lib_null,
#include "amiga-library-functable.inc"
	(CONST_APTR)-1,
};
#pragma GCC diagnostic pop

static struct {
	ULONG data_size;
	CONST_APTR *function_table;
	ULONG *data_table;
	struct Library *(*init_func)(
	    struct ExecBase *exec_base OBJC_M68K_REG("a6"),
	    BPTR seg_list OBJC_M68K_REG("a0"),
	    struct ObjFWRTBase *base OBJC_M68K_REG("d0"));
} init_table = {
	sizeof(struct ObjFWRTBase),
	function_table,
	NULL,
	lib_init
};







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



















|







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
}

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,
	(CONST_APTR)lib_expunge,
	(CONST_APTR)lib_null,
#include "amiga-library-functable.inc"
	(CONST_APTR)-1,
};
#pragma GCC diagnostic pop

static struct {
	ULONG data_size;
	CONST_APTR *function_table;
	ULONG *data_table;
	struct Library *(*init_func)(
	    struct ExecBase *exec_base OBJC_M68K_REG("a6"),
	    void *seg_list OBJC_M68K_REG("a0"),
	    struct ObjFWRTBase *base OBJC_M68K_REG("d0"));
} init_table = {
	sizeof(struct ObjFWRTBase),
	function_table,
	NULL,
	lib_init
};

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

12
13
14
15
16
17
18


19
20
21
22
23
24
25
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"



#include <stdio.h>
#include <stdlib.h>
#include <string.h>

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







>
>







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#define OBJC_NO_PERSONALITY_DECLARATION

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

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

Modified src/runtime/linklib/linklib.m from [03684c47f6] to [ca3819c013].

21
22
23
24
25
26
27














28
29
30
31
32
33
34
#import "private.h"
#import "macros.h"

#include <proto/exec.h>
#include <stdio.h>
#include <stdlib.h>















struct Library *ObjFWRTBase;

static void __attribute__((__constructor__))
init(void)
{
	static bool initialized = false;
	static struct objc_libc libc;







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







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
#import "private.h"
#import "macros.h"

#include <proto/exec.h>
#include <stdio.h>
#include <stdlib.h>

extern int _Unwind_RaiseException(void *);
extern void _Unwind_DeleteException(void *);
extern void *_Unwind_GetLanguageSpecificData(void *);
extern uintptr_t _Unwind_GetRegionStart(void *);
extern uintptr_t _Unwind_GetDataRelBase(void *);
extern uintptr_t _Unwind_GetTextRelBase(void *);
extern uintptr_t _Unwind_GetIP(void *);
extern uintptr_t _Unwind_GetGR(void *, int);
extern void _Unwind_SetIP(void *, uintptr_t);
extern void _Unwind_SetGR(void *, int, uintptr_t);
extern void _Unwind_Resume(void *);
extern void __register_frame_info(const void *, void *);
extern void __deregister_frame_info(const void *);

struct Library *ObjFWRTBase;

static void __attribute__((__constructor__))
init(void)
{
	static bool initialized = false;
	static struct objc_libc libc;
46
47
48
49
50
51
52














53
54
55
56
57
58
59
		.calloc = calloc,
		.realloc = realloc,
		.free = free,
		.vfprintf = vfprintf,
		.fputs = fputs,
		.exit = exit,
		.abort = abort,














		.stdout_ = stdout,
		.stderr_ = stderr
	};
	objc_init(&libc);

	initialized = true;
}







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







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
		.calloc = calloc,
		.realloc = realloc,
		.free = free,
		.vfprintf = vfprintf,
		.fputs = fputs,
		.exit = exit,
		.abort = abort,
		._Unwind_RaiseException = _Unwind_RaiseException,
		._Unwind_DeleteException = _Unwind_DeleteException,
		._Unwind_GetLanguageSpecificData =
		    _Unwind_GetLanguageSpecificData,
		._Unwind_GetRegionStart = _Unwind_GetRegionStart,
		._Unwind_GetDataRelBase = _Unwind_GetDataRelBase,
		._Unwind_GetTextRelBase = _Unwind_GetTextRelBase,
		._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;
}
128
129
130
131
132
133
134





135






136
137
138
139
140
141
142
{
	return glue_objc_get_class(name);
}

void
objc_exception_throw(id object)
{





	glue_objc_exception_throw(object);







	OF_UNREACHABLE
}

int
objc_sync_enter(id object)
{







>
>
>
>
>
|
>
>
>
>
>
>







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
{
	return glue_objc_get_class(name);
}

void
objc_exception_throw(id object)
{
	/*
	 * This does not use the glue code to hack around a compiler bug.
	 *
	 * 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)
{
177
178
179
180
181
182
183








}

void
objc_enumerationMutation(id obj)
{
	glue_objc_enumerationMutation(obj);
}















>
>
>
>
>
>
>
>
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
}

void
objc_enumerationMutation(id obj)
{
	glue_objc_enumerationMutation(obj);
}

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/private.h from [2cf61640d4] to [d94124ff8f].

141
142
143
144
145
146
147













148
149
150
151
152
153
154
	void *(*calloc)(size_t, size_t);
	void *(*realloc)(void *, size_t);
	void (*free)(void *);
	int (*vfprintf)(FILE *, const char *, va_list);
	int (*fputs)(const char *, FILE *);
	void (*exit)(int);
	void (*abort)(void);













	FILE *stdout_;
	FILE *stderr_;
} *objc_libc;
#endif

#ifdef OBJC_COMPILING_AMIGA_LIBRARY
# undef stdout







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







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
	void *(*calloc)(size_t, size_t);
	void *(*realloc)(void *, size_t);
	void (*free)(void *);
	int (*vfprintf)(FILE *, const char *, va_list);
	int (*fputs)(const char *, FILE *);
	void (*exit)(int);
	void (*abort)(void);
	int (*_Unwind_RaiseException)(void *_Nonnull);
	void (*_Unwind_DeleteException)(void *_Nonnull);
	void *(*_Unwind_GetLanguageSpecificData)(void *_Nonnull);
	uintptr_t (*_Unwind_GetRegionStart)(void *_Nonnull);
	uintptr_t (*_Unwind_GetDataRelBase)(void *_Nonnull);
	uintptr_t (*_Unwind_GetTextRelBase)(void *_Nonnull);
	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
191
192
193
194
195
196
197





198
199
200
201
202
203
204
    ptrdiff_t size OBJC_M68K_REG("d0"), bool atomic OBJC_M68K_REG("d1"),
    bool strong OBJC_M68K_REG("d2"));
extern void glue_objc_setPropertyStruct(void *_Nonnull dest OBJC_M68K_REG("a0"),
    const void *_Nonnull src OBJC_M68K_REG("a1"),
    ptrdiff_t size OBJC_M68K_REG("d0"), bool atomic OBJC_M68K_REG("d1"),
    bool strong OBJC_M68K_REG("d2"));
extern void glue_objc_enumerationMutation(id _Nonnull obj OBJC_M68K_REG("a0"));





#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);







>
>
>
>
>







204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
    ptrdiff_t size OBJC_M68K_REG("d0"), bool atomic OBJC_M68K_REG("d1"),
    bool strong OBJC_M68K_REG("d2"));
extern void glue_objc_setPropertyStruct(void *_Nonnull dest OBJC_M68K_REG("a0"),
    const void *_Nonnull src OBJC_M68K_REG("a1"),
    ptrdiff_t size OBJC_M68K_REG("d0"), bool atomic OBJC_M68K_REG("d1"),
    bool strong OBJC_M68K_REG("d2"));
extern void glue_objc_enumerationMutation(id _Nonnull obj OBJC_M68K_REG("a0"));
extern int glue___gnu_objc_personality_v0(int version OBJC_M68K_REG("d0"),
    int actions OBJC_M68K_REG("d1"),
    uint64_t *_Nonnull ex_class OBJC_M68K_REG("d2"),
    void *_Nonnull ex OBJC_M68K_REG("a0"),
    void *_Nonnull ctx 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);