ObjFW  Diff

Differences From Artifact [edb787949c]:

To Artifact [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);
}