ObjFW  Diff

Differences From Artifact [df451058ad]:

To Artifact [c4ad743978]:


19
20
21
22
23
24
25

26
27
28
29
30
31
32

#import "ObjFWRT.h"
#import "amiga-library.h"
#import "macros.h"
#import "private.h"

#include <proto/exec.h>


struct ObjFWRTBase;

#import "inline.h"

#include <errno.h>
#include <stdio.h>







>







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

#import "ObjFWRT.h"
#import "amiga-library.h"
#import "macros.h"
#import "private.h"

#include <proto/exec.h>
#include <proto/intuition.h>

struct ObjFWRTBase;

#import "inline.h"

#include <errno.h>
#include <stdio.h>
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
void *__objc_class_name_Protocol;

static int *
get_errno(void)
{
	return &errno;
}























static void __attribute__((__used__))
ctor(void)
{
	static bool initialized = false;
	struct objc_libc libc = {
		.malloc = malloc,
		.calloc = calloc,
		.realloc = realloc,
		.free = free,
		.vfprintf = vfprintf,
		.fflush = fflush,
		.abort = abort,
#ifdef HAVE_SJLJ_EXCEPTIONS
		._Unwind_SjLj_RaiseException = _Unwind_SjLj_RaiseException,
#else
		._Unwind_RaiseException = _Unwind_RaiseException,
#endif
		._Unwind_DeleteException = _Unwind_DeleteException,
		._Unwind_GetLanguageSpecificData =







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










<
<
<







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
void *__objc_class_name_Protocol;

static int *
get_errno(void)
{
	return &errno;
}

static void
error(const char *string, ULONG arg)
{
	struct Library *IntuitionBase = OpenLibrary("intuition.library", 0);

	if (IntuitionBase != NULL) {
		struct EasyStruct easy = {
			.es_StructSize = sizeof(easy),
			.es_Flags = 0,
			.es_Title = (UBYTE *)NULL,
			.es_TextFormat = (UBYTE *)string,
			(UBYTE *)"OK"
		};

		EasyRequest(NULL, &easy, NULL, arg);

		CloseLibrary(IntuitionBase);
	}

	exit(EXIT_FAILURE);
}

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



#ifdef HAVE_SJLJ_EXCEPTIONS
		._Unwind_SjLj_RaiseException = _Unwind_SjLj_RaiseException,
#else
		._Unwind_RaiseException = _Unwind_RaiseException,
#endif
		._Unwind_DeleteException = _Unwind_DeleteException,
		._Unwind_GetLanguageSpecificData =
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
		.__deregister_frame_info = __deregister_frame_info,
#endif
#ifdef OF_MORPHOS
		.__register_frame = __register_frame,
		.__deregister_frame = __deregister_frame,
#endif
		.get_errno = get_errno,





	};

	if (initialized)
		return;

	if ((ObjFWRTBase = OpenLibrary(OBJFWRT_AMIGA_LIB,
	    OBJFWRT_LIB_MINOR)) == NULL) {
		/*
		 * The linklib is used by objfw(68k).library as well, so we
		 * can't have the compiler optimize this to another function,
		 * hence the use of an unnecessary format specifier.
		 */
		fprintf(stderr, "Failed to open %s!\n", OBJFWRT_AMIGA_LIB);
		abort();
	}

	if (!glue_objc_init(1, &libc, __sF)) {
		/*
		 * The linklib is used by objfw(68k).library as well, so we
		 * can't have the compiler optimize this to another function,
		 * hence the use of an unnecessary format specifier.
		 */
		fprintf(stderr, "Failed to initialize %s!\n",
		    OBJFWRT_AMIGA_LIB);
		abort();
	}

	initialized = true;
}

static void __attribute__((__used__))
dtor(void)
{







>
>
>
>
>






|
<
<
<
<
<
|
|
|
<
|
<
<
<
<
<
<
|
<
<







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
		.__deregister_frame_info = __deregister_frame_info,
#endif
#ifdef OF_MORPHOS
		.__register_frame = __register_frame,
		.__deregister_frame = __deregister_frame,
#endif
		.get_errno = get_errno,
#ifdef OF_AMIGAOS_M68K
		.vsnprintf = vsnprintf,
#endif
		.atexit = atexit,
		.exit = exit,
	};

	if (initialized)
		return;

	if ((ObjFWRTBase = OpenLibrary(OBJFWRT_AMIGA_LIB,
	    OBJFWRT_LIB_MINOR)) == NULL)





		error("Failed to open " OBJFWRT_AMIGA_LIB " version %lu!",
		    OBJFWRT_LIB_MINOR);


	if (!glue_objc_init(1, &libc, __sF))






		error("Failed to initialize " OBJFWRT_AMIGA_LIB "!", 0);



	initialized = true;
}

static void __attribute__((__used__))
dtor(void)
{