2 Copyright (C) 1999-2006 Id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 ===================================================================
32 ===================================================================
40 void MutexLock( mutex_t *m ){
41 CRITICAL_SECTION *crit;
46 crit = (CRITICAL_SECTION *) m;
47 EnterCriticalSection( crit );
50 void MutexUnlock( mutex_t *m ){
51 CRITICAL_SECTION *crit;
56 crit = (CRITICAL_SECTION *) m;
57 LeaveCriticalSection( crit );
60 mutex_t *MutexAlloc( void ){
61 CRITICAL_SECTION *crit;
63 if ( numthreads == 1 ) {
66 crit = (CRITICAL_SECTION *) safe_malloc( sizeof( CRITICAL_SECTION ) );
67 InitializeCriticalSection( crit );
74 ===================================================================
78 ===================================================================
86 void MutexLock( mutex_t *m ){
87 pthread_mutex_t *my_mutex;
92 my_mutex = (pthread_mutex_t *) m;
93 pthread_mutex_lock( my_mutex );
96 void MutexUnlock( mutex_t *m ){
97 pthread_mutex_t *my_mutex;
102 my_mutex = (pthread_mutex_t *) m;
103 pthread_mutex_unlock( my_mutex );
106 mutex_t *MutexAlloc( void ){
107 pthread_mutex_t *my_mutex;
108 pthread_mutexattr_t mattrib;
110 if ( numthreads == 1 ) {
113 my_mutex = safe_malloc( sizeof( *my_mutex ) );
114 if ( pthread_mutexattr_create( &mattrib ) == -1 ) {
115 Error( "pthread_mutex_attr_create failed" );
117 if ( pthread_mutexattr_setkind_np( &mattrib, MUTEX_FAST_NP ) == -1 ) {
118 Error( "pthread_mutexattr_setkind_np failed" );
120 if ( pthread_mutex_init( my_mutex, mattrib ) == -1 ) {
121 Error( "pthread_mutex_init failed" );
123 return (void *) my_mutex;
129 ===================================================================
133 ===================================================================
140 #include <abi_mutex.h>
141 #include <sys/types.h>
142 #include <sys/prctl.h>
144 void MutexLock( mutex_t *m ){
150 lck = (abilock_t *) m;
154 void MutexUnlock( mutex_t *m ){
160 lck = (abilock_t *) m;
164 mutex_t *MutexAlloc( void ){
167 if ( numthreads == 1 ) {
170 lck = (abilock_t *) safe_malloc( sizeof( abilock_t ) );
178 =======================================================================
182 =======================================================================
187 void MutexLock( mutex_t *m ){
190 void MutexUnlock( mutex_t *m ){
193 mutex_t *MutexAlloc( void ){