Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Premakify publicsdk and build additional shared library on Li…
- Loading branch information
Showing
11 changed files
with
630 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
/********************************************************* | ||
* | ||
* Multi Theft Auto: San Andreas - Deathmatch | ||
* | ||
* ml_base, External lua add-on module | ||
* | ||
* Copyright © 2003-2008 MTA. All Rights Reserved. | ||
* | ||
* Grand Theft Auto is © 2002-2003 Rockstar North | ||
* | ||
* THE FOLLOWING SOURCES ARE PART OF THE MULTI THEFT | ||
* AUTO SOFTWARE DEVELOPMENT KIT AND ARE RELEASED AS | ||
* OPEN SOURCE FILES. THESE FILES MAY BE USED AS LONG | ||
* AS THE DEVELOPER AGREES TO THE LICENSE THAT IS | ||
* PROVIDED WITH THIS PACKAGE. | ||
* | ||
*********************************************************/ | ||
|
||
#include "CThread.h" | ||
|
||
CThread::CThread ( void ) | ||
{ | ||
m_pThreadData = NULL; | ||
m_pArg = NULL; | ||
#ifdef WIN32 // Win32 threads | ||
m_hThread = NULL; | ||
#endif | ||
} | ||
|
||
|
||
CThread::~CThread ( void ) | ||
{ | ||
Stop (); | ||
} | ||
|
||
|
||
bool CThread::Start ( CThreadData *pData ) | ||
{ | ||
if ( pData == NULL ) // pData HAS to be valid | ||
return false; | ||
|
||
Stop (); | ||
Arg ( pData ); | ||
|
||
#ifdef WIN32 // Win32 threads | ||
m_hThread = CreateThread ( NULL, 0, &CThread::EntryPoint, this, 0, NULL ); | ||
return m_hThread != NULL; | ||
#else // POSIX threads | ||
if ( pthread_create ( &m_hThread, NULL, CThread::EntryPoint, this ) ) | ||
{ | ||
// something bad happened | ||
return false; | ||
} | ||
#endif | ||
return true; | ||
} | ||
|
||
|
||
void CThread::Stop ( void ) | ||
{ | ||
if ( m_hThread ) | ||
{ | ||
// TerminateThread ( m_hThread, 0 ); | ||
if ( m_pThreadData != NULL ) | ||
m_pThreadData->bAbortThread = true; | ||
} | ||
} | ||
|
||
|
||
bool CThread::TryLock ( ThreadMutex * Mutex ) | ||
{ | ||
#ifdef WIN32 | ||
if ( TryEnterCriticalSection ( Mutex ) != 0 ) | ||
return true; | ||
#else | ||
if ( pthread_mutex_trylock ( Mutex ) == 0 ) | ||
return true; | ||
#endif | ||
return false; | ||
} | ||
|
||
|
||
void CThread::Lock ( ThreadMutex * Mutex ) | ||
{ | ||
#ifdef WIN32 // Win32 threads | ||
EnterCriticalSection ( Mutex ); | ||
#else // POSIX threads | ||
pthread_mutex_lock ( Mutex ); | ||
#endif | ||
} | ||
|
||
|
||
void CThread::Unlock ( ThreadMutex * Mutex ) | ||
{ | ||
#ifdef WIN32 // Win32 threads | ||
LeaveCriticalSection ( Mutex ); | ||
#else // POSIX threads | ||
pthread_mutex_unlock ( Mutex ); | ||
#endif | ||
} | ||
|
||
|
||
int CThread::Run ( CThreadData* arg ) | ||
{ | ||
return Execute ( arg ); | ||
} | ||
|
||
|
||
#ifdef WIN32 // Win32 threads | ||
DWORD CThread::EntryPoint ( void* pThis ) | ||
{ | ||
CThread* pt = (CThread*)pThis; | ||
return pt->Run ( pt->Arg () ); | ||
} | ||
#else // POSIX threads | ||
void* CThread::EntryPoint ( void* pThis ) | ||
{ | ||
CThread* pt = (CThread*)pThis; | ||
pt->Run ( pt->Arg () ); | ||
return NULL; | ||
} | ||
#endif | ||
|
||
|
||
CThreadData* CThread::Arg ( void ) const | ||
{ | ||
return m_pThreadData; | ||
} | ||
|
||
|
||
void CThread::Arg ( CThreadData* pData ) | ||
{ | ||
m_pThreadData = pData; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/********************************************************* | ||
* | ||
* Multi Theft Auto: San Andreas - Deathmatch | ||
* | ||
* ml_base, External lua add-on module | ||
* | ||
* Copyright © 2003-2008 MTA. All Rights Reserved. | ||
* | ||
* Grand Theft Auto is © 2002-2003 Rockstar North | ||
* | ||
* THE FOLLOWING SOURCES ARE PART OF THE MULTI THEFT | ||
* AUTO SOFTWARE DEVELOPMENT KIT AND ARE RELEASED AS | ||
* OPEN SOURCE FILES. THESE FILES MAY BE USED AS LONG | ||
* AS THE DEVELOPER AGREES TO THE LICENSE THAT IS | ||
* PROVIDED WITH THIS PACKAGE. | ||
* | ||
*********************************************************/ | ||
|
||
/** And remember.. threads on Win32 and POSIX are not similar at all. **/ | ||
|
||
#ifndef __CTHREAD_H | ||
#define __CTHREAD_H | ||
|
||
#ifdef WIN32 // Win32 threads | ||
#define _WIN32_WINNT 0x400 | ||
#define WIN32_LEAN_AND_MEAN | ||
#include <windows.h> | ||
|
||
typedef HANDLE ThreadHandle; | ||
typedef CRITICAL_SECTION ThreadMutex; | ||
#else // POSIX threads | ||
#include <stdio.h> | ||
#include <pthread.h> | ||
|
||
typedef pthread_t ThreadHandle; | ||
typedef pthread_mutex_t ThreadMutex; | ||
#endif | ||
|
||
#include "CThreadData.h" | ||
|
||
// Base thread class | ||
class CThread | ||
{ | ||
public: | ||
CThread ( void ); | ||
virtual ~CThread ( void ); | ||
|
||
bool Start ( CThreadData *pData ); | ||
void Stop ( void ); | ||
|
||
static bool TryLock ( ThreadMutex * Mutex ); | ||
static void Lock ( ThreadMutex * Mutex ); | ||
static void Unlock ( ThreadMutex * Mutex ); | ||
|
||
protected: | ||
int Run ( CThreadData* arg ); | ||
|
||
virtual int Execute ( CThreadData* pData ) = 0; | ||
|
||
CThreadData* Arg ( void ) const; | ||
void Arg ( CThreadData* pData ); | ||
|
||
#ifdef WIN32 // Win32 threads | ||
static DWORD WINAPI EntryPoint ( void* ); | ||
#else // POSIX threads | ||
static void* EntryPoint ( void* ); | ||
#endif | ||
|
||
private: | ||
void* m_pArg; | ||
CThreadData* m_pThreadData; | ||
ThreadHandle m_hThread; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/********************************************************* | ||
* | ||
* Multi Theft Auto: San Andreas - Deathmatch | ||
* | ||
* ml_base, External lua add-on module | ||
* | ||
* Copyright © 2003-2008 MTA. All Rights Reserved. | ||
* | ||
* Grand Theft Auto is © 2002-2003 Rockstar North | ||
* | ||
* THE FOLLOWING SOURCES ARE PART OF THE MULTI THEFT | ||
* AUTO SOFTWARE DEVELOPMENT KIT AND ARE RELEASED AS | ||
* OPEN SOURCE FILES. THESE FILES MAY BE USED AS LONG | ||
* AS THE DEVELOPER AGREES TO THE LICENSE THAT IS | ||
* PROVIDED WITH THIS PACKAGE. | ||
* | ||
*********************************************************/ | ||
|
||
#include "CThreadData.h" | ||
|
||
CThreadData::CThreadData ( void ) | ||
{ | ||
bAbortThread = false; | ||
|
||
// Initialize the mutexes | ||
#ifdef WIN32 // Win32 threads | ||
InitializeCriticalSection ( &MutexPrimary ); | ||
InitializeCriticalSection ( &MutexLogical ); | ||
#else // POSIX threads | ||
pthread_mutex_init ( &MutexPrimary, NULL ); | ||
pthread_mutex_init ( &MutexLogical, NULL ); | ||
#endif | ||
} | ||
|
||
CThreadData::~CThreadData ( void ) | ||
{ | ||
#ifdef WIN32 | ||
DeleteCriticalSection ( &MutexPrimary ); | ||
DeleteCriticalSection ( &MutexLogical ); | ||
#else | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/********************************************************* | ||
* | ||
* Multi Theft Auto: San Andreas - Deathmatch | ||
* | ||
* ml_base, External lua add-on module | ||
* | ||
* Copyright © 2003-2008 MTA. All Rights Reserved. | ||
* | ||
* Grand Theft Auto is © 2002-2003 Rockstar North | ||
* | ||
* THE FOLLOWING SOURCES ARE PART OF THE MULTI THEFT | ||
* AUTO SOFTWARE DEVELOPMENT KIT AND ARE RELEASED AS | ||
* OPEN SOURCE FILES. THESE FILES MAY BE USED AS LONG | ||
* AS THE DEVELOPER AGREES TO THE LICENSE THAT IS | ||
* PROVIDED WITH THIS PACKAGE. | ||
* | ||
*********************************************************/ | ||
|
||
class CThreadData; | ||
|
||
#ifndef __CTHREADDATA_H | ||
#define __CTHREADDATA_H | ||
|
||
#include "CThread.h" | ||
|
||
class CThreadData | ||
{ | ||
public: | ||
CThreadData ( void ); | ||
~CThreadData ( void ); | ||
|
||
bool bAbortThread; | ||
ThreadMutex MutexPrimary; // primary mutex for suspend/resume operations | ||
ThreadMutex MutexLogical; // logical mutex for proper CThreadData sync | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
noinst_LTLIBRARIES = libml_base.la | ||
|
||
libml_base_la_SOURCES = \ | ||
CFunctions.cpp \ | ||
CThread.cpp \ | ||
CThreadData.cpp \ | ||
ml_base.cpp \ | ||
extra/CLuaArgument.cpp \ | ||
extra/CLuaArguments.cpp | ||
|
||
#TODO: | ||
# the windows project uses the internal LUA, why? | ||
|
||
libml_base_la_CXXFLAGS = \ | ||
-I$(top_srcdir)/vendor/lua/src/ \ | ||
-I$(top_builddir)/vendor/lua/src/ | ||
|
||
libml_base_la_LIBADD = \ | ||
$(top_builddir)/vendor/lua/src/liblua.la |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Microsoft Visual Studio Solution File, Format Version 10.00 | ||
# Visual Studio 2008 | ||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ml_base", "ml_base.vcproj", "{132A627F-058D-46F8-BCBB-63B6C8D2CC1A}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Win32 = Debug|Win32 | ||
Release|Win32 = Release|Win32 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{132A627F-058D-46F8-BCBB-63B6C8D2CC1A}.Debug|Win32.ActiveCfg = Debug|Win32 | ||
{132A627F-058D-46F8-BCBB-63B6C8D2CC1A}.Debug|Win32.Build.0 = Debug|Win32 | ||
{132A627F-058D-46F8-BCBB-63B6C8D2CC1A}.Release|Win32.ActiveCfg = Release|Win32 | ||
{132A627F-058D-46F8-BCBB-63B6C8D2CC1A}.Release|Win32.Build.0 = Release|Win32 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
Oops, something went wrong.