Differences From Artifact [9f14e5de8b]:
- File src/runtime/amiga-library.m — part of check-in [95e1ba8d63] at 2018-05-13 02:09:02 on branch trunk — runtime: Port Amiga library to MorphOS (user: js, size: 14137) [annotate] [blame] [check-ins using]
To Artifact [52c1c18633]:
- File
src/runtime/amiga-library.m
— part of check-in
[5831626f68]
at
2018-05-13 19:24:28
on branch trunk
— platform.h: Rename OF_AMIGAOS3 to OF_AMIGAOS_M68K
The reason for this is that, in theory, this also supports versions
older than 3. (user: js, size: 14148) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
16 17 18 19 20 21 22 | */ #include "config.h" #import "ObjFW_RT.h" #import "private.h" | | | | | | | 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 | const ULONG __abox__ = 1; #endif struct ExecBase *SysBase; struct objc_libc libc; FILE *stdout; FILE *stderr; | | | 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 | #endif static OF_INLINE char * get_data_seg(void) { char *data_seg; | | | | 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 | } static OF_INLINE size_t * get_datadata_relocs(void) { size_t *datadata_relocs; | | | | 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 | lib_close(void) { OBJC_M68K_ARG(struct ObjFWRTBase *, base, a6) if (base->parent != NULL) { struct ObjFWRTBase *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 | if (version > 1) return false; memcpy(&libc, libc_, sizeof(libc)); stdout = stdout_; stderr = stderr_; | | | 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 | }; struct Resident resident = { .rt_MatchWord = RTC_MATCHWORD, .rt_MatchTag = &resident, .rt_EndSkip = &resident + 1, .rt_Flags = RTF_AUTOINIT | < < < | | 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 |
︙ | ︙ |