This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- SilcMutex mutex = silc_calloc(1, sizeof(*mutex));
- mutex->mutex = CreateMutex(NULL, FALSE, NULL);
- if (!mutex->mutex) {
- silc_free(mutex);
- return NULL;
- }
- return mutex;
+#ifdef SILC_THREADS
+ *mutex = silc_calloc(1, sizeof(**mutex));
+ if (!(*mutex))
+ return FALSE;
+ InitializeCriticalSection(&((*mutex)->mutex));
+ return TRUE;
+#else
+ return FALSE;
+#endif /* SILC_THREADS */
- WaitForSingleObject(mutex->mutex, INFINITE);
+#ifdef SILC_THREADS
+ if (mutex) {
+ EnterCriticalSection(&mutex->mutex);
+ assert(mutex->locked == FALSE);
+ mutex->locked = TRUE;
+ }
+#endif /* SILC_THREADS */