diff --git a/configure b/configure index 413c02fae8..b7f0acdc0a 100755 --- a/configure +++ b/configure @@ -1138,6 +1138,7 @@ HAVE_LIST=" symver symver_asm_label symver_gnu_asm + sysconf sysctl sys_mman_h sys_param_h @@ -2858,6 +2859,7 @@ check_func strerror_r check_func strptime check_func strtok_r check_func sched_getaffinity +check_func sysconf check_func sysctl check_func_headers io.h setmode check_func_headers lzo/lzo1x.h lzo1x_999_compress diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c index 73d96fca1a..400abf4f6c 100644 --- a/libavcodec/pthread.c +++ b/libavcodec/pthread.c @@ -45,6 +45,9 @@ #include #include #endif +#if HAVE_SYSCONF +#include +#endif #include "avcodec.h" #include "internal.h" @@ -177,6 +180,10 @@ static int get_logical_cpus(AVCodecContext *avctx) ret = sysctl(mib, 2, &nb_cpus, &len, NULL, 0); if (ret == -1) nb_cpus = 0; +#elif HAVE_SYSCONF && defined(_SC_NPROC_ONLN) + nb_cpus = sysconf(_SC_NPROC_ONLN); +#elif HAVE_SYSCONF && defined(_SC_NPROCESSORS_ONLN) + nb_cpus = sysconf(_SC_NPROCESSORS_ONLN); #endif av_log(avctx, AV_LOG_DEBUG, "detected %d logical cores\n", nb_cpus); return FFMIN(nb_cpus, MAX_AUTO_THREADS);