(svn r13411) -Codechange: remove the return value from the thread procs because it is never used.
authorrubidium
Sun, 08 Jun 2008 10:51:36 +0000
changeset 9476 902f9cf6373f
parent 9475 cf1925ffac71
child 9477 00be34b8e9fd
(svn r13411) -Codechange: remove the return value from the thread procs because it is never used.
src/fiber_thread.cpp
src/genworld.cpp
src/saveload.cpp
src/thread.h
src/thread_morphos.cpp
src/thread_pthread.cpp
src/thread_win32.cpp
--- a/src/fiber_thread.cpp	Sun Jun 08 09:14:30 2008 +0000
+++ b/src/fiber_thread.cpp	Sun Jun 08 10:51:36 2008 +0000
@@ -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;
 	}
 };
 
--- a/src/genworld.cpp	Sun Jun 08 09:14:30 2008 +0000
+++ b/src/genworld.cpp	Sun Jun 08 10:51:36 2008 +0000
@@ -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;
 }
 
 /**
--- a/src/saveload.cpp	Sun Jun 08 09:14:30 2008 +0000
+++ b/src/saveload.cpp	Sun Jun 08 10:51:36 2008 +0000
@@ -1607,10 +1607,9 @@
 	}
 }
 
-static void * CDECL SaveFileToDiskThread(void *arg)
+static void SaveFileToDiskThread(void *arg)
 {
 	SaveFileToDisk(true);
-	return NULL;
 }
 
 void WaitTillSaved()
--- a/src/thread.h	Sun Jun 08 09:14:30 2008 +0000
+++ b/src/thread.h	Sun Jun 08 10:51:36 2008 +0000
@@ -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.
--- a/src/thread_morphos.cpp	Sun Jun 08 09:14:30 2008 +0000
+++ b/src/thread_morphos.cpp	Sun Jun 08 10:51:36 2008 +0000
@@ -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);
 	}
 
--- a/src/thread_pthread.cpp	Sun Jun 08 09:14:30 2008 +0000
+++ b/src/thread_pthread.cpp	Sun Jun 08 10:51:36 2008 +0000
@@ -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);
 	}
 };
 
--- a/src/thread_win32.cpp	Sun Jun 08 09:14:30 2008 +0000
+++ b/src/thread_win32.cpp	Sun Jun 08 10:51:36 2008 +0000
@@ -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;
 	}
 };