diff options
author | Franklin Wei <git@fwei.tk> | 2018-02-07 20:04:46 -0500 |
---|---|---|
committer | Franklin Wei <git@fwei.tk> | 2018-03-12 20:52:01 -0400 |
commit | 6039eb05ba6d82ef56f2868c96654c552d117bf9 (patch) | |
tree | 9db7016bcbf66cfdf7b9bc998d84c6eaff9c8378 /apps/plugins/sdl/src/thread/dc/SDL_sysmutex.c | |
parent | ef373c03b96b0be08babca581d9f10bccfd4931f (diff) | |
download | rockbox-6039eb05ba6d82ef56f2868c96654c552d117bf9.tar.gz rockbox-6039eb05ba6d82ef56f2868c96654c552d117bf9.zip |
sdl: remove non-rockbox drivers
We never use any of these other drivers, so having them around just takes
up space.
Change-Id: Iced812162df1fef3fd55522b7e700acb6c3bcd41
Diffstat (limited to 'apps/plugins/sdl/src/thread/dc/SDL_sysmutex.c')
-rw-r--r-- | apps/plugins/sdl/src/thread/dc/SDL_sysmutex.c | 122 |
1 files changed, 0 insertions, 122 deletions
diff --git a/apps/plugins/sdl/src/thread/dc/SDL_sysmutex.c b/apps/plugins/sdl/src/thread/dc/SDL_sysmutex.c deleted file mode 100644 index c6c465131b..0000000000 --- a/apps/plugins/sdl/src/thread/dc/SDL_sysmutex.c +++ /dev/null | |||
@@ -1,122 +0,0 @@ | |||
1 | /* | ||
2 | SDL - Simple DirectMedia Layer | ||
3 | Copyright (C) 1997-2012 Sam Lantinga | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2.1 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General Public | ||
16 | License along with this library; if not, write to the Free Software | ||
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | |||
19 | Sam Lantinga | ||
20 | slouken@libsdl.org | ||
21 | */ | ||
22 | #include "SDL_config.h" | ||
23 | |||
24 | /* An implementation of mutexes using semaphores */ | ||
25 | |||
26 | #include "SDL_thread.h" | ||
27 | #include "SDL_systhread_c.h" | ||
28 | |||
29 | #include <arch/spinlock.h> | ||
30 | |||
31 | struct SDL_mutex { | ||
32 | int recursive; | ||
33 | Uint32 owner; | ||
34 | spinlock_t mutex; | ||
35 | }; | ||
36 | |||
37 | /* Create a mutex */ | ||
38 | SDL_mutex *SDL_CreateMutex(void) | ||
39 | { | ||
40 | SDL_mutex *mutex; | ||
41 | |||
42 | /* Allocate mutex memory */ | ||
43 | mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex)); | ||
44 | if ( mutex ) { | ||
45 | spinlock_init(&mutex->mutex); | ||
46 | mutex->recursive = 0; | ||
47 | mutex->owner = 0; | ||
48 | } else { | ||
49 | SDL_OutOfMemory(); | ||
50 | } | ||
51 | return mutex; | ||
52 | } | ||
53 | |||
54 | /* Free the mutex */ | ||
55 | void SDL_DestroyMutex(SDL_mutex *mutex) | ||
56 | { | ||
57 | if ( mutex ) { | ||
58 | SDL_free(mutex); | ||
59 | } | ||
60 | } | ||
61 | |||
62 | /* Lock the semaphore */ | ||
63 | int SDL_mutexP(SDL_mutex *mutex) | ||
64 | { | ||
65 | #if SDL_THREADS_DISABLED | ||
66 | return SDL_arraysize(return ),0; | ||
67 | #else | ||
68 | Uint32 this_thread; | ||
69 | |||
70 | if ( mutex == NULL ) { | ||
71 | SDL_SetError("Passed a NULL mutex"); | ||
72 | return -1; | ||
73 | } | ||
74 | |||
75 | this_thread = SDL_ThreadID(); | ||
76 | if ( mutex->owner == this_thread ) { | ||
77 | ++mutex->recursive; | ||
78 | } else { | ||
79 | /* The order of operations is important. | ||
80 | We set the locking thread id after we obtain the lock | ||
81 | so unlocks from other threads will fail. | ||
82 | */ | ||
83 | spinlock_lock(&mutex->mutex); | ||
84 | mutex->owner = this_thread; | ||
85 | mutex->recursive = 0; | ||
86 | } | ||
87 | |||
88 | return 0; | ||
89 | #endif /* SDL_THREADS_DISABLED */ | ||
90 | } | ||
91 | |||
92 | /* Unlock the mutex */ | ||
93 | int SDL_mutexV(SDL_mutex *mutex) | ||
94 | { | ||
95 | #if SDL_THREADS_DISABLED | ||
96 | return 0; | ||
97 | #else | ||
98 | if ( mutex == NULL ) { | ||
99 | SDL_SetError("Passed a NULL mutex"); | ||
100 | return -1; | ||
101 | } | ||
102 | |||
103 | /* If we don't own the mutex, we can't unlock it */ | ||
104 | if ( SDL_ThreadID() != mutex->owner ) { | ||
105 | SDL_SetError("mutex not owned by this thread"); | ||
106 | return -1; | ||
107 | } | ||
108 | |||
109 | if ( mutex->recursive ) { | ||
110 | --mutex->recursive; | ||
111 | } else { | ||
112 | /* The order of operations is important. | ||
113 | First reset the owner so another thread doesn't lock | ||
114 | the mutex and set the ownership before we reset it, | ||
115 | then release the lock semaphore. | ||
116 | */ | ||
117 | mutex->owner = 0; | ||
118 | spinlock_unlock(&mutex->mutex); | ||
119 | } | ||
120 | return 0; | ||
121 | #endif /* SDL_THREADS_DISABLED */ | ||
122 | } | ||