0002-memfd-wrappers-only-define-memfd_create-if-not-alrea.patch 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. From dfb0460fb4743aec047cdf755a660a9ac2d0f3fb Mon Sep 17 00:00:00 2001
  2. From: Tanu Kaskinen <tanuk@iki.fi>
  3. Date: Wed, 24 Jan 2018 03:51:49 +0200
  4. Subject: [PATCH] memfd-wrappers: only define memfd_create() if not already
  5. defined
  6. glibc 2.27 is to be released soon, and it will provide memfd_create().
  7. If glibc provides the function, we must not define it ourselves,
  8. otherwise building fails due to conflict between the two implementations
  9. of the same function.
  10. BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=104733
  11. Signed-off-by: Romain Naour <romain.naour@gmail.com>
  12. ---
  13. configure.ac | 3 +++
  14. src/pulsecore/memfd-wrappers.h | 7 ++++---
  15. 2 files changed, 7 insertions(+), 3 deletions(-)
  16. diff --git a/configure.ac b/configure.ac
  17. index 0084c86e..0eb44b08 100644
  18. --- a/configure.ac
  19. +++ b/configure.ac
  20. @@ -610,6 +610,9 @@ AS_IF([test "x$enable_memfd" = "xyes" && test "x$HAVE_MEMFD" = "x0"],
  21. [AC_MSG_ERROR([*** Your Linux kernel does not support memfd shared memory.
  22. *** Use linux v3.17 or higher for such a feature.])])
  23. +AS_IF([test "x$HAVE_MEMFD" = "x1"],
  24. + AC_CHECK_FUNCS([memfd_create]))
  25. +
  26. AC_SUBST(HAVE_MEMFD)
  27. AM_CONDITIONAL([HAVE_MEMFD], [test "x$HAVE_MEMFD" = x1])
  28. AS_IF([test "x$HAVE_MEMFD" = "x1"], AC_DEFINE([HAVE_MEMFD], 1, [Have memfd shared memory.]))
  29. diff --git a/src/pulsecore/memfd-wrappers.h b/src/pulsecore/memfd-wrappers.h
  30. index 3bed9b2b..c7aadfd3 100644
  31. --- a/src/pulsecore/memfd-wrappers.h
  32. +++ b/src/pulsecore/memfd-wrappers.h
  33. @@ -20,13 +20,14 @@
  34. License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
  35. ***/
  36. -#ifdef HAVE_MEMFD
  37. +#if defined(HAVE_MEMFD) && !defined(HAVE_MEMFD_CREATE)
  38. #include <sys/syscall.h>
  39. #include <fcntl.h>
  40. /*
  41. - * No glibc wrappers exist for memfd_create(2), so provide our own.
  42. + * Before glibc version 2.27 there was no wrapper for memfd_create(2),
  43. + * so we have to provide our own.
  44. *
  45. * Also define memfd fcntl sealing macros. While they are already
  46. * defined in the kernel header file <linux/fcntl.h>, that file as
  47. @@ -63,6 +64,6 @@ static inline int memfd_create(const char *name, unsigned int flags) {
  48. #define F_SEAL_WRITE 0x0008 /* prevent writes */
  49. #endif
  50. -#endif /* HAVE_MEMFD */
  51. +#endif /* HAVE_MEMFD && !HAVE_MEMFD_CREATE */
  52. #endif
  53. --
  54. 2.14.3