Differences From Artifact [78eee437a1]:
- File src/runtime/amiga-library.m — part of check-in [0509d7a844] at 2019-01-03 19:13:03 on branch trunk — Update copyright (user: js, size: 14030) [annotate] [blame] [check-ins using]
To Artifact [9f8ec83747]:
- File
src/runtime/amiga-library.m
— part of check-in
[ef6d69931e]
at
2019-02-07 00:46:41
on branch trunk
— Make style consistent between ObjFW and ObjFW_RT
ObjFW_RT used to be a separate project that followed the BSD style, as
it was written in pure C, while ObjFW's style is based on the BSD style
with changes to make it a better fit for Objective-C. This commit
changes ObjFW_RT to use the same style as ObjFW. (user: js, size: 13963) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
46 47 48 49 50 51 52 | _start() { return -1; } struct ObjFWRTBase { struct Library library; | | | | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | _start() { return -1; } struct ObjFWRTBase { struct Library library; void *segList; struct ObjFWRTBase *parent; char *dataSeg; bool initialized; }; #ifdef OF_AMIGAOS_M68K extern uintptr_t __CTOR_LIST__[]; extern const void *_EH_FRAME_BEGINS__; extern void *_EH_FRAME_OBJECTS__; |
︙ | ︙ | |||
157 158 159 160 161 162 163 | " blr\n" ".type __restore_r13, @function\n" ".size __restore_r13, .-__restore_r13" ); #endif static OF_INLINE char * | | | | | | | | | | | | | | | | | < | | | | | | 157 158 159 160 161 162 163 164 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 201 202 203 204 205 206 207 208 209 210 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 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | " blr\n" ".type __restore_r13, @function\n" ".size __restore_r13, .-__restore_r13" ); #endif static OF_INLINE char * getDataSeg(void) { char *dataSeg; #if defined(OF_AMIGAOS_M68K) __asm__ ( "move.l #___a4_init, %0" : "=r"(dataSeg) ); #elif defined(OF_MORPHOS) __asm__ ( "lis %0, __r13_init@ha\n\t" "la %0, __r13_init@l(%0)" : "=r"(dataSeg) ); #endif return dataSeg; } static OF_INLINE size_t getDataSize(void) { size_t dataSize; #if defined(OF_AMIGAOS_M68K) __asm__ ( "move.l #___data_size, %0" : "=r"(dataSize) ); #elif defined(OF_MORPHOS) __asm__ ( "lis %0, __sdata_size@ha\n\t" "la %0, __sdata_size@l(%0)\n\t" "lis %%r9, __sbss_size@ha\n\t" "la %%r9, __sbss_size@l(%%r9)\n\t" "add %0, %0, %%r9" : "=r"(dataSize) :: "r9" ); #endif return dataSize; } static OF_INLINE size_t * getDataDataRelocs(void) { size_t *dataDataRelocs; #if defined(OF_AMIGAOS_M68K) __asm__ ( "move.l #___datadata_relocs, %0" : "=r"(dataDataRelocs) ); #elif defined(OF_MORPHOS) __asm__ ( "lis %0, __datadata_relocs@ha\n\t" "la %0, __datadata_relocs@l(%0)\n\t" : "=r"(dataDataRelocs) ); #endif return dataDataRelocs; } static struct Library * lib_init(struct ObjFWRTBase *base OBJC_M68K_REG(d0), void *segList OBJC_M68K_REG(a0), struct ExecBase *sysBase OBJC_M68K_REG(a6)) { #if defined(OF_AMIGAOS_M68K) __asm__ __volatile__ ( "move.l a6, _SysBase" :: "a"(sysBase) ); #elif defined(OF_MORPHOS) __asm__ __volatile__ ( "lis %%r9, SysBase@ha\n\t" "stw %0, SysBase@l(%%r9)" :: "r"(sysBase) : "r9" ); #endif base->segList = segList; base->parent = NULL; base->dataSeg = getDataSeg(); return &base->library; } struct Library *__saveds lib_open(void) { OBJC_M68K_ARG(struct ObjFWRTBase *, base, a6) struct ObjFWRTBase *child; size_t dataSize, *dataDataRelocs; ptrdiff_t displacement; if (base->parent != NULL) return NULL; base->library.lib_OpenCnt++; base->library.lib_Flags &= ~LIBF_DELEXP; |
︙ | ︙ | |||
281 282 283 284 285 286 287 | base->library.lib_NegSize + base->library.lib_PosSize); child = (struct ObjFWRTBase *) ((char *)child + base->library.lib_NegSize); child->library.lib_OpenCnt = 1; child->parent = base; | | | | | | | | | | | | | 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | base->library.lib_NegSize + base->library.lib_PosSize); child = (struct ObjFWRTBase *) ((char *)child + base->library.lib_NegSize); child->library.lib_OpenCnt = 1; child->parent = base; dataSize = getDataSize(); if ((child->dataSeg = AllocMem(dataSize, MEMF_ANY)) == NULL) { FreeMem((char *)child - child->library.lib_NegSize, child->library.lib_NegSize + child->library.lib_PosSize); base->library.lib_OpenCnt--; return NULL; } memcpy(child->dataSeg, base->dataSeg - DATA_OFFSET, dataSize); dataDataRelocs = getDataDataRelocs(); displacement = child->dataSeg - (base->dataSeg - DATA_OFFSET); for (size_t i = 1; i <= dataDataRelocs[0]; i++) *(long *)(child->dataSeg + dataDataRelocs[i]) += displacement; child->dataSeg += DATA_OFFSET; return &child->library; } static void * expunge(struct ObjFWRTBase *base) { void *segList; if (base->parent != NULL) { base->parent->library.lib_Flags |= LIBF_DELEXP; return 0; } if (base->library.lib_OpenCnt > 0) { base->library.lib_Flags |= LIBF_DELEXP; return 0; } segList = base->segList; Remove(&base->library.lib_Node); FreeMem((char *)base - base->library.lib_NegSize, base->library.lib_NegSize + base->library.lib_PosSize); return segList; } static void *__saveds lib_expunge(void) { OBJC_M68K_ARG(struct ObjFWRTBase *, base, a6) |
︙ | ︙ | |||
352 353 354 355 356 357 358 | for (size_t i = 1; i <= (size_t)_EH_FRAME_BEGINS__; i++) libc.__deregister_frame_info( (&_EH_FRAME_BEGINS__)[i]); #endif parent = base->parent; | | | 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | for (size_t i = 1; i <= (size_t)_EH_FRAME_BEGINS__; i++) libc.__deregister_frame_info( (&_EH_FRAME_BEGINS__)[i]); #endif parent = base->parent; FreeMem(base->dataSeg - DATA_OFFSET, getDataSize()); FreeMem((char *)base - base->library.lib_NegSize, base->library.lib_NegSize + base->library.lib_PosSize); base = parent; } if (--base->library.lib_OpenCnt == 0 && |
︙ | ︙ | |||
554 555 556 557 558 559 560 | { libc._Unwind_Resume(ex); } #endif #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpedantic" | | | | | | | | | | 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 | { libc._Unwind_Resume(ex); } #endif #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpedantic" static CONST_APTR functionTable[] = { #ifdef OF_MORPHOS (CONST_APTR)FUNCARRAY_BEGIN, (CONST_APTR)FUNCARRAY_32BIT_NATIVE, #endif (CONST_APTR)lib_open, (CONST_APTR)lib_close, (CONST_APTR)lib_expunge, (CONST_APTR)lib_null, #include "amiga-library-functable.inc" (CONST_APTR)-1, #ifdef OF_MORPHOS (CONST_APTR)FUNCARRAY_END #endif }; #pragma GCC diagnostic pop static struct { ULONG dataSize; CONST_APTR *functionTable; ULONG *dataTable; struct Library *(*initFunc)( struct ObjFWRTBase *base OBJC_M68K_REG(d0), void *segList OBJC_M68K_REG(a0), struct ExecBase *execBase OBJC_M68K_REG(a6)); } init_table = { sizeof(struct ObjFWRTBase), functionTable, NULL, lib_init }; struct Resident resident = { .rt_MatchWord = RTC_MATCHWORD, .rt_MatchTag = &resident, |
︙ | ︙ |