[x264-devel] [PATCH] CPU_COUNT only appeared in glibc 2.6

Jason Garrett-Glaser jason at x264.com
Tue Aug 9 08:04:33 CEST 2011


On Mon, Aug 8, 2011 at 10:57 PM, Rafaël Carré <rafael.carre at gmail.com> wrote:
> ---
>  Hi,
>
>  this patch should fix compilation with ancient glibc
>
>  common/cpu.c |   12 +++++++++++-
>  1 files changed, 11 insertions(+), 1 deletions(-)
>
> diff --git a/common/cpu.c b/common/cpu.c
> index 6185782..59d9724 100644
> --- a/common/cpu.c
> +++ b/common/cpu.c
> @@ -366,7 +366,17 @@ int x264_cpu_num_processors( void )
>
>  #elif SYS_LINUX
>     cpu_set_t p_aff;
> -    return sched_getaffinity( 0, sizeof(p_aff), &p_aff ) ? 1 : CPU_COUNT(&p_aff);
> +    if( sched_getaffinity( 0, sizeof(p_aff), &p_aff ) )
> +        return 1;
> +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 6)
> +    return CPU_COUNT(&p_aff);
> +#else
> +    unsigned int bit;
> +    int np;
> +    for( np = 0, bit = 0; bit < sizeof(p_aff); bit++ )
> +        np += (((uint8_t *)&p_aff)[bit / 8] >> (bit % 8)) & 1;
> +    return np;
> +#endif /* GLIBC */
>
>  #elif SYS_BEOS
>     system_info info;
> --
> 1.7.5.4

This is fixed in github already and will be in the next release.

Jason


More information about the x264-devel mailing list