Re: [Mesa-dev] [PATCH] move pthread_setaffinity_np check to the build system
Quoting Emil Velikov (2018-09-20 02:43:37) > On 13 September 2018 at 19:41, Dylan Baker 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 > > Cc: Emil Velikov > > --- > > 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 > > +int main() { > > + void *a = (void*) _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" If you want to push such a patch with my a-b please do, I've already pushed this as-is. Dylan signature.asc Description: signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] move pthread_setaffinity_np check to the build system
On 13 September 2018 at 19:41, Dylan Baker 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 > Cc: Emil Velikov > --- > 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 > +int main() { > + void *a = (void*) _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 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] move pthread_setaffinity_np check to the build system
Quoting Eric Engestrom (2018-09-14 09:39:27) > On Thursday, 2018-09-13 11:41:38 -0700, Dylan Baker 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\u0161ák > > Cc: Emil Velikov > > --- > > 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 > > +int main() { > > + void *a = (void*) _setaffinity_np; > > + long b = (long) a; > > + return (int) b; > > +}]])], > > + [DEFINES="$DEFINES -DPTHREAD_SETAFFINITY"]; > > -DHAVE_PTHREAD_SETAFFINITY > > With that, and assuming the AC_LINK test code is correct: I just copied the code that meson generates, lol. I'm not really sure that link is required, it would probably work to just compile it. > Reviewed-by: Eric Engestrom > > > + AC_MSG_RESULT([yes]), > > + AC_MSG_RESULT([no])) > > +LIBS="$save_LIBS" > > + > > dnl Check for futex for fast inline simple_mtx_t. > > AC_CHECK_HEADER([linux/futex.h], [DEFINES="$DEFINES -DHAVE_LINUX_FUTEX_H"]) > > > > diff --git a/meson.build b/meson.build > > index 0d534b9b4a9..0588ebf8e7a 100644 > > --- a/meson.build > > +++ b/meson.build > > @@ -1070,6 +1070,13 @@ pre_args += '-DHAVE_ZLIB' > > dep_thread = dependency('threads') > > if dep_thread.found() and host_machine.system() != 'windows' > >pre_args += '-DHAVE_PTHREAD' > > + if cc.has_function( > > + 'pthread_setaffinity_np', > > + dependencies : dep_thread, > > + prefix : '#include ', > > + args : '-D_GNU_SOURCE') > > +pre_args += '-DHAVE_PTHREAD_SETAFFINITY' > > + endif > > endif > > if with_amd_vk or with_gallium_radeonsi or with_gallium_r600 or > > with_gallium_opencl > >dep_elf = dependency('libelf', required : false) > > diff --git a/src/util/u_thread.h b/src/util/u_thread.h > > index eee6f3c712d..7538d7d634b 100644 > > --- a/src/util/u_thread.h > > +++ b/src/util/u_thread.h > > @@ -36,10 +36,6 @@ > > #include > > #endif > > > > -#if defined(HAVE_PTHREAD) && !defined(ANDROID) && !defined(__APPLE__) > > -#define HAVE_PTHREAD_SETAFFINITY > > -#endif > > - > > static inline thrd_t u_thread_create(int (*routine)(void *), void *param) > > { > > thrd_t thread; > > -- > > 2.19.0 > > > > ___ > > mesa-dev mailing list > > mesa-dev@lists.freedesktop.org > > https://lists.freedesktop.org/mailman/listinfo/mesa-dev signature.asc Description: signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] move pthread_setaffinity_np check to the build system
Quoting Dylan Baker (2018-09-13 11:41:38) > 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\u0161ák > Cc: Emil Velikov > --- > 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 > +int main() { > + void *a = (void*) _setaffinity_np; > + long b = (long) a; > + return (int) b; > +}]])], > + [DEFINES="$DEFINES -DPTHREAD_SETAFFINITY"]; This should be -DHAVE_PTHREAD_SETAFFINITY, I've fixed this locally > + AC_MSG_RESULT([yes]), > + AC_MSG_RESULT([no])) > +LIBS="$save_LIBS" > + > dnl Check for futex for fast inline simple_mtx_t. > AC_CHECK_HEADER([linux/futex.h], [DEFINES="$DEFINES -DHAVE_LINUX_FUTEX_H"]) > > diff --git a/meson.build b/meson.build > index 0d534b9b4a9..0588ebf8e7a 100644 > --- a/meson.build > +++ b/meson.build > @@ -1070,6 +1070,13 @@ pre_args += '-DHAVE_ZLIB' > dep_thread = dependency('threads') > if dep_thread.found() and host_machine.system() != 'windows' >pre_args += '-DHAVE_PTHREAD' > + if cc.has_function( > + 'pthread_setaffinity_np', > + dependencies : dep_thread, > + prefix : '#include ', > + args : '-D_GNU_SOURCE') > +pre_args += '-DHAVE_PTHREAD_SETAFFINITY' > + endif > endif > if with_amd_vk or with_gallium_radeonsi or with_gallium_r600 or > with_gallium_opencl >dep_elf = dependency('libelf', required : false) > diff --git a/src/util/u_thread.h b/src/util/u_thread.h > index eee6f3c712d..7538d7d634b 100644 > --- a/src/util/u_thread.h > +++ b/src/util/u_thread.h > @@ -36,10 +36,6 @@ > #include > #endif > > -#if defined(HAVE_PTHREAD) && !defined(ANDROID) && !defined(__APPLE__) > -#define HAVE_PTHREAD_SETAFFINITY > -#endif > - > static inline thrd_t u_thread_create(int (*routine)(void *), void *param) > { > thrd_t thread; > -- > 2.19.0 > signature.asc Description: signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] move pthread_setaffinity_np check to the build system
On Thursday, 2018-09-13 11:41:38 -0700, Dylan Baker 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 > Cc: Emil Velikov > --- > 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 > +int main() { > + void *a = (void*) _setaffinity_np; > + long b = (long) a; > + return (int) b; > +}]])], > + [DEFINES="$DEFINES -DPTHREAD_SETAFFINITY"]; -DHAVE_PTHREAD_SETAFFINITY With that, and assuming the AC_LINK test code is correct: Reviewed-by: Eric Engestrom > + AC_MSG_RESULT([yes]), > + AC_MSG_RESULT([no])) > +LIBS="$save_LIBS" > + > dnl Check for futex for fast inline simple_mtx_t. > AC_CHECK_HEADER([linux/futex.h], [DEFINES="$DEFINES -DHAVE_LINUX_FUTEX_H"]) > > diff --git a/meson.build b/meson.build > index 0d534b9b4a9..0588ebf8e7a 100644 > --- a/meson.build > +++ b/meson.build > @@ -1070,6 +1070,13 @@ pre_args += '-DHAVE_ZLIB' > dep_thread = dependency('threads') > if dep_thread.found() and host_machine.system() != 'windows' >pre_args += '-DHAVE_PTHREAD' > + if cc.has_function( > + 'pthread_setaffinity_np', > + dependencies : dep_thread, > + prefix : '#include ', > + args : '-D_GNU_SOURCE') > +pre_args += '-DHAVE_PTHREAD_SETAFFINITY' > + endif > endif > if with_amd_vk or with_gallium_radeonsi or with_gallium_r600 or > with_gallium_opencl >dep_elf = dependency('libelf', required : false) > diff --git a/src/util/u_thread.h b/src/util/u_thread.h > index eee6f3c712d..7538d7d634b 100644 > --- a/src/util/u_thread.h > +++ b/src/util/u_thread.h > @@ -36,10 +36,6 @@ > #include > #endif > > -#if defined(HAVE_PTHREAD) && !defined(ANDROID) && !defined(__APPLE__) > -#define HAVE_PTHREAD_SETAFFINITY > -#endif > - > static inline thrd_t u_thread_create(int (*routine)(void *), void *param) > { > thrd_t thread; > -- > 2.19.0 > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] move pthread_setaffinity_np check to the build system
Reviewed-by: Marek Olšák Marek On Thu, Sep 13, 2018 at 2:41 PM, Dylan Baker 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 > Cc: Emil Velikov > --- > 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 > +int main() { > + void *a = (void*) _setaffinity_np; > + long b = (long) a; > + return (int) b; > +}]])], > + [DEFINES="$DEFINES -DPTHREAD_SETAFFINITY"]; > + AC_MSG_RESULT([yes]), > + AC_MSG_RESULT([no])) > +LIBS="$save_LIBS" > + > dnl Check for futex for fast inline simple_mtx_t. > AC_CHECK_HEADER([linux/futex.h], [DEFINES="$DEFINES -DHAVE_LINUX_FUTEX_H"]) > > diff --git a/meson.build b/meson.build > index 0d534b9b4a9..0588ebf8e7a 100644 > --- a/meson.build > +++ b/meson.build > @@ -1070,6 +1070,13 @@ pre_args += '-DHAVE_ZLIB' > dep_thread = dependency('threads') > if dep_thread.found() and host_machine.system() != 'windows' >pre_args += '-DHAVE_PTHREAD' > + if cc.has_function( > + 'pthread_setaffinity_np', > + dependencies : dep_thread, > + prefix : '#include ', > + args : '-D_GNU_SOURCE') > +pre_args += '-DHAVE_PTHREAD_SETAFFINITY' > + endif > endif > if with_amd_vk or with_gallium_radeonsi or with_gallium_r600 or > with_gallium_opencl >dep_elf = dependency('libelf', required : false) > diff --git a/src/util/u_thread.h b/src/util/u_thread.h > index eee6f3c712d..7538d7d634b 100644 > --- a/src/util/u_thread.h > +++ b/src/util/u_thread.h > @@ -36,10 +36,6 @@ > #include > #endif > > -#if defined(HAVE_PTHREAD) && !defined(ANDROID) && !defined(__APPLE__) > -#define HAVE_PTHREAD_SETAFFINITY > -#endif > - > static inline thrd_t u_thread_create(int (*routine)(void *), void *param) > { > thrd_t thread; > -- > 2.19.0 > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] move pthread_setaffinity_np check to the build system
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 Cc: Emil Velikov --- 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 +int main() { + void *a = (void*) _setaffinity_np; + long b = (long) a; + return (int) b; +}]])], + [DEFINES="$DEFINES -DPTHREAD_SETAFFINITY"]; + AC_MSG_RESULT([yes]), + AC_MSG_RESULT([no])) +LIBS="$save_LIBS" + dnl Check for futex for fast inline simple_mtx_t. AC_CHECK_HEADER([linux/futex.h], [DEFINES="$DEFINES -DHAVE_LINUX_FUTEX_H"]) diff --git a/meson.build b/meson.build index 0d534b9b4a9..0588ebf8e7a 100644 --- a/meson.build +++ b/meson.build @@ -1070,6 +1070,13 @@ pre_args += '-DHAVE_ZLIB' dep_thread = dependency('threads') if dep_thread.found() and host_machine.system() != 'windows' pre_args += '-DHAVE_PTHREAD' + if cc.has_function( + 'pthread_setaffinity_np', + dependencies : dep_thread, + prefix : '#include ', + args : '-D_GNU_SOURCE') +pre_args += '-DHAVE_PTHREAD_SETAFFINITY' + endif endif if with_amd_vk or with_gallium_radeonsi or with_gallium_r600 or with_gallium_opencl dep_elf = dependency('libelf', required : false) diff --git a/src/util/u_thread.h b/src/util/u_thread.h index eee6f3c712d..7538d7d634b 100644 --- a/src/util/u_thread.h +++ b/src/util/u_thread.h @@ -36,10 +36,6 @@ #include #endif -#if defined(HAVE_PTHREAD) && !defined(ANDROID) && !defined(__APPLE__) -#define HAVE_PTHREAD_SETAFFINITY -#endif - static inline thrd_t u_thread_create(int (*routine)(void *), void *param) { thrd_t thread; -- 2.19.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev