-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathglib-2.80.0-e2k.patch
132 lines (125 loc) · 5.51 KB
/
glib-2.80.0-e2k.patch
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
From 7a900f0b87f3960c67b50b9ca87cd4143c1b7879 Mon Sep 17 00:00:00 2001
From: Ilya Kurdyukov <[email protected]>
Date: Thu, 28 Mar 2024 21:54:11 +0700
Subject: [PATCH] glib-2.80.0 e2k support
---
glib/gmacros.h | 82 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 81 insertions(+), 1 deletion(-)
diff --git a/glib/gmacros.h b/glib/gmacros.h
index 2d66c2f..d346efe 100644
--- a/glib/gmacros.h
+++ b/glib/gmacros.h
@@ -749,6 +749,14 @@
_Pragma ("warning (disable:1478)")
#define G_GNUC_END_IGNORE_DEPRECATIONS \
_Pragma ("warning (pop)")
+#elif defined(__GI_SCANNER__)
+#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+#define G_GNUC_END_IGNORE_DEPRECATIONS
+#elif defined(__EDG__)
+#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
+ _Pragma ("diag_suppress 1215,1444")
+#define G_GNUC_END_IGNORE_DEPRECATIONS \
+ _Pragma ("diag_default 1215,1444")
#elif G_GNUC_CHECK_VERSION(4, 6)
#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
_Pragma ("GCC diagnostic push") \
@@ -1332,7 +1340,7 @@
#ifndef __GI_SCANNER__
-#if g_macro__has_attribute(cleanup)
+#if g_macro__has_attribute(cleanup) || defined(__EDG__)
/* these macros are private; note that gstdio.h also uses _GLIB_CLEANUP */
#define _GLIB_AUTOPTR_FUNC_NAME(TypeName) glib_autoptr_cleanup_##TypeName
@@ -1345,7 +1353,16 @@
#define _GLIB_AUTOPTR_QUEUE_FUNC_NAME(TypeName) glib_queueautoptr_cleanup_##TypeName
#define _GLIB_AUTOPTR_QUEUE_TYPENAME(TypeName) TypeName##_queueautoptr
#define _GLIB_AUTO_FUNC_NAME(TypeName) glib_auto_cleanup_##TypeName
+
+#if defined(__cplusplus) && defined(__EDG__) && !defined(__GI_SCANNER__)
+#define _GLIB_CLEANUP(func) \
+ _Pragma("diag_error 1097") \
+ __attribute__((cleanup(func))) \
+ _Pragma("diag_default 1097")
+#else
#define _GLIB_CLEANUP(func) __attribute__((cleanup(func)))
+#endif
+
#define _GLIB_DEFINE_AUTOPTR_CLEANUP_FUNCS(TypeName, ParentName, cleanup) \
typedef TypeName *_GLIB_AUTOPTR_TYPENAME(TypeName); \
typedef GList *_GLIB_AUTOPTR_LIST_TYPENAME(TypeName); \
@@ -1378,11 +1395,74 @@
G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
static G_GNUC_UNUSED inline void _GLIB_AUTO_FUNC_NAME(TypeName) (TypeName *_ptr) { if (*_ptr != none) (func) (*_ptr); } \
G_GNUC_END_IGNORE_DEPRECATIONS
+/* EDG frontend doesn't support "attribute cleanup" in C++ mode */
+#if defined(__cplusplus) && defined(__EDG__)
+#include <stddef.h>
+
+#define EDG_CLEANUP_COMMON(name) \
+ T *v; \
+ /* prevent copying */ \
+ name(name &x) { v = (T*)x; } \
+public: \
+ name(const name &x) { v = (T*)x; } \
+ name() { } \
+ name(T *x) { v = x; } \
+ ~name() { func((X*)&v); } \
+ T* operator=(T *x) { return (v = x); } \
+ T& operator[](ptrdiff_t i) { return v[i]; } \
+ T* operator->() { return v; } \
+ T** operator&() { return &v; } \
+ T& operator*() { return *v; } \
+ operator T*() const { return v; } \
+ template<typename Z> \
+ explicit operator Z*() { return (Z*)v; }
+
+/* need to hide C++ code from glib-mkenums */
+#define EDG_CLEANUP_DEFINE \
+template <typename T, typename X, void(*func)(X*)> \
+class EDG_CLEANUP_HELPER { \
+ EDG_CLEANUP_COMMON(EDG_CLEANUP_HELPER) \
+}; \
+\
+template <typename T, typename X, void(*func)(X*), class Y> \
+class EDG_CLEANUP_HELPER_EX { \
+ EDG_CLEANUP_COMMON(EDG_CLEANUP_HELPER_EX) \
+ operator Y() const { return Y((T*)this); } \
+}; \
+\
+template <typename T, void(*func)(T*)> \
+class EDG_CLEANUP_HELPER_AUTO { \
+ T v; \
+ /* prevent copying */ \
+ EDG_CLEANUP_HELPER_AUTO(EDG_CLEANUP_HELPER_AUTO &x) { v = (T)x; } \
+public: \
+ EDG_CLEANUP_HELPER_AUTO(const EDG_CLEANUP_HELPER_AUTO &x) { v = (T)x; } \
+ EDG_CLEANUP_HELPER_AUTO(T x) { v = x; } \
+ ~EDG_CLEANUP_HELPER_AUTO() { func(&v); } \
+ T operator=(T x) { return (v = x); } \
+ operator T() const { return v; } \
+};
+
+extern "C++" { EDG_CLEANUP_DEFINE }
+#undef EDG_CLEANUP_DEFINE
+#undef EDG_CLEANUP_COMMON
+
+#define g_autoptr_free(TypeName, var) _GLIB_AUTOPTR_FUNC_NAME(TypeName)(&var)
+#define g_autoptr(TypeName) EDG_CLEANUP_HELPER<TypeName, TypeName*, _GLIB_AUTOPTR_FUNC_NAME(TypeName)>
+#define g_autolist(TypeName) EDG_CLEANUP_HELPER<GList, GList*, _GLIB_AUTOPTR_LIST_FUNC_NAME(TypeName)>
+#define g_autoslist(TypeName) EDG_CLEANUP_HELPER<GSList, GSList*, _GLIB_AUTOPTR_SLIST_FUNC_NAME(TypeName)>
+#define g_autoqueue(TypeName) EDG_CLEANUP_HELPER<GQueue, GQueue*, _GLIB_AUTOPTR_QUEUE_FUNC_NAME(TypeName)>
+#define g_auto(TypeName) EDG_CLEANUP_HELPER_AUTO<TypeName, _GLIB_AUTO_FUNC_NAME(TypeName)>
+// g_autofree gchar *ptr -> g_autofree_edg(gchar) ptr
+#define g_autofree_edg(TypeName) EDG_CLEANUP_HELPER<TypeName, void, g_autoptr_cleanup_generic_gfree>
+#define g_autofree_edg_ex(TypeName, ExtraType) EDG_CLEANUP_HELPER_EX<TypeName, void, g_autoptr_cleanup_generic_gfree, ExtraType>
+#else
#define g_autoptr(TypeName) _GLIB_CLEANUP(_GLIB_AUTOPTR_FUNC_NAME(TypeName)) _GLIB_AUTOPTR_TYPENAME(TypeName)
#define g_autolist(TypeName) _GLIB_CLEANUP(_GLIB_AUTOPTR_LIST_FUNC_NAME(TypeName)) _GLIB_AUTOPTR_LIST_TYPENAME(TypeName)
#define g_autoslist(TypeName) _GLIB_CLEANUP(_GLIB_AUTOPTR_SLIST_FUNC_NAME(TypeName)) _GLIB_AUTOPTR_SLIST_TYPENAME(TypeName)
#define g_autoqueue(TypeName) _GLIB_CLEANUP(_GLIB_AUTOPTR_QUEUE_FUNC_NAME(TypeName)) _GLIB_AUTOPTR_QUEUE_TYPENAME(TypeName)
#define g_auto(TypeName) _GLIB_CLEANUP(_GLIB_AUTO_FUNC_NAME(TypeName)) TypeName
+#endif
#define g_autofree _GLIB_CLEANUP(g_autoptr_cleanup_generic_gfree)
#else /* not GNU C */
--
2.34.1