#include <windows.h>
+#ifdef DBUS_DISABLE_ASSERT
+#define THREAD_CHECK_TRUE(func_name, result_or_call) \
+ do { if (!(result_or_call)) { /* ignore */ } } while (0)
+#else
+#define THREAD_CHECK_TRUE(func_name, result_or_call) do { \
+ if (!(result_or_call)) { \
+ _dbus_warn_check_failed ("thread function %s failed (windows error code=%ld) in %s", \
+ func_name, GetLastError (), _DBUS_FUNCTION_NAME); \
+ } \
+} while (0)
+#endif /* !DBUS_DISABLE_ASSERT */
+
/* Protected by DllMain lock, effectively */
static dbus_bool_t global_init_done = FALSE;
static CRITICAL_SECTION init_lock;
{
HANDLE handle;
handle = CreateMutex (NULL, FALSE, NULL);
+ THREAD_CHECK_TRUE ("CreateMutex", handle);
return (DBusCMutex *) handle;
}
{
HANDLE handle;
handle = CreateMutex (NULL, FALSE, NULL);
+ THREAD_CHECK_TRUE ("CreateMutex", handle);
return (DBusRMutex *) handle;
}
void
_dbus_platform_cmutex_free (DBusCMutex *mutex)
{
- CloseHandle ((HANDLE *) mutex);
+ THREAD_CHECK_TRUE ("CloseHandle", CloseHandle ((HANDLE *) mutex));
}
void
_dbus_platform_rmutex_free (DBusRMutex *mutex)
{
- CloseHandle ((HANDLE *) mutex);
+ THREAD_CHECK_TRUE ("CloseHandle", CloseHandle ((HANDLE *) mutex));
}
void
_dbus_platform_cmutex_lock (DBusCMutex *mutex)
{
- WaitForSingleObject ((HANDLE *) mutex, INFINITE);
+ THREAD_CHECK_TRUE ("WaitForSingleObject", WaitForSingleObject ((HANDLE *) mutex, INFINITE) == WAIT_OBJECT_0);
}
void
_dbus_platform_rmutex_lock (DBusRMutex *mutex)
{
- WaitForSingleObject ((HANDLE *) mutex, INFINITE);
+ THREAD_CHECK_TRUE ("WaitForSingleObject", WaitForSingleObject ((HANDLE *) mutex, INFINITE) == WAIT_OBJECT_0);
}
void
_dbus_platform_cmutex_unlock (DBusCMutex *mutex)
{
- ReleaseMutex ((HANDLE *) mutex);
+ THREAD_CHECK_TRUE ("ReleaseMutex", ReleaseMutex ((HANDLE *) mutex));
}
void
_dbus_platform_rmutex_unlock (DBusRMutex *mutex)
{
- ReleaseMutex ((HANDLE *) mutex);
+ THREAD_CHECK_TRUE ("ReleaseMutex", ReleaseMutex ((HANDLE *) mutex));
}
DBusCondVar *