init: Use global mutex, not once mutex
authorDavid Schleef <ds@schleef.org>
Sun, 2 Oct 2011 19:04:57 +0000 (12:04 -0700)
committerDavid Schleef <ds@schleef.org>
Sun, 2 Oct 2011 19:04:57 +0000 (12:04 -0700)
Um, duh.  orc_init() can be called when the once mutex is held.

orc/orc.c
tools/orcc.c

index c359eb2..8a607c4 100644 (file)
--- a/orc/orc.c
+++ b/orc/orc.c
@@ -29,10 +29,10 @@ void _orc_compiler_init(void);
 void
 orc_init (void)
 {
-  static int inited = FALSE;
+  static volatile int inited = FALSE;
 
   if (!inited) {
-    orc_once_mutex_lock ();
+    orc_global_mutex_lock ();
     if (!inited) {
       ORC_ASSERT(sizeof(OrcExecutor) == sizeof(OrcExecutorAlt));
 
@@ -61,7 +61,7 @@ orc_init (void)
 
       inited = TRUE;
     }
-    orc_once_mutex_unlock ();
+    orc_global_mutex_unlock ();
   }
 }
 
index 54ea870..304fd38 100644 (file)
@@ -718,7 +718,7 @@ output_code_execute (OrcProgram *p, FILE *output, int is_inline)
       }
     }
   } else {
-    fprintf(output, "  static int p_inited = 0;\n");
+    fprintf(output, "  static volatile int p_inited = 0;\n");
     if (use_code) {
       fprintf(output, "  static OrcCode *c = 0;\n");
     } else {