Browse code

core: added function to check if counters have been initialized

Daniel-Constantin Mierla authored on 03/12/2013 22:38:08
Showing 2 changed files
... ...
@@ -89,12 +89,20 @@ static int grp_no; /* number of groups */
89 89
 
90 90
 /** counters array. a[proc_no][counter_id] =>
91 91
   _cnst_vals[proc_no*cnts_no+counter_id] */
92
-counter_array_t* _cnts_vals;
92
+counter_array_t* _cnts_vals = 0;
93 93
 int _cnts_row_len; /* number of elements per row */
94 94
 static int cnts_no; /* number of registered counters */
95 95
 static int cnts_max_rows; /* set to 0 if not yet fully init */
96 96
 
97 97
 
98
+int counters_initialized(void)
99
+{
100
+	if (unlikely(_cnts_vals == 0)) {
101
+		/* not init yet */
102
+		return 0;
103
+	}
104
+	return 1;
105
+}
98 106
 
99 107
 /** init the coutner hash table(s).
100 108
  * @return 0 on success, -1 on error.
... ...
@@ -87,6 +87,7 @@ extern int _cnts_row_len; /* number of elements per row */
87 87
 
88 88
 
89 89
 
90
+int counters_initialized(void);
90 91
 int init_counters(void);
91 92
 void destroy_counters(void);
92 93
 int counters_prefork_init(int max_process_no);