+#define _Noreturn
+
#if defined(__ANDROID__)
#include <android/log.h>
namespace sys;
+#undef _GNU_SOURCE
+#undef __USE_UNIX98
#define _GNU_SOURCE
+#define __USE_UNIX98
// Platform includes
#define uint _uint
#define set _set
import "instance"
// Moved this here from Thread.ec to make compiling ecereCOM in Debug easier
-public int GetCurrentThreadID()
+public int64 GetCurrentThreadID()
{
#if defined(__WIN32__)
- return (int)GetCurrentThreadId();
+ return (int64)GetCurrentThreadId();
#else
- return (int)pthread_self();
+ return (int64)pthread_self();
#endif
}
public class Mutex : struct
{
+#if !defined(__EMSCRIPTEN__)
+
// class_fixed
#if defined(__WIN32__)
#ifdef _DEBUG
#else
pthread_mutex_t mutex;
#endif
+#endif
#ifdef _DEBUG
- int owningThread;
+ int64 owningThread;
#endif
int lockCount;
Mutex()
{
+#if !defined(__EMSCRIPTEN__)
#if defined(__WIN32__)
#ifdef _DEBUG
mutex = CreateMutex(null, FALSE, null);
pthread_mutex_init(&mutex, &attr);
pthread_mutexattr_destroy(&attr);
#endif
+#endif
+
lockCount = 0;
#ifdef _DEBUG
owningThread = 0;
~Mutex()
{
+#if !defined(__EMSCRIPTEN__)
#if defined(__WIN32__)
#ifdef _DEBUG
CloseHandle(mutex);
#else
pthread_mutex_destroy(&mutex);
#endif
+#endif
}
public:
{
if(this)
{
+#if !defined(__EMSCRIPTEN__)
/*
if(this == globalSystem.fileMonitorMutex)
- printf("[%d] Waiting on Mutex %x\n", GetCurrentThreadID(), this);
+ printf("[%d] Waiting on Mutex %x\n", (int)GetCurrentThreadID(), this);
*/
#if defined(__WIN32__)
#ifdef _DEBUG
#endif
#endif
+#endif
+
#ifdef _DEBUG
owningThread = GetCurrentThreadID();
#endif
{
if(this)
{
+#if !defined(__EMSCRIPTEN__)
/*
if(this == globalSystem.fileMonitorMutex)
- printf("[%d] Releasing Mutex %x\n", GetCurrentThreadID(), this);
+ printf("[%d] Releasing Mutex %x\n", (int)GetCurrentThreadID(), this);
*/
#ifdef _DEBUG
if(lockCount && owningThread != GetCurrentThreadID())
pthread_mutex_unlock(&mutex);
#endif
#endif
+#endif
+
#ifdef _DEBUG
if(lockCount < 0)
PrintLn("WARNING: lockCount < 0");
#endif
}
}
+
+ property int lockCount { get { return lockCount; } }
};