mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r5943) -Merge TGP (part r5725): -Codechange: renamed Thread to OTTDThread, as Windows
(who else) uses Thread in winbase.h, and starts complaining if you define it otherwise (with weird, undefined errors) (tnx Arnau and Rubidium)
This commit is contained in:
parent
7cfd3eb618
commit
ee0daa0a4f
|
@ -1392,7 +1392,7 @@ void SaveFileError(void)
|
||||||
SaveFileDone();
|
SaveFileDone();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Thread* save_thread;
|
static OTTDThread* save_thread;
|
||||||
|
|
||||||
/** We have written the whole game into memory, _save_pool, now find
|
/** We have written the whole game into memory, _save_pool, now find
|
||||||
* and appropiate compressor and start writing to file.
|
* and appropiate compressor and start writing to file.
|
||||||
|
|
36
thread.c
36
thread.c
|
@ -5,8 +5,8 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#if defined(__AMIGA__) || defined(__MORPHOS__)
|
#if defined(__AMIGA__) || defined(__MORPHOS__)
|
||||||
Thread* OTTDCreateThread(ThreadFunc function, void* arg) { return NULL; }
|
OTTDThread* OTTDCreateThread(OTTDThreadFunc function, void* arg) { return NULL; }
|
||||||
void* OTTDJoinThread(Thread* t) { return NULL; }
|
void* OTTDJoinThread(OTTDThread* t) { return NULL; }
|
||||||
|
|
||||||
|
|
||||||
#elif defined(__OS2__)
|
#elif defined(__OS2__)
|
||||||
|
@ -15,22 +15,22 @@ void* OTTDJoinThread(Thread* t) { return NULL; }
|
||||||
#include <os2.h>
|
#include <os2.h>
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
|
|
||||||
struct Thread {
|
struct OTTDThread {
|
||||||
TID thread;
|
TID thread;
|
||||||
ThreadFunc func;
|
OTTDThreadFunc func;
|
||||||
void* arg;
|
void* arg;
|
||||||
void* ret;
|
void* ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void Proxy(void* arg)
|
static void Proxy(void* arg)
|
||||||
{
|
{
|
||||||
Thread* t = arg;
|
OTTDThread* t = arg;
|
||||||
t->ret = t->func(t->arg);
|
t->ret = t->func(t->arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread* OTTDCreateThread(ThreadFunc function, void* arg)
|
OTTDThread* OTTDCreateThread(OTTDThreadFunc function, void* arg)
|
||||||
{
|
{
|
||||||
Thread* t = malloc(sizeof(*t));
|
OTTDThread* t = malloc(sizeof(*t));
|
||||||
|
|
||||||
if (t == NULL) return NULL;
|
if (t == NULL) return NULL;
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ Thread* OTTDCreateThread(ThreadFunc function, void* arg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void* OTTDJoinThread(Thread* t)
|
void* OTTDJoinThread(OTTDThread* t)
|
||||||
{
|
{
|
||||||
void* ret;
|
void* ret;
|
||||||
|
|
||||||
|
@ -62,13 +62,13 @@ void* OTTDJoinThread(Thread* t)
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
struct Thread {
|
struct OTTDThread {
|
||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
};
|
};
|
||||||
|
|
||||||
Thread* OTTDCreateThread(ThreadFunc function, void* arg)
|
OTTDThread* OTTDCreateThread(OTTDThreadFunc function, void* arg)
|
||||||
{
|
{
|
||||||
Thread* t = malloc(sizeof(*t));
|
OTTDThread* t = malloc(sizeof(*t));
|
||||||
|
|
||||||
if (t == NULL) return NULL;
|
if (t == NULL) return NULL;
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ Thread* OTTDCreateThread(ThreadFunc function, void* arg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void* OTTDJoinThread(Thread* t)
|
void* OTTDJoinThread(OTTDThread* t)
|
||||||
{
|
{
|
||||||
void* ret;
|
void* ret;
|
||||||
|
|
||||||
|
@ -96,23 +96,23 @@ void* OTTDJoinThread(Thread* t)
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
struct Thread {
|
struct OTTDThread {
|
||||||
HANDLE thread;
|
HANDLE thread;
|
||||||
ThreadFunc func;
|
OTTDThreadFunc func;
|
||||||
void* arg;
|
void* arg;
|
||||||
void* ret;
|
void* ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
static DWORD WINAPI Proxy(LPVOID arg)
|
static DWORD WINAPI Proxy(LPVOID arg)
|
||||||
{
|
{
|
||||||
Thread* t = arg;
|
OTTDThread* t = arg;
|
||||||
t->ret = t->func(t->arg);
|
t->ret = t->func(t->arg);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread* OTTDCreateThread(ThreadFunc function, void* arg)
|
OTTDThread* OTTDCreateThread(OTTDThreadFunc function, void* arg)
|
||||||
{
|
{
|
||||||
Thread* t = malloc(sizeof(*t));
|
OTTDThread* t = malloc(sizeof(*t));
|
||||||
DWORD dwThreadId;
|
DWORD dwThreadId;
|
||||||
|
|
||||||
if (t == NULL) return NULL;
|
if (t == NULL) return NULL;
|
||||||
|
@ -129,7 +129,7 @@ Thread* OTTDCreateThread(ThreadFunc function, void* arg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void* OTTDJoinThread(Thread* t)
|
void* OTTDJoinThread(OTTDThread* t)
|
||||||
{
|
{
|
||||||
void* ret;
|
void* ret;
|
||||||
|
|
||||||
|
|
8
thread.h
8
thread.h
|
@ -3,11 +3,11 @@
|
||||||
#ifndef THREAD_H
|
#ifndef THREAD_H
|
||||||
#define THREAD_H
|
#define THREAD_H
|
||||||
|
|
||||||
typedef struct Thread Thread;
|
typedef struct OTTDThread OTTDThread;
|
||||||
|
|
||||||
typedef void* (*ThreadFunc)(void*);
|
typedef void* (*OTTDThreadFunc)(void*);
|
||||||
|
|
||||||
Thread* OTTDCreateThread(ThreadFunc, void*);
|
OTTDThread* OTTDCreateThread(OTTDThreadFunc, void*);
|
||||||
void* OTTDJoinThread(Thread*);
|
void* OTTDJoinThread(OTTDThread*);
|
||||||
|
|
||||||
#endif /* THREAD_H */
|
#endif /* THREAD_H */
|
||||||
|
|
Loading…
Reference in New Issue