2010-05-02 23:27:30 +00:00
|
|
|
#ifndef __mutex_h__
|
|
|
|
#define __mutex_h__
|
|
|
|
|
2012-05-01 12:39:20 +00:00
|
|
|
/* Mutual exclusion mechanism wrappers for the different platforms */
|
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
#if defined(_WIN32)
|
2012-05-01 12:39:20 +00:00
|
|
|
# include <windows.h>
|
|
|
|
# include <process.h>
|
|
|
|
#elif !defined GEKKO
|
|
|
|
# include <pthread.h>
|
2010-05-02 23:27:30 +00:00
|
|
|
#else
|
2012-05-01 12:39:20 +00:00
|
|
|
# include <SDL.h>
|
2010-05-02 23:27:30 +00:00
|
|
|
#endif
|
|
|
|
|
2012-11-05 02:49:08 +00:00
|
|
|
#ifdef EXTERNC
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
#if defined(_WIN32)
|
|
|
|
typedef HANDLE mutex_t;
|
2012-05-01 12:39:20 +00:00
|
|
|
#elif !defined GEKKO
|
2010-05-02 23:27:30 +00:00
|
|
|
typedef pthread_mutex_t mutex_t;
|
2012-05-01 12:39:20 +00:00
|
|
|
#else
|
|
|
|
/* PK: I don't like pointer typedefs, but SDL_CreateMutex() _returns_ one,
|
|
|
|
* so we're out of luck with our interface. */
|
|
|
|
typedef SDL_mutex* mutex_t;
|
2010-05-02 23:27:30 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
extern int32_t mutex_init(mutex_t *mutex);
|
|
|
|
extern int32_t mutex_lock(mutex_t *mutex);
|
|
|
|
extern int32_t mutex_unlock(mutex_t *mutex);
|
|
|
|
|
2012-11-05 02:49:08 +00:00
|
|
|
|
|
|
|
#ifdef EXTERNC
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-08-12 13:38:37 +00:00
|
|
|
#endif
|