ObjFW  Check-in [ec5dcd5c9e]

Overview
Comment:runtime: Call {con,de}structors in Amiga library
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: ec5dcd5c9eecaa0ce407703a67a11ccc5086974f414d2fe54c273d7018ba57ab
User & Date: js on 2018-04-30 16:33:27
Other Links: manifest | tags
Context
2018-05-01
09:39
PLATFORMS.md: Add AmigaOS check-in: 1ff0d2581e user: js tags: trunk
2018-04-30
16:33
runtime: Call {con,de}structors in Amiga library check-in: ec5dcd5c9e user: js tags: trunk
14:51
runtime: Never use assert() check-in: 2ae3bc33e1 user: js tags: trunk
Changes

Modified src/runtime/ObjFW_RT.sfd from [5ad9f953ab] to [daf0164aa0].

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_set_libc(struct objc_libc *libc)(a0)
* Used by the compiler - these need glue code
void glue___objc_exec_class(void *module)(a0)
IMP glue_objc_msg_lookup(id obj, SEL sel)(a0,a1)
IMP glue_objc_msg_lookup_stret(id obj, SEL sel)(a0,a1)
IMP glue_objc_msg_lookup_super(struct objc_super *super, SEL sel)(a0,a1)
IMP glue_objc_msg_lookup_super_stret(struct objc_super *super, SEL sel)(a0,a1)
id glue_objc_lookUpClass(const char *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)(a0)
* Used by the compiler - these need glue code
void glue___objc_exec_class(void *module)(a0)
IMP glue_objc_msg_lookup(id obj, SEL sel)(a0,a1)
IMP glue_objc_msg_lookup_stret(id obj, SEL sel)(a0,a1)
IMP glue_objc_msg_lookup_super(struct objc_super *super, SEL sel)(a0,a1)
IMP glue_objc_msg_lookup_super_stret(struct objc_super *super, SEL sel)(a0,a1)
id glue_objc_lookUpClass(const char *name)(a0)

Modified src/runtime/amiga-library.m from [edb787949c] to [ec9a414c68].

40
41
42
43
44
45
46

47
48
49
50
51
52
53
54
55
56


57
58
59
60
61
62
63
{
	return -1;
}

struct ObjFWRTBase {
	struct Library library;
	BPTR seg_list;

};

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



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;







>










>
>







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








	return 0;
}

static BPTR
lib_null(void)
{
	return 0;
}

static void

objc_set_libc(struct objc_libc *libc_ OBJC_M68K_REG("a0"))
{


	libc = libc_;

	stdout = libc->stdout;
	stderr = libc->stderr;










}

void *
malloc(size_t size)
{
	return libc->malloc(size);
}







>
>
>
>
>
>
>











>
|

>
>




>
>
>
>
>
>
>
>
>
>







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

	base->initialized = true;
}

void *
malloc(size_t size)
{
	return libc->malloc(size);
}