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/compat.h | |
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/compat.h')
-rw-r--r-- | external/compat.h | 40 |
1 files changed, 40 insertions, 0 deletions
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 */ |