Mercurial > sdl-ios-xcode
comparison src/thread/win32/SDL_sysmutex.c @ 1668:4da1ee79c9af SDL-1.3
more tweaking indent options
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 29 May 2006 04:04:35 +0000 |
parents | 782fd950bd46 |
children |
comparison
equal
deleted
inserted
replaced
1667:1fddae038bc8 | 1668:4da1ee79c9af |
---|---|
34 HANDLE id; | 34 HANDLE id; |
35 }; | 35 }; |
36 | 36 |
37 /* Create a mutex */ | 37 /* Create a mutex */ |
38 SDL_mutex * | 38 SDL_mutex * |
39 SDL_CreateMutex (void) | 39 SDL_CreateMutex(void) |
40 { | 40 { |
41 SDL_mutex *mutex; | 41 SDL_mutex *mutex; |
42 | 42 |
43 /* Allocate mutex memory */ | 43 /* Allocate mutex memory */ |
44 mutex = (SDL_mutex *) SDL_malloc (sizeof (*mutex)); | 44 mutex = (SDL_mutex *) SDL_malloc(sizeof(*mutex)); |
45 if (mutex) { | 45 if (mutex) { |
46 /* Create the mutex, with initial value signaled */ | 46 /* Create the mutex, with initial value signaled */ |
47 mutex->id = CreateMutex (NULL, FALSE, NULL); | 47 mutex->id = CreateMutex(NULL, FALSE, NULL); |
48 if (!mutex->id) { | 48 if (!mutex->id) { |
49 SDL_SetError ("Couldn't create mutex"); | 49 SDL_SetError("Couldn't create mutex"); |
50 SDL_free (mutex); | 50 SDL_free(mutex); |
51 mutex = NULL; | 51 mutex = NULL; |
52 } | 52 } |
53 } else { | 53 } else { |
54 SDL_OutOfMemory (); | 54 SDL_OutOfMemory(); |
55 } | 55 } |
56 return (mutex); | 56 return (mutex); |
57 } | 57 } |
58 | 58 |
59 /* Free the mutex */ | 59 /* Free the mutex */ |
60 void | 60 void |
61 SDL_DestroyMutex (SDL_mutex * mutex) | 61 SDL_DestroyMutex(SDL_mutex * mutex) |
62 { | 62 { |
63 if (mutex) { | 63 if (mutex) { |
64 if (mutex->id) { | 64 if (mutex->id) { |
65 CloseHandle (mutex->id); | 65 CloseHandle(mutex->id); |
66 mutex->id = 0; | 66 mutex->id = 0; |
67 } | 67 } |
68 SDL_free (mutex); | 68 SDL_free(mutex); |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
72 /* Lock the mutex */ | 72 /* Lock the mutex */ |
73 int | 73 int |
74 SDL_mutexP (SDL_mutex * mutex) | 74 SDL_mutexP(SDL_mutex * mutex) |
75 { | 75 { |
76 if (mutex == NULL) { | 76 if (mutex == NULL) { |
77 SDL_SetError ("Passed a NULL mutex"); | 77 SDL_SetError("Passed a NULL mutex"); |
78 return -1; | 78 return -1; |
79 } | 79 } |
80 if (WaitForSingleObject (mutex->id, INFINITE) == WAIT_FAILED) { | 80 if (WaitForSingleObject(mutex->id, INFINITE) == WAIT_FAILED) { |
81 SDL_SetError ("Couldn't wait on mutex"); | 81 SDL_SetError("Couldn't wait on mutex"); |
82 return -1; | 82 return -1; |
83 } | 83 } |
84 return (0); | 84 return (0); |
85 } | 85 } |
86 | 86 |
87 /* Unlock the mutex */ | 87 /* Unlock the mutex */ |
88 int | 88 int |
89 SDL_mutexV (SDL_mutex * mutex) | 89 SDL_mutexV(SDL_mutex * mutex) |
90 { | 90 { |
91 if (mutex == NULL) { | 91 if (mutex == NULL) { |
92 SDL_SetError ("Passed a NULL mutex"); | 92 SDL_SetError("Passed a NULL mutex"); |
93 return -1; | 93 return -1; |
94 } | 94 } |
95 if (ReleaseMutex (mutex->id) == FALSE) { | 95 if (ReleaseMutex(mutex->id) == FALSE) { |
96 SDL_SetError ("Couldn't release mutex"); | 96 SDL_SetError("Couldn't release mutex"); |
97 return -1; | 97 return -1; |
98 } | 98 } |
99 return (0); | 99 return (0); |
100 } | 100 } |
101 | 101 |