@@ -182,85 +182,6 @@ vips_g_thread_new(const char *domain, GThreadFunc func, gpointer data)
182
182
return thread ;
183
183
}
184
184
185
- static int
186
- get_num_processors (void )
187
- {
188
- #if GLIB_CHECK_VERSION (2 , 48 , 1 )
189
- /* We could use g_get_num_processors when GLib >= 2.48.1, see:
190
- * https://gitlab.gnome.org/GNOME/glib/commit/999711abc82ea3a698d05977f9f91c0b73957f7f
191
- * https://gitlab.gnome.org/GNOME/glib/commit/2149b29468bb99af3c29d5de61f75aad735082dc
192
- */
193
- return g_get_num_processors ();
194
- #else
195
- int nproc ;
196
-
197
- nproc = 1 ;
198
-
199
- #ifdef G_OS_UNIX
200
-
201
- #if defined(HAVE_UNISTD_H ) && defined(_SC_NPROCESSORS_ONLN )
202
- {
203
- /* POSIX style.
204
- */
205
- int x ;
206
-
207
- x = sysconf (_SC_NPROCESSORS_ONLN );
208
- if (x > 0 )
209
- nproc = x ;
210
- }
211
- #elif defined HW_NCPU
212
- {
213
- /* BSD style.
214
- */
215
- int x ;
216
- size_t len = sizeof (x );
217
-
218
- sysctl ((int [2 ]){ CTL_HW , HW_NCPU }, 2 , & x , & len , NULL , 0 );
219
- if (x > 0 )
220
- nproc = x ;
221
- }
222
- #endif
223
-
224
- /* libgomp has some very complex code on Linux to count the number of
225
- * processors available to the current process taking pthread affinity
226
- * into account, but we don't attempt that here. Perhaps we should?
227
- */
228
-
229
- #endif /*G_OS_UNIX*/
230
-
231
- #ifdef G_OS_WIN32
232
- {
233
- /* Count the CPUs currently available to this process.
234
- */
235
- SYSTEM_INFO sysinfo ;
236
- DWORD_PTR process_cpus ;
237
- DWORD_PTR system_cpus ;
238
-
239
- /* This *never* fails, use it as fallback
240
- */
241
- GetNativeSystemInfo (& sysinfo );
242
- nproc = (int ) sysinfo .dwNumberOfProcessors ;
243
-
244
- if (GetProcessAffinityMask (GetCurrentProcess (),
245
- & process_cpus , & system_cpus )) {
246
- unsigned int af_count ;
247
-
248
- for (af_count = 0 ; process_cpus != 0 ; process_cpus >>= 1 )
249
- if (process_cpus & 1 )
250
- af_count ++ ;
251
-
252
- /* Prefer affinity-based result, if available
253
- */
254
- if (af_count > 0 )
255
- nproc = af_count ;
256
- }
257
- }
258
- #endif /*G_OS_WIN32*/
259
-
260
- return nproc ;
261
- #endif /*!GLIB_CHECK_VERSION(2, 48, 1)*/
262
- }
263
-
264
185
/* The default concurrency, set by the environment variable VIPS_CONCURRENCY,
265
186
* or if that is not set, the number of threads available on the host machine.
266
187
*/
@@ -284,7 +205,7 @@ vips__concurrency_get_default(void)
284
205
(x = atoi (str )) > 0 )
285
206
nthr = x ;
286
207
else
287
- nthr = get_num_processors ();
208
+ nthr = g_get_num_processors ();
288
209
289
210
if (nthr < 1 ||
290
211
nthr > MAX_THREADS ) {
0 commit comments