File: compat.h

package info (click to toggle)
librcc 0.2.13%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,036 kB
  • sloc: ansic: 9,069; xml: 524; sh: 247; makefile: 163
file content (42 lines) | stat: -rw-r--r-- 1,252 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef _RCC_EXTERNAL_COMPAT_H
#define _RCC_EXTERNAL_COMPAT_H

#include <glib.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 */