Module: libav Branch: master Commit: bcc73960657538f601dc90076e30df3cc6032569
Author: Janne Grunau <[email protected]> Committer: Janne Grunau <[email protected]> Date: Sat Dec 24 00:27:12 2011 +0100 threads: add sysconf based number of CPUs detection Can act as fallback and should work on a couple of Unix systems. --- configure | 2 ++ libavcodec/pthread.c | 7 +++++++ 2 files changed, 9 insertions(+), 0 deletions(-) diff --git a/configure b/configure index 413c02f..b7f0acd 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 73d96fc..400abf4 100644 --- a/libavcodec/pthread.c +++ b/libavcodec/pthread.c @@ -45,6 +45,9 @@ #include <sys/types.h> #include <sys/sysctl.h> #endif +#if HAVE_SYSCONF +#include <unistd.h> +#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); _______________________________________________ libav-commits mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-commits
