[Mesa-dev] [PATCH] move pthread_setaffinity_np check to the build system

Emil Velikov emil.l.velikov at gmail.com
Thu Sep 20 09:43:37 UTC 2018


On 13 September 2018 at 19:41, Dylan Baker <dylan at pnwbakers.com> wrote:
> Rather than trying to encode all of the rules in a header, lets just put
> them in the build system where they belong. This fixes the build on
> FreeBSD, which does have pthraed_setaffinity_np, but it's in a
> pthread_np.h, not behind _GNU_SOURCE. FreeBSD also implements cpu_set
> slightly differently, so additional changes would be required to get it
> working right there anyway.
>
> Fixes: 9f1bbbdbbd77d346c74c7abbb31f399151a85713
>        ("util: try to fix the Android and MacOS build")
> Cc: Marek Olšák <maraeo at gmail.com>
> Cc: Emil Velikov <emil.velikov at collabora.com>
> ---
>  configure.ac        | 16 ++++++++++++++++
>  meson.build         |  7 +++++++
>  src/util/u_thread.h |  4 ----
>  3 files changed, 23 insertions(+), 4 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index f8bb131cb63..d10236dbead 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -968,6 +968,22 @@ if test "x$pthread_stubs_possible" = xyes; then
>      PKG_CHECK_MODULES(PTHREADSTUBS, pthread-stubs >= 0.4)
>  fi
>
> +save_LIBS="$LIBS"
> +LIBS="$PTHREAD_LIBS"
> +AC_MSG_CHECKING(whether pthread_setaffinity_np is supported)
> +AC_LINK_IFELSE([AC_LANG_SOURCE([[
> +    #define _GNU_SOURCE
> +    #include <pthread.h>
> +    int main() {
> +       void *a = (void*) &pthread_setaffinity_np;
> +       long b = (long) a;
> +       return (int) b;
> +    }]])],
> +  [DEFINES="$DEFINES -DPTHREAD_SETAFFINITY"];
> +   AC_MSG_RESULT([yes]),
> +   AC_MSG_RESULT([no]))
> +LIBS="$save_LIBS"
> +
Just like meson's have_function there is AC_CHECK_FUNCS - which will
also set the HAVE_$(function_name)

So a quick:
1) sed to use the correct define -
s/HAVE_PTHREAD_SETAFFINITY/HAVE_PTHREAD_SETAFFINITY_NP/
2) and following 4 lines should do it

save_LIBS="$LIBS"
LIBS="$PTHREAD_LIBS"
AC_CHECK_FUNCS([pthread_setaffinity_np])
LIBS="$save_LIBS"

Thanks
Emil


More information about the mesa-dev mailing list