2 * Copyright (C) 1995-2007, Index Data ApS
3 * See the file LICENSE for details.
5 * $Id: mutex.c,v 1.1 2007-04-17 20:26:18 adam Exp $
10 * \brief Implements MUTEX functions
22 #include <yaz/xmalloc.h>
25 #include <yaz/mutex.h>
41 CRITICAL_SECTION m_handle;
43 #elif YAZ_POSIX_THREADS
45 pthread_mutex_t m_handle;
57 YAZ_EXPORT void yaz_mutex_create(YAZ_MUTEX *p)
61 *p = (YAZ_MUTEX) malloc(sizeof(**p));
63 InitializeCriticalSection(&(*p)->m_handle);
64 #elif YAZ_POSIX_THREADS
65 pthread_mutex_init(&(*p)->m_handle, 0);
67 pth_mutex_init(&(*p)->m_handle);
72 YAZ_EXPORT void yaz_mutex_enter(YAZ_MUTEX p)
77 EnterCriticalSection(&p->m_handle);
78 #elif YAZ_POSIX_THREADS
79 pthread_mutex_lock(&p->m_handle);
84 YAZ_EXPORT void yaz_mutex_leave(YAZ_MUTEX p)
89 LeaveCriticalSection(&p->m_handle);
90 #elif YAZ_POSIX_THREADS
91 pthread_mutex_unlock(&p->m_handle);
96 YAZ_EXPORT void yaz_mutex_destroy(YAZ_MUTEX *p)
101 DeleteCriticalSection(&(*p)->m_handle);
111 * indent-tabs-mode: nil
113 * vim: shiftwidth=4 tabstop=8 expandtab