ObjFW  Check-in [57f0d10b19]

Overview
Comment:runtime/linklib: Use init/exit list on amiga-gcc

The init list is executed before all constructors and the exit list
after all destructors. This makes sure the runtime library is present
during all constructors and destructors.

Use -2 so that objfw.library later on can use -1.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 57f0d10b19af99f06a734dcc2fe0468b0f97870554fcca3a476f687f0b637665
User & Date: js on 2018-05-26 15:18:42
Other Links: manifest | tags
Context
2018-05-26
15:22
Work around amiga-gcc not having trunc() check-in: 15a59cf9d5 user: js tags: trunk
15:18
runtime/linklib: Use init/exit list on amiga-gcc check-in: 57f0d10b19 user: js tags: trunk
14:49
Remove #define INTUITION_CLASSES_H hack check-in: b31bd48f90 user: js tags: trunk
Changes

Modified src/runtime/linklib/linklib.m from [127b4c9eeb] to [715e972f4a].

23
24
25
26
27
28
29




30
31
32
33
34
35
36

#include <proto/exec.h>

#import "inline.h"

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





#ifdef HAVE_SJLJ_EXCEPTIONS
extern int _Unwind_SjLj_RaiseException(void *);
#else
extern int _Unwind_RaiseException(void *);
#endif
extern void _Unwind_DeleteException(void *);







>
>
>
>







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

#include <proto/exec.h>

#import "inline.h"

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

#ifdef OF_AMIGAOS_M68K
# include <stabs.h>
#endif

#ifdef HAVE_SJLJ_EXCEPTIONS
extern int _Unwind_SjLj_RaiseException(void *);
#else
extern int _Unwind_RaiseException(void *);
#endif
extern void _Unwind_DeleteException(void *);
49
50
51
52
53
54
55


56

57
58
59
60
61
62
63
64
#endif
extern void __register_frame_info(const void *, void *);
extern void __deregister_frame_info(const void *);

struct Library *ObjFWRTBase;
void *__objc_class_name_Protocol;



static void __attribute__((__constructor__))

init(void)
{
	static bool initialized = false;
	struct objc_libc libc = {
		.malloc = malloc,
		.calloc = calloc,
		.realloc = realloc,
		.free = free,







>
>
|
>
|







53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#endif
extern void __register_frame_info(const void *, void *);
extern void __deregister_frame_info(const void *);

struct Library *ObjFWRTBase;
void *__objc_class_name_Protocol;

static void
#ifndef OF_AMIGAOS_M68K
    __attribute__((__constructor__))
#endif
ctor(void)
{
	static bool initialized = false;
	struct objc_libc libc = {
		.malloc = malloc,
		.calloc = calloc,
		.realloc = realloc,
		.free = free,
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
		fputs("Failed to initialize objfw_rt.library!\n", stderr);
		abort();
	}

	initialized = true;
}


OF_DESTRUCTOR()





{
	CloseLibrary(ObjFWRTBase);
}






void
__objc_exec_class(void *module)
{
	/*
	 * The compiler generates constructors that call into this, so it is
	 * possible that we are not set up yet when we get called.
	 */
	init();

	__objc_exec_class_m68k(module);
}

IMP
objc_msg_lookup(id obj, SEL sel)
{







>
|
>
>
>
>
>



>
>
>
>
>








|







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
		fputs("Failed to initialize objfw_rt.library!\n", stderr);
		abort();
	}

	initialized = true;
}

static void
#ifndef OF_AMIGAOS_M68K
    __attribute__((__destructor__))
#else
    __attribute__((__unused__))
#endif
dtor(void)
{
	CloseLibrary(ObjFWRTBase);
}

#ifdef OF_AMIGAOS_M68K
ADD2INIT(ctor, -2);
ADD2EXIT(dtor, -2);
#endif

void
__objc_exec_class(void *module)
{
	/*
	 * The compiler generates constructors that call into this, so it is
	 * possible that we are not set up yet when we get called.
	 */
	ctor();

	__objc_exec_class_m68k(module);
}

IMP
objc_msg_lookup(id obj, SEL sel)
{