@@ -50,10 +50,11 @@ #ifdef OF_AMIGAOS_M68K void __init_eh(void) { + /* Taken care of by objc_init() */ } #endif struct ObjFWRTBase { struct Library library; @@ -71,11 +72,11 @@ #ifdef OF_MORPHOS const ULONG __abox__ = 1; #endif struct ExecBase *SysBase; -struct objc_libc libc; +struct objc_libC libC; #if defined(OF_AMIGAOS_M68K) __asm__ ( ".text\n" ".globl ___restore_a4\n" @@ -163,11 +164,11 @@ return dataDataRelocs; } static struct Library * -lib_init(struct ObjFWRTBase *base OBJC_M68K_REG(d0), +libInit(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" @@ -187,11 +188,11 @@ return &base->library; } struct Library *__saveds -lib_open(void) +libOpen(void) { OBJC_M68K_ARG(struct ObjFWRTBase *, base, a6) struct ObjFWRTBase *child; size_t dataSize, *dataDataRelocs; @@ -202,11 +203,11 @@ base->library.lib_OpenCnt++; base->library.lib_Flags &= ~LIBF_DELEXP; /* - * We cannot use malloc here, as that depends on the libc passed from + * We cannot use malloc here, as that depends on the libC passed from * the application. */ if ((child = AllocMem(base->library.lib_NegSize + base->library.lib_PosSize, MEMF_ANY)) == NULL) { base->library.lib_OpenCnt--; @@ -268,19 +269,19 @@ return segList; #undef SysBase } static void *__saveds -lib_expunge(void) +libExpunge(void) { OBJC_M68K_ARG(struct ObjFWRTBase *, base, a6) return expunge(base, SysBase); } static void *__saveds -lib_close(void) +libClose(void) { /* * SysBase becomes invalid during this function, so we store it in * sysBase and add a define to make the inlines use the right one. */ @@ -294,11 +295,11 @@ #ifdef OF_AMIGAOS_M68K if (base->initialized) for (void *const *frame = _EH_FRAME_BEGINS__; *frame != NULL;) - libc.__deregister_frame_info(*frame++); + libC.__deregister_frame_info(*frame++); #endif parent = base->parent; FreeMem(base->dataSeg - DATA_OFFSET, getDataSize()); @@ -315,17 +316,17 @@ return NULL; #undef SysBase } static void * -lib_null(void) +libNull(void) { return NULL; } bool -objc_init(unsigned int version, struct objc_libc *libc_) +objc_init(unsigned int version, struct objc_libC *libC_) { #ifdef OF_AMIGAOS_M68K OBJC_M68K_ARG(struct ObjFWRTBase *, base, a6) #else register struct ObjFWRTBase *r12 __asm__("r12"); @@ -340,16 +341,16 @@ return false; if (base->initialized) return true; - memcpy(&libc, libc_, sizeof(libc)); + memcpy(&libC, libC_, sizeof(libC)); #ifdef OF_AMIGAOS_M68K - for (void *const *frame = _EH_FRAME_OBJECTS__, + for (void *const *frame = _EH_FRAME_BEGINS__, **object = _EH_FRAME_OBJECTS__; *frame != NULL;) - libc.__register_frame_info(*frame++, *object++); + libC.__register_frame_info(*frame++, *object++); iter0 = &__CTOR_LIST__[1]; #elif defined(OF_MORPHOS) __asm__ ( "lis %0, __EH_FRAME_BEGIN__@ha\n\t" @@ -357,11 +358,11 @@ "lis %1, __CTOR_LIST__@ha\n\t" "la %1, __CTOR_LIST__@l(%1)\n\t" : "=r"(frame), "=r"(iter0) ); - libc.__register_frame(frame); + libC.__register_frame(frame); #endif for (iter = iter0; *iter != 0; iter++); while (iter > iter0) { @@ -375,110 +376,136 @@ } void * malloc(size_t size) { - return libc.malloc(size); + return libC.malloc(size); } void * calloc(size_t count, size_t size) { - return libc.calloc(count, size); + return libC.calloc(count, size); } void * realloc(void *ptr, size_t size) { - return libc.realloc(ptr, size); + return libC.realloc(ptr, size); } void free(void *ptr) { - libc.free(ptr); + libC.free(ptr); } #ifdef HAVE_SJLJ_EXCEPTIONS int _Unwind_SjLj_RaiseException(void *ex) { - return libc._Unwind_SjLj_RaiseException(ex); + return libC._Unwind_SjLj_RaiseException(ex); } #else int _Unwind_RaiseException(void *ex) { - return libc._Unwind_RaiseException(ex); + return libC._Unwind_RaiseException(ex); } #endif void _Unwind_DeleteException(void *ex) { - libc._Unwind_DeleteException(ex); + libC._Unwind_DeleteException(ex); } void * _Unwind_GetLanguageSpecificData(void *ctx) { - return libc._Unwind_GetLanguageSpecificData(ctx); + return libC._Unwind_GetLanguageSpecificData(ctx); } uintptr_t _Unwind_GetRegionStart(void *ctx) { - return libc._Unwind_GetRegionStart(ctx); + return libC._Unwind_GetRegionStart(ctx); } uintptr_t _Unwind_GetDataRelBase(void *ctx) { - return libc._Unwind_GetDataRelBase(ctx); + return libC._Unwind_GetDataRelBase(ctx); } uintptr_t _Unwind_GetTextRelBase(void *ctx) { - return libc._Unwind_GetTextRelBase(ctx); + return libC._Unwind_GetTextRelBase(ctx); } uintptr_t _Unwind_GetIP(void *ctx) { - return libc._Unwind_GetIP(ctx); + return libC._Unwind_GetIP(ctx); } uintptr_t _Unwind_GetGR(void *ctx, int gr) { - return libc._Unwind_GetGR(ctx, gr); + return libC._Unwind_GetGR(ctx, gr); } void _Unwind_SetIP(void *ctx, uintptr_t ip) { - libc._Unwind_SetIP(ctx, ip); + libC._Unwind_SetIP(ctx, ip); } void _Unwind_SetGR(void *ctx, int gr, uintptr_t value) { - libc._Unwind_SetGR(ctx, gr, value); + libC._Unwind_SetGR(ctx, gr, value); } #ifdef HAVE_SJLJ_EXCEPTIONS void _Unwind_SjLj_Resume(void *ex) { - libc._Unwind_SjLj_Resume(ex); + libC._Unwind_SjLj_Resume(ex); } #else void _Unwind_Resume(void *ex) { - libc._Unwind_Resume(ex); + libC._Unwind_Resume(ex); +} +#endif + +#ifdef OF_AMIGAOS_M68K +void +__register_frame_info(const void *begin, void *object) +{ + libC.__register_frame_info(begin, object); +} + +void +*__deregister_frame_info(const void *begin) +{ + return libC.__deregister_frame_info(begin); +} +#endif + +#ifdef OF_MORPHOS +void __register_frame(void *frame) +{ + libC.__register_frame(frame); +} + +void __deregister_frame(void *frame) +{ + libC.__deregister_frame(frame); } #endif #ifdef OF_AMIGAOS_M68K int @@ -496,24 +523,24 @@ int vsnprintf(char *restrict str, size_t size, const char *restrict fmt, va_list args) { - return libc.vsnprintf(str, size, fmt, args); + return libC.vsnprintf(str, size, fmt, args); } #endif int atexit(void (*function)(void)) { - return libc.atexit(function); + return libC.atexit(function); } void exit(int status) { - libc.exit(status); + libC.exit(status); OF_UNREACHABLE } #pragma GCC diagnostic push @@ -521,14 +548,14 @@ 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, + (CONST_APTR)libOpen, + (CONST_APTR)libClose, + (CONST_APTR)libExpunge, + (CONST_APTR)libNull, #ifdef OF_MORPHOS (CONST_APTR)-1, (CONST_APTR)FUNCARRAY_32BIT_SYSTEMV, #endif #include "amiga-funcarray.inc" @@ -549,11 +576,11 @@ struct ExecBase *execBase OBJC_M68K_REG(a6)); } init_table = { sizeof(struct ObjFWRTBase), functionTable, NULL, - lib_init + libInit }; struct Resident resident = { .rt_MatchWord = RTC_MATCHWORD, .rt_MatchTag = &resident,