2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
\r
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
\r
5 This file is part of GtkRadiant.
\r
7 GtkRadiant is free software; you can redistribute it and/or modify
\r
8 it under the terms of the GNU General Public License as published by
\r
9 the Free Software Foundation; either version 2 of the License, or
\r
10 (at your option) any later version.
\r
12 GtkRadiant is distributed in the hope that it will be useful,
\r
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
15 GNU General Public License for more details.
\r
17 You should have received a copy of the GNU General Public License
\r
18 along with GtkRadiant; if not, write to the Free Software
\r
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\r
24 #include "qthreads.h"
\r
28 ===================================================================
\r
32 ===================================================================
\r
38 #include <windows.h>
\r
40 void MutexLock (mutex_t *m)
\r
42 CRITICAL_SECTION *crit;
\r
46 crit = (CRITICAL_SECTION *) m;
\r
47 EnterCriticalSection (crit);
\r
50 void MutexUnlock (mutex_t *m)
\r
52 CRITICAL_SECTION *crit;
\r
56 crit = (CRITICAL_SECTION *) m;
\r
57 LeaveCriticalSection (crit);
\r
60 mutex_t *MutexAlloc(void)
\r
62 CRITICAL_SECTION *crit;
\r
64 if (numthreads == 1)
\r
66 crit = (CRITICAL_SECTION *) safe_malloc(sizeof(CRITICAL_SECTION));
\r
67 InitializeCriticalSection (crit);
\r
68 return (void *) crit;
\r
74 ===================================================================
\r
78 ===================================================================
\r
84 #include <pthread.h>
\r
86 void MutexLock (mutex_t *m)
\r
88 pthread_mutex_t *my_mutex;
\r
92 my_mutex = (pthread_mutex_t *) m;
\r
93 pthread_mutex_lock (my_mutex);
\r
96 void MutexUnlock (mutex_t *m)
\r
98 pthread_mutex_t *my_mutex;
\r
102 my_mutex = (pthread_mutex_t *) m;
\r
103 pthread_mutex_unlock (my_mutex);
\r
106 mutex_t *MutexAlloc(void)
\r
108 pthread_mutex_t *my_mutex;
\r
109 pthread_mutexattr_t mattrib;
\r
111 if (numthreads == 1)
\r
113 my_mutex = safe_malloc (sizeof(*my_mutex));
\r
114 if (pthread_mutexattr_create (&mattrib) == -1)
\r
115 Error ("pthread_mutex_attr_create failed");
\r
116 if (pthread_mutexattr_setkind_np (&mattrib, MUTEX_FAST_NP) == -1)
\r
117 Error ("pthread_mutexattr_setkind_np failed");
\r
118 if (pthread_mutex_init (my_mutex, mattrib) == -1)
\r
119 Error ("pthread_mutex_init failed");
\r
120 return (void *) my_mutex;
\r
126 ===================================================================
\r
130 ===================================================================
\r
137 #include <abi_mutex.h>
\r
138 #include <sys/types.h>
\r
139 #include <sys/prctl.h>
\r
141 void MutexLock (mutex_t *m)
\r
147 lck = (abilock_t *) m;
\r
151 void MutexUnlock (mutex_t *m)
\r
157 lck = (abilock_t *) m;
\r
158 release_lock (lck);
\r
161 mutex_t *MutexAlloc(void)
\r
165 if (numthreads == 1)
\r
167 lck = (abilock_t *) safe_malloc(sizeof(abilock_t));
\r
169 return (void *) lck;
\r
175 =======================================================================
\r
179 =======================================================================
\r
184 void MutexLock (mutex_t *m)
\r
188 void MutexUnlock (mutex_t *m)
\r
192 mutex_t *MutexAlloc(void)
\r