ObjFW  Check-in [5831626f68]

Overview
Comment:platform.h: Rename OF_AMIGAOS3 to OF_AMIGAOS_M68K

The reason for this is that, in theory, this also supports versions
older than 3.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5831626f68bbeeb02e7384c3efbafcc4238469fd7f6f7b4b294899cc73314c63
User & Date: js on 2018-05-13 19:24:28
Other Links: manifest | tags
Context
2018-05-13
19:26
runtime: Remove unused -D flag check-in: e46fe510af user: js tags: trunk
19:24
platform.h: Rename OF_AMIGAOS3 to OF_AMIGAOS_M68K check-in: 5831626f68 user: js tags: trunk
18:38
platform.h: Add m68k check-in: a5eafc5004 user: js tags: trunk
Changes

Modified src/OFApplication.m from [af29800e76] to [d91a949b73].

49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# include <crt_externs.h>
#elif defined(OF_WINDOWS)
# include <windows.h>

extern int _CRT_glob;
extern void __wgetmainargs(int *, wchar_t ***, wchar_t ***, int, int *);
#elif defined(OF_AMIGAOS)
# ifdef OF_AMIGAOS3
#  define INTUITION_CLASSES_H
# endif
# include <proto/exec.h>
# include <proto/dos.h>
#elif !defined(OF_IOS)
extern char **environ;
#endif







|







49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# include <crt_externs.h>
#elif defined(OF_WINDOWS)
# include <windows.h>

extern int _CRT_glob;
extern void __wgetmainargs(int *, wchar_t ***, wchar_t ***, int, int *);
#elif defined(OF_AMIGAOS)
# ifdef OF_AMIGAOS_M68K
#  define INTUITION_CLASSES_H
# endif
# include <proto/exec.h>
# include <proto/dos.h>
#elif !defined(OF_IOS)
extern char **environ;
#endif

Modified src/OFFile.m from [8331bd9e6b] to [994cdd90a3].

54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

#ifdef OF_NINTENDO_DS
# include <stdbool.h>
# include <filesystem.h>
#endif

#ifdef OF_AMIGAOS
# ifdef OF_AMIGAOS3
#  define INTUITION_CLASSES_H
# endif
# include <proto/dos.h>
#endif

#ifndef O_BINARY
# define O_BINARY 0







|







54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

#ifdef OF_NINTENDO_DS
# include <stdbool.h>
# include <filesystem.h>
#endif

#ifdef OF_AMIGAOS
# ifdef OF_AMIGAOS_M68K
#  define INTUITION_CLASSES_H
# endif
# include <proto/dos.h>
#endif

#ifndef O_BINARY
# define O_BINARY 0

Modified src/OFFileManager.m from [61a3729f18] to [bdbcbaf8ab].

54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifdef OF_WINDOWS
# include <windows.h>
# include <direct.h>
# include <ntdef.h>
#endif

#ifdef OF_AMIGAOS
# ifdef OF_AMIGAOS3
#  define INTUITION_CLASSES_H
# endif
# include <proto/exec.h>
# include <proto/dos.h>
# include <proto/locale.h>
#endif








|







54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifdef OF_WINDOWS
# include <windows.h>
# include <direct.h>
# include <ntdef.h>
#endif

#ifdef OF_AMIGAOS
# ifdef OF_AMIGAOS_M68K
#  define INTUITION_CLASSES_H
# endif
# include <proto/exec.h>
# include <proto/dos.h>
# include <proto/locale.h>
#endif

Modified src/OFLocalization.m from [16040a43d0] to [d4d11c9c0c].

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

#ifdef OF_AMIGAOS
# ifdef OF_AMIGAOS4
#  define __NOLIBBASE__
#  define __NOGLOBALIFACE__
#  define __USE_INLINE__
# endif
# ifdef OF_AMIGAOS3
#  define INTUITION_CLASSES_H
# endif
# include <proto/dos.h>
# include <proto/exec.h>
# include <proto/locale.h>
#endif








|







31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

#ifdef OF_AMIGAOS
# ifdef OF_AMIGAOS4
#  define __NOLIBBASE__
#  define __NOGLOBALIFACE__
#  define __USE_INLINE__
# endif
# ifdef OF_AMIGAOS_M68K
#  define INTUITION_CLASSES_H
# endif
# include <proto/dos.h>
# include <proto/exec.h>
# include <proto/locale.h>
#endif

Modified src/OFStdIOStream.h from [25b6014eaa] to [62b2bfde7a].

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 * file.
 */

#import "OFStream.h"
#import "OFKernelEventObserver.h"

#ifdef OF_AMIGAOS
# ifdef OF_AMIGAOS3
#  define INTUITION_CLASSES_H
# endif
# include <proto/dos.h>
# ifdef OF_AMIGAOS3
#  undef INTUITION_CLASSES_H
# endif
#endif

OF_ASSUME_NONNULL_BEGIN

/*!







|



|







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 * file.
 */

#import "OFStream.h"
#import "OFKernelEventObserver.h"

#ifdef OF_AMIGAOS
# ifdef OF_AMIGAOS_M68K
#  define INTUITION_CLASSES_H
# endif
# include <proto/dos.h>
# ifdef OF_AMIGAOS_M68K
#  undef INTUITION_CLASSES_H
# endif
#endif

OF_ASSUME_NONNULL_BEGIN

/*!

Modified src/OFStdIOStream.m from [6647a44cbe] to [3ca31d2e74].

38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

#import "OFNotOpenException.h"
#import "OFOutOfRangeException.h"
#import "OFReadFailedException.h"
#import "OFWriteFailedException.h"

#ifdef OF_AMIGAOS
# ifdef OF_AMIGAOS3
#  define INTUITION_CLASSES_H
# endif
# include <proto/exec.h>
#endif

/* References for static linking */
#ifdef OF_WINDOWS







|







38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

#import "OFNotOpenException.h"
#import "OFOutOfRangeException.h"
#import "OFReadFailedException.h"
#import "OFWriteFailedException.h"

#ifdef OF_AMIGAOS
# ifdef OF_AMIGAOS_M68K
#  define INTUITION_CLASSES_H
# endif
# include <proto/exec.h>
#endif

/* References for static linking */
#ifdef OF_WINDOWS

Modified src/OFString.m from [2d7f2091d4] to [6b9d12d673].

65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
 * It seems strtod is buggy on Win32.
 * However, the MinGW version __strtod seems to be ok.
 */
#ifdef __MINGW32__
# define strtod __strtod
#endif

#ifdef OF_AMIGAOS3
/* libnix has strtod, but not strtof */
# define strtof strtod
#endif

static struct {
	Class isa;
} placeholder;







|







65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
 * It seems strtod is buggy on Win32.
 * However, the MinGW version __strtod seems to be ok.
 */
#ifdef __MINGW32__
# define strtod __strtod
#endif

#ifdef OF_AMIGAOS_M68K
/* libnix has strtod, but not strtof */
# define strtof strtod
#endif

static struct {
	Class isa;
} placeholder;
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
	return value;
}

- (float)floatValue
{
	void *pool = objc_autoreleasePoolPush();

#if defined(OF_AMIGAOS3) || defined(OF_MORPHOS)
	OFString *stripped = [self stringByDeletingEnclosingWhitespaces];

	if ([stripped caseInsensitiveCompare: @"INF"] == OF_ORDERED_SAME ||
	    [stripped caseInsensitiveCompare: @"INFINITY"] == OF_ORDERED_SAME)
		return INFINITY;
	if ([stripped caseInsensitiveCompare: @"-INF"] == OF_ORDERED_SAME ||
	    [stripped caseInsensitiveCompare: @"-INFINITY"] == OF_ORDERED_SAME)







|







2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
	return value;
}

- (float)floatValue
{
	void *pool = objc_autoreleasePoolPush();

#if defined(OF_AMIGAOS_M68K) || defined(OF_MORPHOS)
	OFString *stripped = [self stringByDeletingEnclosingWhitespaces];

	if ([stripped caseInsensitiveCompare: @"INF"] == OF_ORDERED_SAME ||
	    [stripped caseInsensitiveCompare: @"INFINITY"] == OF_ORDERED_SAME)
		return INFINITY;
	if ([stripped caseInsensitiveCompare: @"-INF"] == OF_ORDERED_SAME ||
	    [stripped caseInsensitiveCompare: @"-INFINITY"] == OF_ORDERED_SAME)
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
	return value;
}

- (double)doubleValue
{
	void *pool = objc_autoreleasePoolPush();

#if defined(OF_AMIGAOS3) || defined(OF_MORPHOS)
	OFString *stripped = [self stringByDeletingEnclosingWhitespaces];

	if ([stripped caseInsensitiveCompare: @"INF"] == OF_ORDERED_SAME ||
	    [stripped caseInsensitiveCompare: @"INFINITY"] == OF_ORDERED_SAME)
		return INFINITY;
	if ([stripped caseInsensitiveCompare: @"-INF"] == OF_ORDERED_SAME ||
	    [stripped caseInsensitiveCompare: @"-INFINITY"] == OF_ORDERED_SAME)







|







2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
	return value;
}

- (double)doubleValue
{
	void *pool = objc_autoreleasePoolPush();

#if defined(OF_AMIGAOS_M68K) || defined(OF_MORPHOS)
	OFString *stripped = [self stringByDeletingEnclosingWhitespaces];

	if ([stripped caseInsensitiveCompare: @"INF"] == OF_ORDERED_SAME ||
	    [stripped caseInsensitiveCompare: @"INFINITY"] == OF_ORDERED_SAME)
		return INFINITY;
	if ([stripped caseInsensitiveCompare: @"-INF"] == OF_ORDERED_SAME ||
	    [stripped caseInsensitiveCompare: @"-INFINITY"] == OF_ORDERED_SAME)

Modified src/OFSystemInfo.m from [a9b82e1cd3] to [3534efb1b1].

109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
	operatingSystemName = @"iOS";
#elif defined(OF_MACOS)
	operatingSystemName = @"macOS";
#elif defined(OF_WINDOWS)
	operatingSystemName = @"Windows";
#elif defined(OF_ANDROID)
	operatingSystemName = @"Android";
#elif defined(OF_AMIGAOS3)
	operatingSystemName = @"AmigaOS";
#elif defined(OF_MORPHOS)
	operatingSystemName = @"MorphOS";
#elif defined(OF_AMIGAOS4)
	operatingSystemName = @"AmigaOS 4";
#elif defined(OF_WII)
	operatingSystemName = @"Nintendo Wii";







|







109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
	operatingSystemName = @"iOS";
#elif defined(OF_MACOS)
	operatingSystemName = @"macOS";
#elif defined(OF_WINDOWS)
	operatingSystemName = @"Windows";
#elif defined(OF_ANDROID)
	operatingSystemName = @"Android";
#elif defined(OF_AMIGAOS_M68K)
	operatingSystemName = @"AmigaOS";
#elif defined(OF_MORPHOS)
	operatingSystemName = @"MorphOS";
#elif defined(OF_AMIGAOS4)
	operatingSystemName = @"AmigaOS 4";
#elif defined(OF_WII)
	operatingSystemName = @"Nintendo Wii";
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# endif
#elif defined(OF_ANDROID)
	/* TODO */
#elif defined(OF_MORPHOS)
	/* TODO */
#elif defined(OF_AMIGAOS4)
	/* TODO */
#elif defined(OF_AMIGAOS3)
	/* TODO */
#elif defined(OF_WII) || defined(NINTENDO_3DS) || defined(OF_NINTENDO_DS) || \
    defined(OF_PSP) || defined(OF_MSDOS)
	/* Intentionally nothing */
#elif defined(HAVE_SYS_UTSNAME_H) && defined(HAVE_UNAME)
	struct utsname utsname;








|







213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# endif
#elif defined(OF_ANDROID)
	/* TODO */
#elif defined(OF_MORPHOS)
	/* TODO */
#elif defined(OF_AMIGAOS4)
	/* TODO */
#elif defined(OF_AMIGAOS_M68K)
	/* TODO */
#elif defined(OF_WII) || defined(NINTENDO_3DS) || defined(OF_NINTENDO_DS) || \
    defined(OF_PSP) || defined(OF_MSDOS)
	/* Intentionally nothing */
#elif defined(HAVE_SYS_UTSNAME_H) && defined(HAVE_UNAME)
	struct utsname utsname;

Modified src/OFThread.m from [19b90357c1] to [9adc83c2c8].

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# include <sched.h>
#endif
#include "unistd_wrapper.h"

#include "platform.h"

#ifdef OF_AMIGAOS
# ifdef OF_AMIGAOS3
#  define INTUITION_CLASSES_H
# endif
# include <proto/dos.h>
#endif

#ifdef OF_WII
# define nanosleep ogc_nanosleep







|







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# include <sched.h>
#endif
#include "unistd_wrapper.h"

#include "platform.h"

#ifdef OF_AMIGAOS
# ifdef OF_AMIGAOS_M68K
#  define INTUITION_CLASSES_H
# endif
# include <proto/dos.h>
#endif

#ifdef OF_WII
# define nanosleep ogc_nanosleep

Modified src/OFURLHandler_file.m from [08b70171c7] to [cf54856e03].

63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifdef OF_WINDOWS
# include <windows.h>
# include <direct.h>
# include <ntdef.h>
#endif

#ifdef OF_AMIGAOS
# ifdef OF_AMIGAOS3
#  define INTUITION_CLASSES_H
# endif
# include <proto/dos.h>
# include <proto/locale.h>
#endif

#if defined(OF_WINDOWS)







|







63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifdef OF_WINDOWS
# include <windows.h>
# include <direct.h>
# include <ntdef.h>
#endif

#ifdef OF_AMIGAOS
# ifdef OF_AMIGAOS_M68K
#  define INTUITION_CLASSES_H
# endif
# include <proto/dos.h>
# include <proto/locale.h>
#endif

#if defined(OF_WINDOWS)

Modified src/platform.h from [b3d1b8e8ef] to [e9d4861f7a].

123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# else
#  define OF_MORPHOS_IXEMUL
# endif
#elif defined(__amigaos4__)
# define OF_AMIGAOS4
# define OF_AMIGAOS
#elif defined(__amigaos__)
# define OF_AMIGAOS3
# define OF_AMIGAOS
#elif defined(__sun__)
# define OF_SOLARIS
#elif defined(__QNX__)
# define OF_QNX
#elif defined(__wii__)
# define OF_WII







|







123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# else
#  define OF_MORPHOS_IXEMUL
# endif
#elif defined(__amigaos4__)
# define OF_AMIGAOS4
# define OF_AMIGAOS
#elif defined(__amigaos__)
# define OF_AMIGAOS_M68K
# define OF_AMIGAOS
#elif defined(__sun__)
# define OF_SOLARIS
#elif defined(__QNX__)
# define OF_QNX
#elif defined(__wii__)
# define OF_WII

Modified src/runtime/amiga-library.m from [9f14e5de8b] to [52c1c18633].

16
17
18
19
20
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
 */

#include "config.h"

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

#ifdef OF_AMIGAOS3
# define INTUITION_CLASSES_H
#endif

#include <exec/libraries.h>
#include <exec/nodes.h>
#include <exec/resident.h>
#include <proto/exec.h>

#define CONCAT_VERSION2(major, minor) #major "." #minor
#define CONCAT_VERSION(major, minor) CONCAT_VERSION2(major, minor)
#define VERSION_STRING CONCAT_VERSION(OBJFW_RT_LIB_MAJOR, OBJFW_RT_LIB_MINOR)

#if defined(OF_AMIGAOS3)
# define DATA_OFFSET 0x7FFE
#elif defined(OF_MORPHOS)
# define DATA_OFFSET 0x8000
#endif

#ifdef OF_AMIGAOS3
# define OBJC_M68K_REG(reg) __asm__ (#reg)
#else
# define OBJC_M68K_REG(reg)
#endif

/* This always needs to be the first thing in the file. */
int
_start()
{
	return -1;
}

struct ObjFWRTBase {
	struct Library library;
	void *seg_list;
	struct ObjFWRTBase *parent;
	char *data_seg;
	bool initialized;
};

#ifdef OF_AMIGAOS3
extern uintptr_t __CTOR_LIST__[];
extern const void *_EH_FRAME_BEGINS__;
extern void *_EH_FRAME_OBJECTS__;
#endif

extern void __objc_exec_class_m68k(void);
extern IMP _Nonnull objc_msg_lookup_m68k(void);







|












|





|
|



















|







16
17
18
19
20
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
 */

#include "config.h"

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

#ifdef OF_AMIGAOS_M68K
# define INTUITION_CLASSES_H
#endif

#include <exec/libraries.h>
#include <exec/nodes.h>
#include <exec/resident.h>
#include <proto/exec.h>

#define CONCAT_VERSION2(major, minor) #major "." #minor
#define CONCAT_VERSION(major, minor) CONCAT_VERSION2(major, minor)
#define VERSION_STRING CONCAT_VERSION(OBJFW_RT_LIB_MAJOR, OBJFW_RT_LIB_MINOR)

#if defined(OF_AMIGAOS_M68K)
# define DATA_OFFSET 0x7FFE
#elif defined(OF_MORPHOS)
# define DATA_OFFSET 0x8000
#endif

#ifdef OF_AMIGAOS_M68K
# define OBJC_M68K_REG(reg) __asm__(#reg)
#else
# define OBJC_M68K_REG(reg)
#endif

/* This always needs to be the first thing in the file. */
int
_start()
{
	return -1;
}

struct ObjFWRTBase {
	struct Library library;
	void *seg_list;
	struct ObjFWRTBase *parent;
	char *data_seg;
	bool initialized;
};

#ifdef OF_AMIGAOS_M68K
extern uintptr_t __CTOR_LIST__[];
extern const void *_EH_FRAME_BEGINS__;
extern void *_EH_FRAME_OBJECTS__;
#endif

extern void __objc_exec_class_m68k(void);
extern IMP _Nonnull objc_msg_lookup_m68k(void);
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
const ULONG __abox__ = 1;
#endif
struct ExecBase *SysBase;
struct objc_libc libc;
FILE *stdout;
FILE *stderr;

#if defined(OF_AMIGAOS3)
__asm__ (
    ".text\n"
    ".globl ___restore_a4\n"
    ".align 1\n"
    "___restore_a4:\n"
    "	movea.l	42(a6), a4\n"
    "	rts"







|







137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
const ULONG __abox__ = 1;
#endif
struct ExecBase *SysBase;
struct objc_libc libc;
FILE *stdout;
FILE *stderr;

#if defined(OF_AMIGAOS_M68K)
__asm__ (
    ".text\n"
    ".globl ___restore_a4\n"
    ".align 1\n"
    "___restore_a4:\n"
    "	movea.l	42(a6), a4\n"
    "	rts"
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#endif

static OF_INLINE char *
get_data_seg(void)
{
	char *data_seg;

#if defined(OF_AMIGAOS3)
	__asm__ (
	    "move.l	#___a4_init, %0"
	    : "=r"(data_seg)
	);
#elif defined(OF_MORPHOS)
	__asm__ (
	    "lis	%0, __r13_init@ha\n\t"
	    "la		%0, __r13_init@l(%0)"
	    : "=r"(data_seg)
	);
#endif

	return data_seg;
}

static OF_INLINE size_t
get_data_size(void)
{
	size_t data_size;

#if defined(OF_AMIGAOS3)
	__asm__ (
	    "move.l	#___data_size, %0"
	    : "=r"(data_size)
	);
#elif defined(OF_MORPHOS)
	__asm__ (
	    "lis	%0, __sdata_size@ha\n\t"







|




















|







165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#endif

static OF_INLINE char *
get_data_seg(void)
{
	char *data_seg;

#if defined(OF_AMIGAOS_M68K)
	__asm__ (
	    "move.l	#___a4_init, %0"
	    : "=r"(data_seg)
	);
#elif defined(OF_MORPHOS)
	__asm__ (
	    "lis	%0, __r13_init@ha\n\t"
	    "la		%0, __r13_init@l(%0)"
	    : "=r"(data_seg)
	);
#endif

	return data_seg;
}

static OF_INLINE size_t
get_data_size(void)
{
	size_t data_size;

#if defined(OF_AMIGAOS_M68K)
	__asm__ (
	    "move.l	#___data_size, %0"
	    : "=r"(data_size)
	);
#elif defined(OF_MORPHOS)
	__asm__ (
	    "lis	%0, __sdata_size@ha\n\t"
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
}

static OF_INLINE size_t *
get_datadata_relocs(void)
{
	size_t *datadata_relocs;

#if defined(OF_AMIGAOS3)
	__asm__ (
	    "move.l	#___datadata_relocs, %0"
	    : "=r"(datadata_relocs)
	);
#elif defined(OF_MORPHOS)
	__asm__ (
	    "lis	%0, __datadata_relocs@ha\n\t"
	    "la		%0, __datadata_relocs@l(%0)\n\t"
	    : "=r"(datadata_relocs)
	);
#endif

	return datadata_relocs;
}

static struct Library *
lib_init(struct ObjFWRTBase *base OBJC_M68K_REG(d0),
    void *seg_list OBJC_M68K_REG(a0),
    struct ExecBase *sys_base OBJC_M68K_REG(a6))
{
#if defined(OF_AMIGAOS3)
	__asm__ __volatile__ (
	    "move.l	a6, _SysBase"
	    :: "a"(sys_base)
	);
#elif defined(OF_MORPHOS)
	__asm__ __volatile__ (
	    "lis	%%r9, SysBase@ha\n\t"







|




















|







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
}

static OF_INLINE size_t *
get_datadata_relocs(void)
{
	size_t *datadata_relocs;

#if defined(OF_AMIGAOS_M68K)
	__asm__ (
	    "move.l	#___datadata_relocs, %0"
	    : "=r"(datadata_relocs)
	);
#elif defined(OF_MORPHOS)
	__asm__ (
	    "lis	%0, __datadata_relocs@ha\n\t"
	    "la		%0, __datadata_relocs@l(%0)\n\t"
	    : "=r"(datadata_relocs)
	);
#endif

	return datadata_relocs;
}

static struct Library *
lib_init(struct ObjFWRTBase *base OBJC_M68K_REG(d0),
    void *seg_list OBJC_M68K_REG(a0),
    struct ExecBase *sys_base OBJC_M68K_REG(a6))
{
#if defined(OF_AMIGAOS_M68K)
	__asm__ __volatile__ (
	    "move.l	a6, _SysBase"
	    :: "a"(sys_base)
	);
#elif defined(OF_MORPHOS)
	__asm__ __volatile__ (
	    "lis	%%r9, SysBase@ha\n\t"
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
lib_close(void)
{
	OBJC_M68K_ARG(struct ObjFWRTBase *, base, a6)

	if (base->parent != NULL) {
		struct ObjFWRTBase *parent;

#ifdef OF_AMIGAOS3
		if (base->initialized)
			for (size_t i = 1; i <= (size_t)_EH_FRAME_BEGINS__; i++)
				libc.__deregister_frame_info(
				    (&_EH_FRAME_BEGINS__)[i]);
#endif

		parent = base->parent;







|







347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
lib_close(void)
{
	OBJC_M68K_ARG(struct ObjFWRTBase *, base, a6)

	if (base->parent != NULL) {
		struct ObjFWRTBase *parent;

#ifdef OF_AMIGAOS_M68K
		if (base->initialized)
			for (size_t i = 1; i <= (size_t)_EH_FRAME_BEGINS__; i++)
				libc.__deregister_frame_info(
				    (&_EH_FRAME_BEGINS__)[i]);
#endif

		parent = base->parent;
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
	if (version > 1)
		return false;

	memcpy(&libc, libc_, sizeof(libc));
	stdout = stdout_;
	stderr = stderr_;

#ifdef OF_AMIGAOS3
	if ((size_t)_EH_FRAME_BEGINS__ != (size_t)_EH_FRAME_OBJECTS__)
		return false;

	for (size_t i = 1; i <= (size_t)_EH_FRAME_BEGINS__; i++)
		libc.__register_frame_info((&_EH_FRAME_BEGINS__)[i],
		    (&_EH_FRAME_OBJECTS__)[i]);








|







394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
	if (version > 1)
		return false;

	memcpy(&libc, libc_, sizeof(libc));
	stdout = stdout_;
	stderr = stderr_;

#ifdef OF_AMIGAOS_M68K
	if ((size_t)_EH_FRAME_BEGINS__ != (size_t)_EH_FRAME_OBJECTS__)
		return false;

	for (size_t i = 1; i <= (size_t)_EH_FRAME_BEGINS__; i++)
		libc.__register_frame_info((&_EH_FRAME_BEGINS__)[i],
		    (&_EH_FRAME_OBJECTS__)[i]);

603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
};

struct Resident resident = {
	.rt_MatchWord = RTC_MATCHWORD,
	.rt_MatchTag = &resident,
	.rt_EndSkip = &resident + 1,
	.rt_Flags = RTF_AUTOINIT
#ifndef OF_AMIGAOS3
	    | RTF_PPC
#endif
#ifdef OF_MORPHOS
	    | RTF_EXTENDED
#endif
	    ,
	.rt_Version = OBJFW_RT_LIB_MAJOR,
	.rt_Type = NT_LIBRARY,
	.rt_Pri = 0,
	.rt_Name = (char *)"objfw_rt.library",
	.rt_IdString = (char *)"ObjFW_RT " VERSION_STRING







<
<
<

|







603
604
605
606
607
608
609



610
611
612
613
614
615
616
617
618
};

struct Resident resident = {
	.rt_MatchWord = RTC_MATCHWORD,
	.rt_MatchTag = &resident,
	.rt_EndSkip = &resident + 1,
	.rt_Flags = RTF_AUTOINIT



#ifdef OF_MORPHOS
	    | RTF_PPC | RTF_EXTENDED
#endif
	    ,
	.rt_Version = OBJFW_RT_LIB_MAJOR,
	.rt_Type = NT_LIBRARY,
	.rt_Pri = 0,
	.rt_Name = (char *)"objfw_rt.library",
	.rt_IdString = (char *)"ObjFW_RT " VERSION_STRING

Modified src/runtime/linklib/linklib.m from [a24ad9446a] to [5386d2b724].

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

#include "config.h"

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

#ifdef OF_AMIGAOS3
# define INTUITION_CLASSES_H
#endif
#include <proto/exec.h>

#import "inline.h"

#include <stdio.h>







|







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

#include "config.h"

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

#ifdef OF_AMIGAOS_M68K
# define INTUITION_CLASSES_H
#endif
#include <proto/exec.h>

#import "inline.h"

#include <stdio.h>
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
{
	return objc_get_class_m68k(name);
}

void
objc_exception_throw(id object)
{
#ifdef OF_AMIGAOS3
	/*
	 * 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







|







178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
{
	return objc_get_class_m68k(name);
}

void
objc_exception_throw(id object)
{
#ifdef OF_AMIGAOS_M68K
	/*
	 * 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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
{
	objc_setPropertyStruct_m68k(dest, src, size, atomic, strong);
}

void
objc_enumerationMutation(id object)
{
#ifdef OF_AMIGAOS3
	/*
	 * 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 a result
	 * objc_enumerationMutation() might throw an exception that could never
	 * be caught. If, however, we're using a function pointer instead of







|







242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
{
	objc_setPropertyStruct_m68k(dest, src, size, atomic, strong);
}

void
objc_enumerationMutation(id object)
{
#ifdef OF_AMIGAOS_M68K
	/*
	 * 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 a result
	 * objc_enumerationMutation() might throw an exception that could never
	 * be caught. If, however, we're using a function pointer instead of

Modified tests/OFStringTests.m from [e81e35af26] to [9c3fe0a3f0].

879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
	TEST(@"-[floatValue]",
	    [C(@"\t-0.25 ") floatValue] == -0.25 &&
	    [C(@"\r\n\tINF\t\n") floatValue] == INFINITY &&
	    [C(@"\r -INFINITY\n") floatValue] == -INFINITY &&
	    isnan([C(@"   NAN\t\t") floatValue]))

#if !defined(OF_ANDROID) && !defined(OF_SOLARIS) && !defined(OF_DJGPP) && \
    !defined(OF_AMIGAOS3)
# define INPUT @"\t-0x1.FFFFFFFFFFFFFP-1020 "
# define EXPECTED -0x1.FFFFFFFFFFFFFP-1020
#else
/* Android, Solaris, DJGPP and AmigaOS3 do not accept 0x for strtod() */
# if (!defined(OF_SOLARIS) || !defined(OF_X86)) && !defined(OF_AMIGAOS3)
#  define INPUT @"\t-0.123456789 "
#  define EXPECTED -0.123456789
# else
/*
 * Solaris' strtod() has weird rounding on x86, but not on x86_64/
 * AmigaOS 3 with libnix has weird rounding as well.
 */







|




|







879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
	TEST(@"-[floatValue]",
	    [C(@"\t-0.25 ") floatValue] == -0.25 &&
	    [C(@"\r\n\tINF\t\n") floatValue] == INFINITY &&
	    [C(@"\r -INFINITY\n") floatValue] == -INFINITY &&
	    isnan([C(@"   NAN\t\t") floatValue]))

#if !defined(OF_ANDROID) && !defined(OF_SOLARIS) && !defined(OF_DJGPP) && \
    !defined(OF_AMIGAOS_M68K)
# define INPUT @"\t-0x1.FFFFFFFFFFFFFP-1020 "
# define EXPECTED -0x1.FFFFFFFFFFFFFP-1020
#else
/* Android, Solaris, DJGPP and AmigaOS3 do not accept 0x for strtod() */
# if (!defined(OF_SOLARIS) || !defined(OF_X86)) && !defined(OF_AMIGAOS_M68K)
#  define INPUT @"\t-0.123456789 "
#  define EXPECTED -0.123456789
# else
/*
 * Solaris' strtod() has weird rounding on x86, but not on x86_64/
 * AmigaOS 3 with libnix has weird rounding as well.
 */