Skip to content

Commit 57b7b9e

Browse files
authored
Remove a couple of redundant GLib version guards (libvips#3680)
The minimum required GLib version was raised to 2.52, making these guards unnecessary.
1 parent 0789614 commit 57b7b9e

File tree

3 files changed

+1
-97
lines changed

3 files changed

+1
-97
lines changed

libvips/foreign/pforeign.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,6 @@
3535
extern "C" {
3636
#endif /*__cplusplus*/
3737

38-
/* Slow and horrid version if there's no recent glib.
39-
*/
40-
#if !GLIB_CHECK_VERSION(2, 48, 0)
41-
#define g_uint_checked_mul(dest, a, b) ( \
42-
((guint64) a * b) > UINT_MAX \
43-
? (*dest = UINT_MAX, FALSE) \
44-
: (*dest = a * b, TRUE))
45-
#endif /*!GLIB_CHECK_VERSION(2, 48, 0)*/
46-
4738
/* We've seen real images with 28 chunks, so set 50.
4839
*/
4940
#define MAX_PNG_TEXT_CHUNKS 50

libvips/iofuncs/init.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -489,14 +489,6 @@ vips_init(const char *argv0)
489489
vips__buffer_init();
490490
vips__meta_init();
491491

492-
/* This does an unsynchronised static hash table init on first call --
493-
* we have to make sure we do this single-threaded. See:
494-
* https://github.com/openslide/openslide/issues/161
495-
*/
496-
#if !GLIB_CHECK_VERSION(2, 48, 1)
497-
(void) g_get_language_names();
498-
#endif
499-
500492
if (!vips__global_lock)
501493
vips__global_lock = vips_g_mutex_new();
502494

libvips/iofuncs/thread.c

Lines changed: 1 addition & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -182,85 +182,6 @@ vips_g_thread_new(const char *domain, GThreadFunc func, gpointer data)
182182
return thread;
183183
}
184184

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-
264185
/* The default concurrency, set by the environment variable VIPS_CONCURRENCY,
265186
* or if that is not set, the number of threads available on the host machine.
266187
*/
@@ -284,7 +205,7 @@ vips__concurrency_get_default(void)
284205
(x = atoi(str)) > 0)
285206
nthr = x;
286207
else
287-
nthr = get_num_processors();
208+
nthr = g_get_num_processors();
288209

289210
if (nthr < 1 ||
290211
nthr > MAX_THREADS) {

0 commit comments

Comments
 (0)