From f8d299c399312fdd41958843a101db36353ad8e2 Mon Sep 17 00:00:00 2001 From: Michael Vrhel Date: Wed, 22 Feb 2017 08:11:48 -0800 Subject: Avoid getenv call in openjpeg getenv is not allowed in certain cases causing linking issues. This fix should be pushed to the openjpeg group. Thanks to Chris for the fix. --- openjpeg/src/lib/openjp2/j2k.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'openjpeg') diff --git a/openjpeg/src/lib/openjp2/j2k.c b/openjpeg/src/lib/openjp2/j2k.c index 7c0696838..e689213ce 100644 --- a/openjpeg/src/lib/openjp2/j2k.c +++ b/openjpeg/src/lib/openjp2/j2k.c @@ -5983,12 +5983,16 @@ OPJ_BOOL opj_j2k_set_threads(opj_j2k_t *j2k, OPJ_UINT32 num_threads) static int opj_j2k_get_default_thread_count(void) { +#if defined(MUTEX_win32) || defined(MUTEX_pthread) const char* num_threads = getenv("OPJ_NUM_THREADS"); - if( num_threads == NULL || !opj_has_thread_support() ) + if (num_threads == NULL || !opj_has_thread_support()) return 0; - if( strcmp(num_threads, "ALL_CPUS") == 0 ) + if (strcmp(num_threads, "ALL_CPUS") == 0) return opj_get_num_cpus(); return atoi(num_threads); +#else + return 0; +#endif } /* ----------------------------------------------------------------------- */ -- cgit v1.2.1