ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

pthread-mutex.cpp

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #define FORBIDDEN_SYMBOL_EXCEPTION_time_h
00024 
00025 #include "common/scummsys.h"
00026 
00027 #if defined(__ANDROID__) || defined(IPHONE)
00028 
00029 #include "backends/mutex/pthread/pthread-mutex.h"
00030 
00031 #include <pthread.h>
00032 
00033 
00034 OSystem::MutexRef PthreadMutexManager::createMutex() {
00035     pthread_mutexattr_t attr;
00036 
00037     pthread_mutexattr_init(&attr);
00038     pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
00039 
00040     pthread_mutex_t *mutex = new pthread_mutex_t;
00041 
00042     if (pthread_mutex_init(mutex, &attr) != 0) {
00043         warning("pthread_mutex_init() failed");
00044         delete mutex;
00045         return NULL;
00046     }
00047 
00048     return (OSystem::MutexRef)mutex;
00049 }
00050 
00051 void PthreadMutexManager::lockMutex(OSystem::MutexRef mutex) {
00052     if (pthread_mutex_lock((pthread_mutex_t *)mutex) != 0)
00053         warning("pthread_mutex_lock() failed");
00054 }
00055 
00056 void PthreadMutexManager::unlockMutex(OSystem::MutexRef mutex) {
00057     if (pthread_mutex_unlock((pthread_mutex_t *)mutex) != 0)
00058         warning("pthread_mutex_unlock() failed");
00059 }
00060 
00061 void PthreadMutexManager::deleteMutex(OSystem::MutexRef mutex) {
00062     pthread_mutex_t *m = (pthread_mutex_t *)mutex;
00063 
00064     if (pthread_mutex_destroy(m) != 0)
00065         warning("pthread_mutex_destroy() failed");
00066     else
00067         delete m;
00068 }
00069 
00070 #endif


Generated on Sat May 30 2020 05:00:33 for ResidualVM by doxygen 1.7.1
curved edge   curved edge