@@ -25,21 +25,20 @@ #endif #import "OFException.h" #import "OFArray.h" #import "OFLocale.h" +#ifdef OF_HAVE_THREADS +# import "OFPlainMutex.h" +#endif #import "OFString.h" #import "OFSystemInfo.h" #import "OFInitializationFailedException.h" #import "OFLockFailedException.h" #import "OFUnlockFailedException.h" -#ifdef OF_HAVE_THREADS -# import "mutex.h" -#endif - #if defined(OF_WINDOWS) && defined(OF_HAVE_SOCKETS) # include #endif #if defined(OF_ARM) && !defined(__ARM_DWARF_EH__) @@ -48,13 +47,13 @@ struct _Unwind_Context; typedef enum { _URC_OK = 0, _URC_END_OF_STACK = 5 -}_Unwind_Reason_Code; +} _Unwind_Reason_Code; -struct backtrace_ctx { +struct BacktraceCtx { void **backtrace; uint8_t i; }; #ifdef HAVE__UNWIND_BACKTRACE @@ -67,25 +66,25 @@ extern int _Unwind_VRS_Get(struct _Unwind_Context *, int, uint32_t, int, void *); #endif #if !defined(HAVE_STRERROR_R) && defined(OF_HAVE_THREADS) -static of_mutex_t mutex; +static OFPlainMutex mutex; OF_CONSTRUCTOR() { - OF_ENSURE(of_mutex_new(&mutex) == 0); + OFEnsure(OFPlainMutexNew(&mutex) == 0); } OF_DESTRUCTOR() { - of_mutex_free(&mutex); + OFPlainMutexFree(&mutex); } #endif OFString * -of_strerror(int errNo) +OFStrError(int errNo) { OFString *ret; #ifdef HAVE_STRERROR_R char buffer[256]; #endif @@ -189,21 +188,21 @@ ret = [OFString stringWithCString: buffer encoding: [OFLocale encoding]]; #else # ifdef OF_HAVE_THREADS - if (of_mutex_lock(&mutex) != 0) + if (OFPlainMutexLock(&mutex) != 0) @throw [OFLockFailedException exception]; @try { # endif ret = [OFString stringWithCString: strerror(errNo) encoding: [OFLocale encoding]]; # ifdef OF_HAVE_THREADS } @finally { - if (of_mutex_unlock(&mutex) != 0) + if (OFPlainMutexUnlock(&mutex) != 0) @throw [OFUnlockFailedException exception]; } # endif #endif @@ -210,11 +209,11 @@ return ret; } #ifdef OF_WINDOWS OFString * -of_windows_status_to_string(LSTATUS status) +OFWindowsStatusToString(LSTATUS status) { OFString *string = nil; void *buffer; if ([OFSystemInfo isWindowsNT]) { @@ -253,15 +252,15 @@ } #endif #ifdef HAVE__UNWIND_BACKTRACE static _Unwind_Reason_Code -backtrace_callback(struct _Unwind_Context *ctx, void *data) +backtraceCallback(struct _Unwind_Context *ctx, void *data) { - struct backtrace_ctx *bt = data; + struct BacktraceCtx *bt = data; - if (bt->i < OF_BACKTRACE_SIZE) { + if (bt->i < OFBacktraceSize) { # ifndef HAVE_ARM_EHABI_EXCEPTIONS bt->backtrace[bt->i++] = (void *)_Unwind_GetIP(ctx); # else uintptr_t ip; @@ -282,17 +281,17 @@ } #ifdef HAVE__UNWIND_BACKTRACE - (instancetype)init { - struct backtrace_ctx ctx; + struct BacktraceCtx ctx; self = [super init]; ctx.backtrace = _backtrace; ctx.i = 0; - _Unwind_Backtrace(backtrace_callback, &ctx); + _Unwind_Backtrace(backtraceCallback, &ctx); return self; } #endif @@ -307,12 +306,11 @@ #ifdef HAVE__UNWIND_BACKTRACE OFMutableArray OF_GENERIC(OFString *) *backtrace = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); - for (uint8_t i = 0; - i < OF_BACKTRACE_SIZE && _backtrace[i] != NULL; i++) { + for (uint8_t i = 0; i < OFBacktraceSize && _backtrace[i] != NULL; i++) { # ifdef HAVE_DLADDR Dl_info info; if (dladdr(_backtrace[i], &info)) { OFString *frame;