Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -413,11 +413,13 @@ [self retain]; _running = OF_THREAD_RUNNING; - if (!of_thread_new(&_thread, callMain, self, &_attr)) { + if (!of_thread_new(&_thread, + [_name cStringWithEncoding: [OFLocale encoding]], callMain, self, + &_attr)) { [self release]; @throw [OFThreadStartFailedException exceptionWithThread: self errNo: errno]; } Index: src/thread.h ================================================================== --- src/thread.h +++ src/thread.h @@ -64,13 +64,13 @@ #ifdef __cplusplus extern "C" { #endif extern bool of_thread_attr_init(of_thread_attr_t *attr); -extern bool of_thread_new(of_thread_t *thread, void (*function)(id), id object, - const of_thread_attr_t *attr); +extern bool of_thread_new(of_thread_t *thread, const char *name, + void (*function)(id), id object, const of_thread_attr_t *attr); extern void of_thread_set_name(const char *name); extern bool of_thread_join(of_thread_t thread); extern bool of_thread_detach(of_thread_t thread); #ifdef __cplusplus } #endif Index: src/thread_amiga.m ================================================================== --- src/thread_amiga.m +++ src/thread_amiga.m @@ -70,12 +70,12 @@ return true; } bool -of_thread_new(of_thread_t *thread, void (*function)(id), id object, - const of_thread_attr_t *attr) +of_thread_new(of_thread_t *thread, const char *name, void (*function)(id), + id object, const of_thread_attr_t *attr) { OFMutableData *tags = nil; if ((*thread = calloc(1, sizeof(**thread))) == NULL) { errno = ENOMEM; @@ -104,10 +104,12 @@ ADD_TAG(NP_Child, TRUE) #endif #ifdef OF_MORPHOS ADD_TAG(NP_CodeType, CODETYPE_PPC); #endif + if (name != NULL) + ADD_TAG(NP_Name, (ULONG)name); ADD_TAG(NP_Input, ((struct Process *)FindTask(NULL))->pr_CIS) ADD_TAG(NP_Output, ((struct Process *)FindTask(NULL))->pr_COS) ADD_TAG(NP_Error, ((struct Process *)FindTask(NULL))->pr_CES) ADD_TAG(NP_CloseInput, FALSE) Index: src/thread_pthread.m ================================================================== --- src/thread_pthread.m +++ src/thread_pthread.m @@ -30,10 +30,11 @@ static int minPrio = 0, maxPrio = 0, normalPrio = 0; struct thread_ctx { void (*function)(id object); id object; + const char *name; }; /* * This is done here to make sure this is done as early as possible in the main * thread. @@ -70,10 +71,13 @@ static void * functionWrapper(void *data) { struct thread_ctx *ctx = data; + if (ctx->name != NULL) + of_thread_set_name(ctx->name); + pthread_cleanup_push(free, data); ctx->function(ctx->object); pthread_cleanup_pop(1); @@ -99,12 +103,12 @@ return true; } bool -of_thread_new(of_thread_t *thread, void (*function)(id), id object, - const of_thread_attr_t *attr) +of_thread_new(of_thread_t *thread, const char *name, void (*function)(id), + id object, const of_thread_attr_t *attr) { bool ret; pthread_attr_t pattr; if (pthread_attr_init(&pattr) != 0) @@ -150,10 +154,11 @@ return false; } ctx->function = function; ctx->object = object; + ctx->name = name; ret = (pthread_create(thread, &pattr, functionWrapper, ctx) == 0); } @finally { pthread_attr_destroy(&pattr); Index: src/thread_winapi.m ================================================================== --- src/thread_winapi.m +++ src/thread_winapi.m @@ -27,12 +27,12 @@ return true; } bool -of_thread_new(of_thread_t *thread, void (*function)(id), id object, - const of_thread_attr_t *attr) +of_thread_new(of_thread_t *thread, const char *name, void (*function)(id), + id object, const of_thread_attr_t *attr) { *thread = CreateThread(NULL, (attr != NULL ? attr->stackSize : 0), (LPTHREAD_START_ROUTINE)function, (void *)object, 0, NULL); if (thread == NULL) {