summaryrefslogtreecommitdiffstats
path: root/external
diff options
context:
space:
mode:
Diffstat (limited to 'external')
-rw-r--r--external/Makefile.am4
-rw-r--r--external/compat.h40
-rw-r--r--external/rccexternal.c4
-rw-r--r--external/rcclibtranslate.c12
4 files changed, 51 insertions, 9 deletions
diff --git a/external/Makefile.am b/external/Makefile.am
index 51cbad9..31cec9c 100644
--- a/external/Makefile.am
+++ b/external/Makefile.am
@@ -4,12 +4,12 @@ endif
bindir = $(pkgdatadir)/
-rccexternal_SOURCES= rccexternal.c \
+rccexternal_SOURCES= rccexternal.c compat.h \
rcclibtranslate.c rcclibtranslate.h \
../src/rccdb4.c ../src/rccdb4.h \
../src/rcchome.c ../src/rcchome.h \
../src/rcclock.c ../src/rcclock.h
-
+
rccexternal_LDADD= @GLIB2_LIBS@ @LIBTRANSLATE_LIBS@ @BDB_LIBS@
AM_CPPFLAGS = @GLIB2_CFLAGS@ @LIBTRANSLATE_CFLAGS@ @BDB_INCLUDES@ -I../src
diff --git a/external/compat.h b/external/compat.h
new file mode 100644
index 0000000..a70776d
--- /dev/null
+++ b/external/compat.h
@@ -0,0 +1,40 @@
+#ifndef _RCC_EXTERNAL_COMPAT_H
+#define _RCC_EXTERNAL_COMPAT_H
+
+# if GLIB_CHECK_VERSION(2,32,0)
+inline static GMutex *g_mutex_new_32() {
+ GMutex *res = malloc(sizeof(GMutex));
+ if (!res) return res;
+ g_mutex_init(res);
+ return res;
+}
+
+inline static GCond *g_cond_new_32() {
+ GCond *res = malloc(sizeof(GCond));
+ if (!res) return res;
+ g_cond_init(res);
+ return res;
+}
+
+inline static GThread *g_thread_create_32(GThreadFunc func, gpointer data, int joinable) {
+ GThread *res = g_thread_new(NULL, func, data);
+ if ((res)&&(!joinable)) g_thread_unref(res);
+ return res;
+}
+
+# define g_thread_create_compat(func, data, joinable) g_thread_create_32(func, data, joinable)
+# define g_mutex_new_compat() g_mutex_new_32()
+# define g_cond_new_compat() g_cond_new_32()
+# define g_mutex_free_compat(mutex) free(mutex)
+# define g_cond_free_compat(mutex) free(mutex)
+#else
+# define g_thread_create_compat(func, data, joinable) g_thread_create(func, data, joinable, NULL)
+# define g_mutex_new_compat() g_mutex_new()
+# define g_cond_new_compat() g_cond_new()
+# define g_mutex_free_compat(mutex) g_mutex_free(mutex)
+# define g_cond_free_compat(mutex) g_cond_free(mutex)
+# endif
+
+
+
+#endif /* _RCC_EXTERNAL_COMPAT_H */
diff --git a/external/rccexternal.c b/external/rccexternal.c
index 4e4fa77..eb6bbba 100644
--- a/external/rccexternal.c
+++ b/external/rccexternal.c
@@ -62,6 +62,8 @@
#include "../src/rccexternal.h"
#include "rcclibtranslate.h"
+#include "compat.h"
+
#define RCC_EXIT_CHECK_TIMEOUT 10 /* seconds */
@@ -170,7 +172,7 @@ int main() {
info = (rcc_external_info)malloc(sizeof(rcc_external_info_s));
if (info) info->s = sd;
else break;
- if (g_thread_create(rccLibTranslate, info, FALSE, NULL)) continue;
+ if (g_thread_create_compat(rccLibTranslate, info, FALSE)) continue;
break;
}
close(sd);
diff --git a/external/rcclibtranslate.c b/external/rcclibtranslate.c
index 5f8670d..fb83222 100644
--- a/external/rcclibtranslate.c
+++ b/external/rcclibtranslate.c
@@ -42,7 +42,7 @@
#include "../src/rcctranslate.h"
#include "../src/rccdb4.h"
#include "rcclibtranslate.h"
-
+#include "compat.h"
#ifdef HAVE_LIBTRANSLATE
static TranslateSession *session = NULL;
@@ -169,12 +169,12 @@ int rccLibTranslateInit(const char *rcc_home_dir) {
free(dbname);
}
if (db4ctx) {
- mutex = g_mutex_new();
- cond = g_cond_new();
+ mutex = g_mutex_new_compat();
+ cond = g_cond_new_compat();
if ((mutex)&&(cond))
queue = g_queue_new();
if (queue)
- thread = g_thread_create(rccLibPostponed, NULL, TRUE, NULL);
+ thread = g_thread_create_compat(rccLibPostponed, NULL, TRUE);
}
#endif /* HAVE_LIBTRANSLATE */
@@ -203,11 +203,11 @@ void rccLibTranslateFree() {
queue = NULL;
}
if (mutex) {
- g_mutex_free(mutex);
+ g_mutex_free_compat(mutex);
mutex = NULL;
}
if (cond) {
- g_cond_free(cond);
+ g_cond_free_compat(cond);
cond = NULL;
}
if (db4ctx) rccDb4FreeContext(db4ctx);