multi.c: Remove static variables _gfortrani_caf_this_image and caf_num_images.

2018-09-02  Thomas Koenig  <tkoenig@gcc.gnu.org>
	* caf/multi.c: Remove static variables _gfortrani_caf_this_image
	and caf_num_images.
	* runtime/environ.c: Add caf_num_images.
	* runtime/compile_options.c: Add _gfortrani_caf_this_image.

From-SVN: r264045
diff --git a/libgfortran/ChangeLog.dev b/libgfortran/ChangeLog.dev
index b051202..1bdd4e5 100644
--- a/libgfortran/ChangeLog.dev
+++ b/libgfortran/ChangeLog.dev
@@ -1,4 +1,10 @@
 2018-09-02  Thomas Koenig  <tkoenig@gcc.gnu.org>
+	* caf/multi.c: Remove static variables _gfortrani_caf_this_image
+	and caf_num_images.
+	* runtime/environ.c: Add caf_num_images.
+	* runtime/compile_options.c: Add _gfortrani_caf_this_image.
+
+2018-09-02  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
 	* caf/multi.c (_gfortran_caf_register): New function.
 	(_gfortran_caf_lock): New function.
diff --git a/libgfortran/caf/multi.c b/libgfortran/caf/multi.c
index f4a700c..474b8f5 100644
--- a/libgfortran/caf/multi.c
+++ b/libgfortran/caf/multi.c
@@ -59,8 +59,6 @@
 
 /* Static variables.  */
 
-__thread int _gfortrani_caf_this_image = -1;
-int caf_num_images = -1;
 pthread_barrier_t sync_all_barrier;
 pthread_t *tidlist;
 
diff --git a/libgfortran/runtime/compile_options.c b/libgfortran/runtime/compile_options.c
index ef8777e..8b46a9c 100644
--- a/libgfortran/runtime/compile_options.c
+++ b/libgfortran/runtime/compile_options.c
@@ -142,6 +142,10 @@
 extern void set_options (int , int []);
 export_proto(set_options);
 
+/* Thread-local storage which image we are in.  */
+
+__thread int _gfortrani_caf_this_image = -1;
+
 void
 set_options (int num, int options[])
 {
diff --git a/libgfortran/runtime/environ.c b/libgfortran/runtime/environ.c
index c65754b..5fa12bd 100644
--- a/libgfortran/runtime/environ.c
+++ b/libgfortran/runtime/environ.c
@@ -32,6 +32,7 @@
 #include <unistd.h>
 #endif
 
+int caf_num_images = -1;
 
 /* Implementation of secure_getenv() for targets where it is not
    provided. */