# HG changeset patch # User rubidium # Date 1212922296 0 # Node ID bba7a506af6dbaf0374d2c556e567c0806c22fdb # Parent c93ddf309a10596cf3f19a42febb8e7cafb8651f (svn r13411) -Codechange: remove the return value from the thread procs because it is never used. diff --git a/src/fiber_thread.cpp b/src/fiber_thread.cpp --- a/src/fiber_thread.cpp +++ b/src/fiber_thread.cpp @@ -109,7 +109,7 @@ /** * First function which is called within the fiber. */ - static void * CDECL stFiberProc(void *fiber) + static void stFiberProc(void *fiber) { Fiber_Thread *cur = (Fiber_Thread *)fiber; /* Now suspend the thread until we get SwitchToFiber() for the first time */ @@ -124,8 +124,6 @@ s_main->m_sem->Set(); throw; } - - return NULL; } }; diff --git a/src/genworld.cpp b/src/genworld.cpp --- a/src/genworld.cpp +++ b/src/genworld.cpp @@ -85,7 +85,7 @@ /** * The internal, real, generate function. */ -static void * CDECL _GenerateWorld(void *arg) +static void _GenerateWorld(void *arg) { try { _generating_world = true; @@ -170,7 +170,6 @@ _generating_world = false; throw; } - return NULL; } /** diff --git a/src/saveload.cpp b/src/saveload.cpp --- a/src/saveload.cpp +++ b/src/saveload.cpp @@ -1607,10 +1607,9 @@ } } -static void * CDECL SaveFileToDiskThread(void *arg) +static void SaveFileToDiskThread(void *arg) { SaveFileToDisk(true); - return NULL; } void WaitTillSaved() diff --git a/src/thread.h b/src/thread.h --- a/src/thread.h +++ b/src/thread.h @@ -5,7 +5,7 @@ #ifndef THREAD_H #define THREAD_H -typedef void * (CDECL *OTTDThreadFunc)(void *); +typedef void (*OTTDThreadFunc)(void *); /** * A Thread Object which works on all our supported OSes. @@ -37,7 +37,7 @@ /** * Join this thread. */ - virtual void *Join() = 0; + virtual void Join() = 0; /** * Check if this thread is the current active thread. @@ -64,7 +64,7 @@ * Convert the current thread to a new ThreadObject. * @return A new ThreadObject with the current thread attached to it. */ - static ThreadObject* AttachCurrent(); + static ThreadObject *AttachCurrent(); /** * Find the Id of the current running thread. diff --git a/src/thread_morphos.cpp b/src/thread_morphos.cpp --- a/src/thread_morphos.cpp +++ b/src/thread_morphos.cpp @@ -34,7 +34,6 @@ struct Message msg; ///< standard exec.library message (MUST be the first thing in the message struct!) OTTDThreadFunc func; ///< function the thread will execute void *arg; ///< functions arguments for the thread function - void *ret; ///< return value of the thread function }; @@ -79,7 +78,6 @@ /* Things we'll pass down to the child by utilizing NP_StartupMsg */ m_msg.func = proc; m_msg.arg = param; - m_msg.ret = NULL; m_replyport = CreateMsgPort(); @@ -161,10 +159,9 @@ return true; } - /* virtual */ void *Join() + /* virtual */ void Join() { struct OTTDThreadStartupMessage *reply; - void *ret; /* You cannot join yourself */ assert(!IsCurrent()); @@ -173,13 +170,9 @@ KPutStr("[OpenTTD] Wait for child to quit...\n"); WaitPort(m_replyport); - reply = (struct OTTDThreadStartupMessage *)GetMsg(m_replyport); - ret = reply->ret; - + GetMsg(m_replyport); DeleteMsgPort(m_replyport); m_thr = 0; - - return ret; } /* virtual */ bool IsCurrent() @@ -209,7 +202,7 @@ if (NewGetTaskAttrs(NULL, &msg, sizeof(struct OTTDThreadStartupMessage *), TASKINFOTYPE_STARTUPMSG, TAG_DONE) && msg != NULL) { try { - msg->ret = msg->func(msg->arg); + msg->func(msg->arg); } catch(...) { KPutStr("[Child] Returned to main()\n"); } @@ -256,7 +249,7 @@ /* virtual */ void Set() { - // Check if semaphore count is really important there. + /* Check if semaphore count is really important there. */ ReleaseSemaphore(&m_sem); } diff --git a/src/thread_pthread.cpp b/src/thread_pthread.cpp --- a/src/thread_pthread.cpp +++ b/src/thread_pthread.cpp @@ -95,18 +95,15 @@ throw 0; } - /* virtual */ void *Join() + /* virtual */ void Join() { /* You cannot join yourself */ assert(!IsCurrent()); - void *ret; - pthread_join(m_thr, &ret); + pthread_join(m_thr, NULL); m_thr = 0; delete this; - - return ret; } /* virtual */ bool IsCurrent() @@ -126,14 +123,15 @@ */ static void *stThreadProc(void *thr) { - return ((ThreadObject_pthread *)thr)->ThreadProc(); + ((ThreadObject_pthread *)thr)->ThreadProc(); + pthread_exit(NULL); } /** * A new thread is created, and this function is called. Call the custom * function of the creator of the thread. */ - void *ThreadProc() + void ThreadProc() { /* The new thread stops here so the calling thread can complete pthread_create() call */ sem_wait(&m_sem_start); @@ -152,8 +150,6 @@ sem_post(&m_sem_stop); if (exit) delete this; - - pthread_exit(NULL); } }; diff --git a/src/thread_win32.cpp b/src/thread_win32.cpp --- a/src/thread_win32.cpp +++ b/src/thread_win32.cpp @@ -20,7 +20,6 @@ OTTDThreadFunc m_proc; void *m_param; bool m_attached; - void *ret; public: /** @@ -91,14 +90,12 @@ throw 0; } - /* virtual */ void *Join() + /* virtual */ void Join() { /* You cannot join yourself */ assert(!IsCurrent()); WaitForSingleObject(m_h_thr, INFINITE); - - return this->ret; } /* virtual */ bool IsCurrent() @@ -119,21 +116,20 @@ */ static uint CALLBACK stThreadProc(void *thr) { - return ((ThreadObject_Win32 *)thr)->ThreadProc(); + ((ThreadObject_Win32 *)thr)->ThreadProc(); + return 0; } /** * A new thread is created, and this function is called. Call the custom * function of the creator of the thread. */ - uint ThreadProc() + void ThreadProc() { try { - this->ret = m_proc(m_param); + m_proc(m_param); } catch (...) { } - - return 0; } };