diff --git a/Makefile.common b/Makefile.common
index b16c59f99a..25439a632d 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -472,6 +472,7 @@ ifeq ($(HAVE_THREADS), 1)
OBJ += autosave.o \
libretro-common/rthreads/rthreads.o \
libretro-common/rthreads/rsemaphore.o \
+ libretro-common/rthreads/async_job.o \
gfx/video_thread_wrapper.o \
audio/audio_thread_wrapper.o
DEFINES += -DHAVE_THREADS
@@ -869,7 +870,7 @@ ifeq ($(HAVE_NETWORKING), 1)
ifeq ($(HAVE_CHEEVOS), 1)
ifeq ($(HAVE_THREADS), 1)
DEFINES += -DHAVE_CHEEVOS
- OBJ += cheevos.o async_job.o libretro-common/utils/md5.o
+ OBJ += cheevos.o libretro-common/utils/md5.o
endif
endif
endif
diff --git a/async_job.h b/async_job.h
deleted file mode 100644
index 18c3c2dcb1..0000000000
--- a/async_job.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* RetroArch - A frontend for libretro.
- * Copyright (C) 2015 - Andre Leiradella
- *
- * RetroArch is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Found-
- * ation, either version 3 of the License, or (at your option) any later version.
- *
- * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with RetroArch.
- * If not, see .
- */
-
-#ifndef __RARCH_ASYNC_JOB_H
-#define __RARCH_ASYNC_JOB_H
-
-typedef struct async_job async_job_t;
-typedef void (*async_task_t)(void *payload);
-
-async_job_t *async_job_new(void);
-
-void async_job_free(async_job_t *ajob);
-
-int async_job_add(async_job_t *ajob, async_task_t task, void *payload);
-
-#endif /* __RARCH_ASYNC_JOB_H */
diff --git a/cheevos.c b/cheevos.c
index f10e1fe3d5..40ec7538d9 100644
--- a/cheevos.c
+++ b/cheevos.c
@@ -24,11 +24,11 @@
#include
#include
#include
+#include
#include "cheevos.h"
#include "dynamic.h"
#include "net_http_special.h"
-#include "async_job.h"
enum
{
diff --git a/griffin/griffin.c b/griffin/griffin.c
index 0ebb341377..b73e6b4c6a 100644
--- a/griffin/griffin.c
+++ b/griffin/griffin.c
@@ -90,7 +90,6 @@ ACHIEVEMENTS
#include "../libretro-common/formats/json/jsonsax.c"
#include "../libretro-common/utils/md5.c"
#include "../net_http_special.c"
-#include "../async_job.c"
#include "../cheevos.c"
#endif
@@ -733,6 +732,7 @@ THREAD
#elif defined(HAVE_THREADS)
#include "../libretro-common/rthreads/rthreads.c"
#include "../libretro-common/rthreads/rsemaphore.c"
+#include "../libretro-common/rthreads/async_job.c"
#include "../gfx/video_thread_wrapper.c"
#include "../audio/audio_thread_wrapper.c"
#include "../autosave.c"
diff --git a/libretro-common/include/rthreads/async_job.h b/libretro-common/include/rthreads/async_job.h
new file mode 100644
index 0000000000..d98742b479
--- /dev/null
+++ b/libretro-common/include/rthreads/async_job.h
@@ -0,0 +1,35 @@
+/* Copyright (C) 2010-2015 The RetroArch team
+ *
+ * ---------------------------------------------------------------------------------------
+ * The following license statement only applies to this file (async_job.h).
+ * ---------------------------------------------------------------------------------------
+ *
+ * Permission is hereby granted, free of charge,
+ * to any person obtaining a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef __LIBRETRO_SDK_ASYNC_JOB_H
+#define __LIBRETRO_SDK_ASYNC_JOB_H
+
+typedef struct async_job async_job_t;
+typedef void (*async_task_t)(void *payload);
+
+async_job_t *async_job_new(void);
+
+void async_job_free(async_job_t *ajob);
+
+int async_job_add(async_job_t *ajob, async_task_t task, void *payload);
+
+#endif /* __LIBRETRO_SDK_ASYNC_JOB_H */
diff --git a/libretro-common/include/rthreads/rsemaphore.h b/libretro-common/include/rthreads/rsemaphore.h
index 3373dc84da..9dbb82155b 100644
--- a/libretro-common/include/rthreads/rsemaphore.h
+++ b/libretro-common/include/rthreads/rsemaphore.h
@@ -1,16 +1,23 @@
-/* RetroArch - A frontend for libretro.
- * Copyright (C) 2015 - Andre Leiradella
+/* Copyright (C) 2010-2015 The RetroArch team
*
- * RetroArch is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Found-
- * ation, either version 3 of the License, or (at your option) any later version.
+ * ---------------------------------------------------------------------------------------
+ * The following license statement only applies to this file (rsemaphore.h).
+ * ---------------------------------------------------------------------------------------
*
- * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
+ * Permission is hereby granted, free of charge,
+ * to any person obtaining a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
- * You should have received a copy of the GNU General Public License along with RetroArch.
- * If not, see .
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __LIBRETRO_SDK_SEMAPHORE_H
@@ -34,4 +41,4 @@ void ssem_wait(ssem_t *semaphore);
void ssem_signal(ssem_t *semaphore);
-#endif /* __RARCH_SEMAPHORE_H */
+#endif /* __LIBRETRO_SDK_SEMAPHORE_H */
diff --git a/async_job.c b/libretro-common/rthreads/async_job.c
similarity index 53%
rename from async_job.c
rename to libretro-common/rthreads/async_job.c
index f53bb29e06..3aa1778997 100644
--- a/async_job.c
+++ b/libretro-common/rthreads/async_job.c
@@ -1,23 +1,30 @@
-/* RetroArch - A frontend for libretro.
- * Copyright (C) 2015 - Andre Leiradella
+/* Copyright (C) 2010-2015 The RetroArch team
*
- * RetroArch is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Found-
- * ation, either version 3 of the License, or (at your option) any later version.
+ * ---------------------------------------------------------------------------------------
+ * The following license statement only applies to this file (async_job.c).
+ * ---------------------------------------------------------------------------------------
*
- * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
+ * Permission is hereby granted, free of charge,
+ * to any person obtaining a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
- * You should have received a copy of the GNU General Public License along with RetroArch.
- * If not, see .
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include
#include
#include
-#include
+#include
typedef struct async_job_node async_job_node_t;
@@ -40,8 +47,8 @@ struct async_job
static void async_job_processor(void *userdata)
{
- async_job_t *ajob = (async_job_t*)userdata;
async_job_node_t *node;
+ async_job_t *ajob = (async_job_t*)userdata;
for (;;)
{
@@ -64,14 +71,11 @@ static void async_job_processor(void *userdata)
async_job_t *async_job_new(void)
{
- async_job_t *ajob = (async_job_t*)malloc(sizeof(*ajob));
+ async_job_t *ajob = (async_job_t*)calloc(1, sizeof(*ajob));
if (ajob)
{
- ajob->first = NULL;
- ajob->last = NULL;
- ajob->finish = 0;
- ajob->lock = slock_new();
+ ajob->lock = slock_new();
if (ajob->lock)
{
@@ -107,14 +111,13 @@ void async_job_free(async_job_t *ajob)
int async_job_add(async_job_t *ajob, async_task_t task, void *payload)
{
- async_job_node_t *node = (async_job_node_t*)malloc(sizeof(*node));
+ async_job_node_t *node = (async_job_node_t*)calloc(1, sizeof(*node));
if (!node)
return -1;
node->task = task;
node->payload = payload;
- node->next = NULL;
slock_lock(ajob->lock);