-#ifdef WIN32
-static CRITICAL_SECTION critical_section;
-#define NMEM_ENTER EnterCriticalSection(&critical_section)
-#define NMEM_LEAVE LeaveCriticalSection(&critical_section)
-struct nmem_mutex {
- CRITICAL_SECTION m_handle;
-};
-#elif YAZ_POSIX_THREADS
-static pthread_mutex_t nmem_mutex = PTHREAD_MUTEX_INITIALIZER;
-#define NMEM_ENTER pthread_mutex_lock(&nmem_mutex);
-#define NMEM_LEAVE pthread_mutex_unlock(&nmem_mutex);
-struct nmem_mutex {
- pthread_mutex_t m_handle;
-};
-#elif YAZ_GNU_THREADS
-static pth_mutex_t nmem_mutex = PTH_MUTEX_INIT;
-#define NMEM_ENTER pth_mutex_acquire(&nmem_mutex, 0, 0)
-#define NMEM_LEAVE pth_mutex_release(&nmem_mutex)
-struct nmem_mutex {
- pth_mutex_t m_handle;
-};
-#else
-#define NMEM_ENTER
-#define NMEM_LEAVE
-struct nmem_mutex {
- int dummy;
-};
-#endif
-
-YAZ_EXPORT void nmem_mutex_create(NMEM_MUTEX *p)
-{
- NMEM_ENTER;
- if (!*p)
- {
- *p = (NMEM_MUTEX) malloc (sizeof(**p));
-#ifdef WIN32
- InitializeCriticalSection(&(*p)->m_handle);
-#elif YAZ_POSIX_THREADS
- pthread_mutex_init (&(*p)->m_handle, 0);
-#elif YAZ_GNU_THREADS
- pth_mutex_init (&(*p)->m_handle);
-#endif
- }
- NMEM_LEAVE;
-}
-
-YAZ_EXPORT void nmem_mutex_enter(NMEM_MUTEX p)