+// Mutex implementation macros
+#if defined(HAVE_PTHREAD_H)
+
+ #include <pthread.h>
+ pthread_mutex_t g_scheduledResourceLock;
+ #define MUTEX_LOCK(ARG_NAME) { pthread_mutex_lock(ARG_NAME); }
+ #define MUTEX_UNLOCK(ARG_NAME) { pthread_mutex_unlock(ARG_NAME); }
+ #define MUTEX_INITIALIZE(ARG_NAME) { }
+ #define MUTEX_TERMINATE(ARG_NAME) { }
+
+#elif defined(HAVE_WINDOWS_H)
+
+ #include <windows.h>
+ CRITICAL_SECTION g_scheduledResourceLock;
+ bool g_initializedScheduledResourceLock = false;
+ #define MUTEX_LOCK(ARG_NAME) { EnterCriticalSection(ARG_NAME); }
+ #define MUTEX_UNLOCK(ARG_NAME) { LeaveCriticalSection(ARG_NAME); }
+ #define MUTEX_INITIALIZE(ARG_NAME) { assert(!g_initializedScheduledResourceLock); \
+ InitializeCriticalSection(ARG_NAME); \
+ g_initializedScheduledResourceLock = true; \
+ }
+ #define MUTEX_TERMINATE(ARG_NAME) { if (g_initializedScheduledResourceLock) \
+ { \
+ DeleteCriticalSection(ARG_NAME); \
+ g_initializedScheduledResourceLock = false; \
+ } \
+ }
+
+#elif defined(WITH_ARDUINO)
+
+ #define MUTEX_LOCK(ARG_NAME) { }
+ #define MUTEX_UNLOCK(ARG_NAME) { }
+ #define MUTEX_INITIALIZE(ARG_NAME) { }
+ #define MUTEX_TERMINATE(ARG_NAME) { }
+
+#else
+
+ ERROR Need mutex implementation on this platform
+