00001 /* 00002 SDL - Simple DirectMedia Layer 00003 Copyright (C) 1997-2009 Sam Lantinga 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00018 00019 Sam Lantinga 00020 slouken@libsdl.org 00021 */ 00022 00023 #ifndef _SDL_mutex_h 00024 #define _SDL_mutex_h 00025 00032 #include "SDL_stdinc.h" 00033 #include "SDL_error.h" 00034 00035 #include "begin_code.h" 00036 /* Set up for C function definitions, even when using C++ */ 00037 #ifdef __cplusplus 00038 extern "C" { 00039 #endif 00040 00044 #define SDL_MUTEX_TIMEDOUT 1 00045 00047 #define SDL_MUTEX_MAXWAIT (~(Uint32)0) 00048 00049 00050 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*@{*/ 00052 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 00053 00055 struct SDL_mutex; 00056 typedef struct SDL_mutex SDL_mutex; 00057 00059 extern DECLSPEC SDL_mutex * SDLCALL SDL_CreateMutex(void); 00060 00061 #define SDL_LockMutex(m) SDL_mutexP(m) 00062 00065 extern DECLSPEC int SDLCALL SDL_mutexP(SDL_mutex *mutex); 00066 00067 #define SDL_UnlockMutex(m) SDL_mutexV(m) 00068 00074 extern DECLSPEC int SDLCALL SDL_mutexV(SDL_mutex *mutex); 00075 00077 extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex *mutex); 00078 00081 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*@{*/ 00083 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 00084 00086 struct SDL_semaphore; 00087 typedef struct SDL_semaphore SDL_sem; 00088 00090 extern DECLSPEC SDL_sem * SDLCALL SDL_CreateSemaphore(Uint32 initial_value); 00091 00093 extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem *sem); 00094 00100 extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem *sem); 00101 00106 extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem *sem); 00107 00115 extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem *sem, Uint32 ms); 00116 00120 extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem *sem); 00121 00123 extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem *sem); 00124 00127 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*@{*/ 00129 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 00130 00133 struct SDL_cond; 00134 typedef struct SDL_cond SDL_cond; 00138 extern DECLSPEC SDL_cond * SDLCALL SDL_CreateCond(void); 00139 00141 extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond *cond); 00142 00146 extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond *cond); 00147 00151 extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond *cond); 00152 00158 extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond *cond, SDL_mutex *mut); 00159 00166 extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms); 00167 00170 /* Ends C function definitions when using C++ */ 00171 #ifdef __cplusplus 00172 } 00173 #endif 00174 #include "close_code.h" 00175 00176 #endif /* _SDL_mutex_h */ 00177