* Write preliminary thread creation functions for Linux.
* Debug the Makefile
This commit is contained in:
jean.chalard
2009-05-23 04:44:44 +00:00
parent d7840821ad
commit 10aa8e32d9
4 changed files with 485 additions and 466 deletions
+2 -2
View File
@@ -7,7 +7,7 @@ GENERIC_OBJS = src/JApp.o src/JGBKFont.o \
src/JGE.o src/JGui.o src/JLBFont.o \ src/JGE.o src/JGui.o src/JLBFont.o \
src/JGameObject.o src/JSpline.o src/JAnimator.o \ src/JGameObject.o src/JSpline.o src/JAnimator.o \
src/JResourceManager.o src/JFileSystem.o \ src/JResourceManager.o src/JFileSystem.o \
src/JNetwork.o src/JSocket.o \ src/JNetwork.o \
src/JParticle.o src/JParticleEmitter.o src/JParticleEffect.o \ src/JParticle.o src/JParticleEmitter.o src/JParticleEffect.o \
src/JParticleSystem.o \ src/JParticleSystem.o \
src/unzip/ioapi.o src/unzip/mztools.o src/unzip/unzip.o \ src/unzip/ioapi.o src/unzip/mztools.o src/unzip/unzip.o \
@@ -16,7 +16,7 @@ GENERIC_OBJS = src/JApp.o src/JGBKFont.o \
src/tinyxml/tinyxmlparser.o src/tinyxml/tinyxmlerror.o \ src/tinyxml/tinyxmlparser.o src/tinyxml/tinyxmlerror.o \
src/Encoding.o src/JTTFont.o \ src/Encoding.o src/JTTFont.o \
src/JMD2Model.o src/JOBJModel.o src/vram.o src/JMD2Model.o src/JOBJModel.o src/vram.o
PSP_OBJS = src/JGfx.o src/JSfx.o src/JAudio.o src/JMP3.o src/decoder_prx.o src/main.o PSP_OBJS = src/JSocket.o src/JGfx.o src/JSfx.o src/JAudio.o src/JMP3.o src/decoder_prx.o src/main.o
LINUX_OBJS = src/linux/JGfx.o src/linux/JSfx.o src/Xmain.o LINUX_OBJS = src/linux/JGfx.o src/linux/JSfx.o src/Xmain.o
+7 -3
View File
@@ -23,8 +23,10 @@ public:
int send(char * buffer, int length); int send(char * buffer, int length);
int connect(string serverIP = ""); int connect(string serverIP = "");
static int isConnected(); static int isConnected();
#if defined (WIN32) || defined (LINUX) #if defined (WIN32)
static int net_thread(LPVOID param); static int net_thread(void* param);
#elif defined (LINUX)
static void* net_thread(void* param);
#else #else
static int net_thread(SceSize args, void *argp); static int net_thread(SceSize args, void *argp);
static int connect_to_apctl(int config); static int connect_to_apctl(int config);
@@ -32,8 +34,10 @@ public:
private: private:
#if defined (WIN32) || defined (LINUX) #if defined (WIN32)
static DWORD netthread; static DWORD netthread;
#elif defined (LINUX)
static pthread_t netthread;
#else #else
static int netthread; static int netthread;
#endif #endif
+25 -8
View File
@@ -78,8 +78,8 @@ int JNetwork::send(char * buffer, int length){
#ifdef WIN32 #if defined (WIN32)
int JNetwork::net_thread(LPVOID param) int JNetwork::net_thread(void* param)
{ {
do do
{ {
@@ -88,18 +88,14 @@ int JNetwork::net_thread(LPVOID param)
if (JNetwork::serverIP.size()){ if (JNetwork::serverIP.size()){
OutputDebugString(JNetwork::serverIP.c_str()); OutputDebugString(JNetwork::serverIP.c_str());
s->start_client(JNetwork::serverIP.c_str()); s->start_client(JNetwork::serverIP.c_str());
}else{ }else{
s->start_server(""); //IP address useless for server ? s->start_server(""); //IP address useless for server ?
} }
} }
while(0); while(0);
return 0; return 0;
} }
int JNetwork::connect(string serverIP){ int JNetwork::connect(string serverIP){
if(netthread) return 0; if(netthread) return 0;
@@ -110,11 +106,32 @@ int JNetwork::connect(string serverIP){
return netthread; return netthread;
} }
#elif defined (LINUX)
void* JNetwork::net_thread(void* param __attribute__((unused)))
{
do
{
JSocket::mInstance = new JSocket();
JSocket * s = JSocket::mInstance;
if (JNetwork::serverIP.size())
s->start_client(JNetwork::serverIP.c_str());
else
s->start_server(""); //IP address useless for server ?
}
while (0);
return NULL;
}
int JNetwork::connect(string serverIP)
{
if (netthread) return 0;
JNetwork::serverIP = serverIP;
return pthread_create(&netthread, NULL, net_thread, NULL);
}
#else #else
int net_thread(SceSize args, void *argp) int net_thread(SceSize args, void *argp)
{ {
do do
{ {
JSocket::mInstance = new JSocket(); JSocket::mInstance = new JSocket();
-2
View File
@@ -207,5 +207,3 @@ int JSocket::start_server(const char *szIpAddr)