[libbluray-devel] Make sure compiler won' t change method registration order in bdj_register_native_methods()

tourettes git at videolan.org
Tue Jan 6 15:39:30 CET 2015


libbluray | branch: master | tourettes <tourettes at team-mediaportal.com> | Sun Jan  4 15:35:59 2015 +0200| [1bde987813df79f6b6e5a09defd085340f5dcbcd] | committer: hpi1

Make sure compiler won't change method registration order in bdj_register_native_methods()

At least Visual Studio C compiler aggressively tries to optimize
"return A() * B() * C() * D()" by changing the execution order.

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=1bde987813df79f6b6e5a09defd085340f5dcbcd
---

 src/libbluray/bdj/native/register_native.c |   34 ++++++++++++++--------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/src/libbluray/bdj/native/register_native.c b/src/libbluray/bdj/native/register_native.c
index 80dfdae..b20968a 100644
--- a/src/libbluray/bdj/native/register_native.c
+++ b/src/libbluray/bdj/native/register_native.c
@@ -99,24 +99,24 @@ int bdj_register_native_methods(JNIEnv *env)
     extern const int Java_java_awt_BDGraphics_methods_count;
     extern const int Java_java_awt_BDFontMetrics_methods_count;
 
-    return
-      _register_methods(env, "org/videolan/Logger",
-                           Java_org_videolan_Logger_methods,
-                           Java_org_videolan_Logger_methods_count)
-      *
-      _register_methods(env, "org/videolan/Libbluray",
-                           Java_org_videolan_Libbluray_methods,
-                           Java_org_videolan_Libbluray_methods_count)
-      *
+    int result = _register_methods(env, "org/videolan/Logger",
+        Java_org_videolan_Logger_methods,
+        Java_org_videolan_Logger_methods_count);
+
+    result *= _register_methods(env, "org/videolan/Libbluray",
+        Java_org_videolan_Libbluray_methods,
+        Java_org_videolan_Libbluray_methods_count);
+
       /* BDFontMetrics must be registered before BDGraphics */
-      _register_methods(env, "java/awt/BDFontMetrics",
-                           Java_java_awt_BDFontMetrics_methods,
-                           Java_java_awt_BDFontMetrics_methods_count)
-      *
-      _register_methods(env, "java/awt/BDGraphicsBase",
-                           Java_java_awt_BDGraphics_methods,
-                           Java_java_awt_BDGraphics_methods_count)
-      ;
+    result *= _register_methods(env, "java/awt/BDFontMetrics",
+        Java_java_awt_BDFontMetrics_methods,
+        Java_java_awt_BDFontMetrics_methods_count);
+
+    result *= _register_methods(env, "java/awt/BDGraphicsBase",
+        Java_java_awt_BDGraphics_methods,
+        Java_java_awt_BDGraphics_methods_count);
+
+    return result;
 }
 
 void bdj_unregister_native_methods(JNIEnv *env)



More information about the libbluray-devel mailing list