[Mesa-dev] [PATCH] anv: Check if memfd_create is already defined.
Eric Engestrom
eric.engestrom at imgtec.com
Wed Nov 29 14:53:23 UTC 2017
On Wednesday, 2017-11-29 07:29:40 +0000, Vinson Lee wrote:
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103909
> Signed-off-by: Vinson Lee <vlee at freedesktop.org>
> ---
> configure.ac | 1 +
> meson.build | 2 +-
> src/intel/vulkan/anv_allocator.c | 2 ++
> src/intel/vulkan/anv_gem_stubs.c | 2 ++
> 4 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/configure.ac b/configure.ac
> index 1344c12884fb..f378e54b857b 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -849,6 +849,7 @@ AC_CHECK_HEADER([sys/sysctl.h], [DEFINES="$DEFINES -DHAVE_SYS_SYSCTL_H"])
> AC_CHECK_FUNC([strtof], [DEFINES="$DEFINES -DHAVE_STRTOF"])
> AC_CHECK_FUNC([mkostemp], [DEFINES="$DEFINES -DHAVE_MKOSTEMP"])
> AC_CHECK_FUNC([timespec_get], [DEFINES="$DEFINES -DHAVE_TIMESPEC_GET"])
> +AC_CHECK_FUNC([memfd_create], [DEFINES="$DEFINES -DHAVE_MEMFD_CREATE"])
>
> AC_MSG_CHECKING([whether strtod has locale support])
> AC_LINK_IFELSE([AC_LANG_SOURCE([[
> diff --git a/meson.build b/meson.build
> index e2ba3cb05245..4a2e817f0fa4 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -617,7 +617,7 @@ foreach h : ['xlocale.h', 'sys/sysctl.h', 'linux/futex.h']
> endif
> endforeach
>
> -foreach f : ['strtof', 'mkostemp', 'posix_memalign', 'timespec_get']
> +foreach f : ['strtof', 'mkostemp', 'posix_memalign', 'timespec_get', 'memfd_create']
> if cc.has_function(f)
> pre_args += '-DHAVE_ at 0@'.format(f.to_upper())
> endif
Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>
If scons can also compile anv (I don't know scons enough to know that),
then it needs the same check:
----8<----
diff --git a/scons/gallium.py b/scons/gallium.py
index ef3b2ee81ae233b8807f..a1fd615f0724ff6cc01a 100755
--- a/scons/gallium.py
+++ b/scons/gallium.py
@@ -358,6 +358,9 @@ def generate(env):
if check_functions(env, ['timespec_get']):
cppdefines += ['HAVE_TIMESPEC_GET']
+ if check_functions(env, ['memfd_create']):
+ cppdefines += ['HAVE_MEMFD_CREATE']
+
if platform == 'windows':
cppdefines += [
'WIN32',
---->8----
> diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c
> index 8ed32b3c6731..33bd3c68c55f 100644
> --- a/src/intel/vulkan/anv_allocator.c
> +++ b/src/intel/vulkan/anv_allocator.c
> @@ -109,11 +109,13 @@ struct anv_mmap_cleanup {
>
> #define ANV_MMAP_CLEANUP_INIT ((struct anv_mmap_cleanup){0})
>
> +#ifndef HAVE_MEMFD_CREATE
> static inline int
> memfd_create(const char *name, unsigned int flags)
> {
> return syscall(SYS_memfd_create, name, flags);
> }
> +#endif
>
> static inline uint32_t
> ilog2_round_up(uint32_t value)
> diff --git a/src/intel/vulkan/anv_gem_stubs.c b/src/intel/vulkan/anv_gem_stubs.c
> index 02527b5fcd8d..26eb5c8a610b 100644
> --- a/src/intel/vulkan/anv_gem_stubs.c
> +++ b/src/intel/vulkan/anv_gem_stubs.c
> @@ -27,11 +27,13 @@
>
> #include "anv_private.h"
>
> +#ifndef HAVE_MEMFD_CREATE
> static inline int
> memfd_create(const char *name, unsigned int flags)
> {
> return syscall(SYS_memfd_create, name, flags);
> }
> +#endif
>
> uint32_t
> anv_gem_create(struct anv_device *device, uint64_t size)
> --
> 2.15.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list