Use atomic functions where appropriate

Also, rename atomic functions to be consistent with the rest of the
platform/threading functions, and move atomic functions to threading*
files rather than platform* files
This commit is contained in:
jp9000
2014-03-16 18:26:46 -07:00
parent 3ed647b8a0
commit 154e0c59e1
15 changed files with 84 additions and 76 deletions

View File

@@ -241,5 +241,5 @@ struct graphics_subsystem {
DARRAY(struct vec2) texverts[16];
pthread_mutex_t mutex;
volatile int ref;
volatile long ref;
};

View File

@@ -179,13 +179,13 @@ void gs_entercontext(graphics_t graphics)
thread_graphics = graphics;
}
graphics->ref++;
os_atomic_inc_long(&graphics->ref);
}
void gs_leavecontext(void)
{
if (thread_graphics) {
if (!--thread_graphics->ref) {
if (!os_atomic_dec_long(&thread_graphics->ref)) {
graphics_t graphics = thread_graphics;
graphics->exports.device_leavecontext(graphics->device);