]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Do not use deprecated functions for lock statements
authorJürg Billeter <j@bitron.ch>
Sun, 16 Sep 2012 18:45:15 +0000 (20:45 +0200)
committerJürg Billeter <j@bitron.ch>
Sun, 16 Sep 2012 18:45:15 +0000 (20:45 +0200)
Fixes bug 662810.

codegen/valaccodebasemodule.vala

index a81afeca4f31e1508db3264c84cecfc7d4359fd7..8b2a3594071c553f29c7ef1f24627096f7213921 100644 (file)
@@ -462,13 +462,16 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                gvalue_type = (Struct) glib_ns.scope.lookup ("Value");
                gvariant_type = (Class) glib_ns.scope.lookup ("Variant");
                gsource_type = (Class) glib_ns.scope.lookup ("Source");
-               mutex_type = (Struct) glib_ns.scope.lookup ("StaticRecMutex");
 
                if (context.require_glib_version (2, 32)) {
                        gmutex_type = (Struct) glib_ns.scope.lookup ("Mutex");
                        grecmutex_type = (Struct) glib_ns.scope.lookup ("RecMutex");
                        grwlock_type = (Struct) glib_ns.scope.lookup ("RWLock");
                        gcond_type = (Struct) glib_ns.scope.lookup ("Cond");
+
+                       mutex_type = grecmutex_type;
+               } else {
+                       mutex_type = (Struct) glib_ns.scope.lookup ("StaticRecMutex");
                }
 
                type_module_type = (TypeSymbol) glib_ns.scope.lookup ("TypeModule");
@@ -871,8 +874,15 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                        pop_context ();
 
                        if (finalize_context != null) {
+                               string mutex_clear;
+                               if (context.require_glib_version (2, 32)) {
+                                       mutex_clear = "g_rec_mutex_clear";
+                               } else {
+                                       mutex_clear = "g_static_rec_mutex_free";
+                               }
+
                                push_context (finalize_context);
-                               var fc = new CCodeFunctionCall (new CCodeIdentifier ("g_static_rec_mutex_free"));
+                               var fc = new CCodeFunctionCall (new CCodeIdentifier (mutex_clear));
                                fc.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, l));
                                ccode.add_expression (fc);
                                pop_context ();