summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/fiber_thread.cpp4
-rw-r--r--src/genworld.cpp3
-rw-r--r--src/saveload.cpp3
-rw-r--r--src/thread.h6
-rw-r--r--src/thread_morphos.cpp15
-rw-r--r--src/thread_pthread.cpp14
-rw-r--r--src/thread_win32.cpp14
7 files changed, 20 insertions, 39 deletions
diff --git a/src/fiber_thread.cpp b/src/fiber_thread.cpp
index 6d311290c..5155b5519 100644
--- a/src/fiber_thread.cpp
+++ b/src/fiber_thread.cpp
@@ -109,7 +109,7 @@ private:
/**
* 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 @@ private:
s_main->m_sem->Set();
throw;
}
-
- return NULL;
}
};
diff --git a/src/genworld.cpp b/src/genworld.cpp
index a870108c5..88e4633e6 100644
--- a/src/genworld.cpp
+++ b/src/genworld.cpp
@@ -85,7 +85,7 @@ bool IsGenerateWorldThreaded()
/**
* The internal, real, generate function.
*/
-static void * CDECL _GenerateWorld(void *arg)
+static void _GenerateWorld(void *arg)
{
try {
_generating_world = true;
@@ -170,7 +170,6 @@ static void * CDECL _GenerateWorld(void *arg)
_generating_world = false;
throw;
}
- return NULL;
}
/**
diff --git a/src/saveload.cpp b/src/saveload.cpp
index 5cec94cdf..b6c72d482 100644
--- a/src/saveload.cpp
+++ b/src/saveload.cpp
@@ -1607,10 +1607,9 @@ static SaveOrLoadResult SaveFileToDisk(bool threaded)
}
}
-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
index a1fd4d8d5..f6f29a711 100644
--- 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 @@ public:
/**
* Join this thread.
*/
- virtual void *Join() = 0;
+ virtual void Join() = 0;
/**
* Check if this thread is the current active thread.
@@ -64,7 +64,7 @@ public:
* 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
index 6cd9e1498..ef074da45 100644
--- a/src/thread_morphos.cpp
+++ b/src/thread_morphos.cpp
@@ -34,7 +34,6 @@ struct OTTDThreadStartupMessage {
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 @@ public:
/* 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 @@ public:
return true;
}
- /* virtual */ void *Join()
+ /* virtual */ void Join()
{
struct OTTDThreadStartupMessage *reply;
- void *ret;
/* You cannot join yourself */
assert(!IsCurrent());
@@ -173,13 +170,9 @@ public:
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 @@ private:
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 @@ public:
/* 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
index 07d5e39b2..27cecc5a9 100644
--- a/src/thread_pthread.cpp
+++ b/src/thread_pthread.cpp
@@ -95,18 +95,15 @@ public:
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 @@ private:
*/
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 @@ private:
sem_post(&m_sem_stop);
if (exit) delete this;
-
- pthread_exit(NULL);
}
};
diff --git a/src/thread_win32.cpp b/src/thread_win32.cpp
index 778bee9bf..6f12a6fbc 100644
--- a/src/thread_win32.cpp
+++ b/src/thread_win32.cpp
@@ -20,7 +20,6 @@ private:
OTTDThreadFunc m_proc;
void *m_param;
bool m_attached;
- void *ret;
public:
/**
@@ -91,14 +90,12 @@ public:
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 @@ private:
*/
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;
}
};