]> Cypherpunks repositories - gostls13.git/commitdiff
runtime/cgo: use PTHREAD_{MUTEX,COND}_INITIALIZER
authorIan Lance Taylor <iant@golang.org>
Tue, 28 Apr 2015 20:58:32 +0000 (13:58 -0700)
committerIan Lance Taylor <iant@golang.org>
Tue, 28 Apr 2015 22:27:26 +0000 (22:27 +0000)
Technically you must initialize static pthread_mutex_t and
pthread_cond_t variables with the appropriate INITIALIZER macro.  In
practice the default initializers are zero anyhow, but it's still good
code hygiene.

Change-Id: I517304b16c2c7943b3880855c1b47a9a506b4bdf
Reviewed-on: https://go-review.googlesource.com/9433
Reviewed-by: David Crawshaw <crawshaw@golang.org>
src/runtime/cgo/gcc_libinit.c

index 95a18a8bb64a560fa7069fe9f4218ba0169b3bdd..0342b1323efaef1c66f514ea02ff01205a49e72c 100644 (file)
@@ -10,8 +10,8 @@
 #include <stdlib.h>
 #include <string.h> // strerror
 
-static pthread_cond_t runtime_init_cond;
-static pthread_mutex_t runtime_init_mu;
+static pthread_cond_t runtime_init_cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t runtime_init_mu = PTHREAD_MUTEX_INITIALIZER;
 static int runtime_init_done;
 
 void
@@ -39,4 +39,4 @@ x_cgo_notify_runtime_init_done(void* dummy) {
        runtime_init_done = 1;
        pthread_cond_broadcast(&runtime_init_cond);
        pthread_mutex_unlock(&runtime_init_mu);
-}
\ No newline at end of file
+}