5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 2002 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; version 2 of the License.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
19 /* I used Apache's APR code as a reference here. */
26 /* SILC Mutex structure */
27 struct SilcMutexStruct {
31 SilcBool silc_mutex_alloc(SilcMutex *mutex)
35 *mutex = silc_calloc(1, sizeof(**mutex));
39 ret = create_sem(0, "SILC_MUTEX");
40 if (ret < B_NO_ERROR) {
50 void silc_mutex_free(SilcMutex mutex)
52 delete_sem(mutex->sema);
56 void silc_mutex_lock(SilcMutex mutex)
58 if (acquire_sem(mutex->sema) < B_NO_ERROR)
62 void silc_mutex_unlock(SilcMutex mutex)
64 if (release_sem(mutex->sema) < B_NO_ERROR)
68 #endif /* SILC_THREADS */