diff options
author | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2013-11-13 21:40:58 +0100 |
---|---|---|
committer | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2013-11-13 21:40:58 +0100 |
commit | 81bb21fe5313463ac9896984cd71cfc3455379ee (patch) | |
tree | c83aef759bf48ceb1567810c7a059307f7455bee /external | |
parent | 2e1a735c1bb76094744a6112b092331e34c7db09 (diff) | |
download | librcc-81bb21fe5313463ac9896984cd71cfc3455379ee.tar.gz librcc-81bb21fe5313463ac9896984cd71cfc3455379ee.tar.bz2 librcc-81bb21fe5313463ac9896984cd71cfc3455379ee.tar.xz librcc-81bb21fe5313463ac9896984cd71cfc3455379ee.zip |
Avoid functions deprecated in glib 2.32
Diffstat (limited to 'external')
-rw-r--r-- | external/Makefile.am | 4 | ||||
-rw-r--r-- | external/compat.h | 40 | ||||
-rw-r--r-- | external/rccexternal.c | 4 | ||||
-rw-r--r-- | external/rcclibtranslate.c | 12 |
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); |