5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 2001 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
22 #include "silcincludes.h"
24 /* SILC Mutex structure */
25 struct SilcMutexStruct {
27 pthread_mutex_t mutex;
30 #endif /* SILC_THREADS */
33 bool silc_mutex_alloc(SilcMutex *mutex)
36 *mutex = silc_calloc(1, sizeof(**mutex));
40 pthread_mutex_init(&(*mutex)->mutex, NULL);
41 #endif /* SILC_THREADS */
45 void silc_mutex_free(SilcMutex mutex)
48 pthread_mutex_destroy(&mutex->mutex);
50 #endif /* SILC_THREADS */
53 void silc_mutex_lock(SilcMutex mutex)
56 if (pthread_mutex_lock(&mutex->mutex))
58 #endif /* SILC_THREADS */
61 void silc_mutex_unlock(SilcMutex mutex)
64 if (pthread_mutex_unlock(&mutex->mutex))
66 #endif /* SILC_THREADS */