comparison src/thread/pth/SDL_sysmutex.c @ 1662:782fd950bd46 SDL-1.3

Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API. WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid. The code is now run through a consistent indent format: indent -i4 -nut -nsc -br -ce The headers are being converted to automatically generate doxygen documentation.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 28 May 2006 13:04:16 +0000
parents d910939febfa
children 4da1ee79c9af
comparison
equal deleted inserted replaced
1661:281d3f4870e5 1662:782fd950bd46
31 31
32 #include "SDL_mutex.h" 32 #include "SDL_mutex.h"
33 #include "SDL_sysmutex_c.h" 33 #include "SDL_sysmutex_c.h"
34 34
35 /* Create a mutex */ 35 /* Create a mutex */
36 SDL_mutex *SDL_CreateMutex(void) 36 SDL_mutex *
37 SDL_CreateMutex (void)
37 { 38 {
38 SDL_mutex *mutex; 39 SDL_mutex *mutex;
39 40
40 /* Allocate mutex memory */ 41 /* Allocate mutex memory */
41 mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex)); 42 mutex = (SDL_mutex *) SDL_malloc (sizeof (*mutex));
42 if ( mutex ) { 43 if (mutex) {
43 /* Create the mutex, with initial value signaled */ 44 /* Create the mutex, with initial value signaled */
44 if (!pth_mutex_init(&(mutex->mutexpth_p))) { 45 if (!pth_mutex_init (&(mutex->mutexpth_p))) {
45 SDL_SetError("Couldn't create mutex"); 46 SDL_SetError ("Couldn't create mutex");
46 SDL_free(mutex); 47 SDL_free (mutex);
47 mutex = NULL; 48 mutex = NULL;
48 } 49 }
49 } else { 50 } else {
50 SDL_OutOfMemory(); 51 SDL_OutOfMemory ();
51 } 52 }
52 return(mutex); 53 return (mutex);
53 } 54 }
54 55
55 /* Free the mutex */ 56 /* Free the mutex */
56 void SDL_DestroyMutex(SDL_mutex *mutex) 57 void
58 SDL_DestroyMutex (SDL_mutex * mutex)
57 { 59 {
58 if ( mutex ) { 60 if (mutex) {
59 SDL_free(mutex); 61 SDL_free (mutex);
60 } 62 }
61 } 63 }
62 64
63 /* Lock the mutex */ 65 /* Lock the mutex */
64 int SDL_mutexP(SDL_mutex *mutex) 66 int
67 SDL_mutexP (SDL_mutex * mutex)
65 { 68 {
66 if ( mutex == NULL ) { 69 if (mutex == NULL) {
67 SDL_SetError("Passed a NULL mutex"); 70 SDL_SetError ("Passed a NULL mutex");
68 return -1; 71 return -1;
69 } 72 }
70 73
71 pth_mutex_acquire(&(mutex->mutexpth_p), FALSE, NULL); 74 pth_mutex_acquire (&(mutex->mutexpth_p), FALSE, NULL);
72 75
73 return(0); 76 return (0);
74 } 77 }
75 78
76 /* Unlock the mutex */ 79 /* Unlock the mutex */
77 int SDL_mutexV(SDL_mutex *mutex) 80 int
81 SDL_mutexV (SDL_mutex * mutex)
78 { 82 {
79 if ( mutex == NULL ) { 83 if (mutex == NULL) {
80 SDL_SetError("Passed a NULL mutex"); 84 SDL_SetError ("Passed a NULL mutex");
81 return -1; 85 return -1;
82 } 86 }
83 87
84 pth_mutex_release(&(mutex->mutexpth_p)); 88 pth_mutex_release (&(mutex->mutexpth_p));
85 89
86 return(0); 90 return (0);
87 } 91 }
92
93 /* vi: set ts=4 sw=4 expandtab: */