branch-updates.diff 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. diff --git a/Makefile.am b/Makefile.am
  2. index 670cdcb..1d7043b 100644
  3. --- a/Makefile.am
  4. +++ b/Makefile.am
  5. @@ -25,7 +25,7 @@ SUBDIRS = src test
  6. pkgconfigdir = $(libdir)/pkgconfig
  7. pkgconfig_DATA = xshmfence.pc
  8. -EXTRA_DIST = xshmfence.pc.in ChangeLog
  9. +EXTRA_DIST = xshmfence.pc.in ChangeLog README.md
  10. MAINTAINERCLEANFILES = ChangeLog
  11. .PHONY: ChangeLog
  12. diff --git a/README b/README.md
  13. similarity index 56%
  14. rename from README
  15. rename to README.md
  16. index db193b7..748fe8a 100644
  17. --- a/README
  18. +++ b/README.md
  19. @@ -1,4 +1,5 @@
  20. libxshmfence - Shared memory 'SyncFence' synchronization primitive
  21. +------------------------------------------------------------------
  22. This library offers a CPU-based synchronization primitive compatible
  23. with the X SyncFence objects that can be shared between processes
  24. @@ -14,23 +15,15 @@ There are two underlying implementations:
  25. All questions regarding this software should be directed at the
  26. Xorg mailing list:
  27. - http://lists.freedesktop.org/mailman/listinfo/xorg
  28. -
  29. -Please submit bug reports to the Xorg bugzilla:
  30. -
  31. - https://bugs.freedesktop.org/enter_bug.cgi?product=xorg
  32. + https://lists.x.org/mailman/listinfo/xorg
  33. The master development code repository can be found at:
  34. - git://anongit.freedesktop.org/git/xorg/lib/libxshmfence
  35. + https://gitlab.freedesktop.org/xorg/lib/libxshmfence
  36. - http://cgit.freedesktop.org/xorg/lib/libxshmfence
  37. +Please submit bug reports and requests to merge patches there.
  38. For patch submission instructions, see:
  39. - http://www.x.org/wiki/Development/Documentation/SubmittingPatches
  40. -
  41. -For more information on the git code manager, see:
  42. -
  43. - http://wiki.x.org/wiki/GitPage
  44. + https://www.x.org/wiki/Development/Documentation/SubmittingPatches
  45. diff --git a/configure.ac b/configure.ac
  46. index 8afe7a6..5636cb8 100644
  47. --- a/configure.ac
  48. +++ b/configure.ac
  49. @@ -24,7 +24,7 @@ dnl Process this file with autoconf to create configure.
  50. AC_PREREQ([2.60])
  51. AC_INIT([libxshmfence], [1.3],
  52. - [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libxshmfence])
  53. + [https://gitlab.freedesktop.org/xorg/lib/libxshmfence/issues], [libxshmfence])
  54. AC_CONFIG_SRCDIR([Makefile.am])
  55. AC_CONFIG_HEADERS([config.h])
  56. @@ -91,7 +91,7 @@ AC_SUBST([XPROTO_CFLAGS])
  57. CFLAGS="$CFLAGS $XPROTO_CFLAGS"
  58. -AC_CHECK_FUNCS(memfd_create)
  59. +AC_CHECK_FUNCS(memfd_create mkostemp)
  60. AC_CHECK_DECLS([__NR_memfd_create], [], [], [[#include <asm/unistd.h>]])
  61. diff --git a/src/xshmfence_alloc.c b/src/xshmfence_alloc.c
  62. index 05cf953..932adb9 100644
  63. --- a/src/xshmfence_alloc.c
  64. +++ b/src/xshmfence_alloc.c
  65. @@ -26,6 +26,8 @@
  66. #include "xshmfenceint.h"
  67. +#include <fcntl.h>
  68. +
  69. #if !HAVE_MEMFD_CREATE
  70. #if HAVE_DECL___NR_MEMFD_CREATE
  71. #include <asm/unistd.h>
  72. @@ -68,10 +70,17 @@ xshmfence_alloc_shm(void)
  73. {
  74. char template[] = SHMDIR "/shmfd-XXXXXX";
  75. int fd;
  76. +#ifndef HAVE_MKOSTEMP
  77. + int flags;
  78. +#endif
  79. #if HAVE_MEMFD_CREATE
  80. fd = memfd_create("xshmfence", MFD_CLOEXEC|MFD_ALLOW_SEALING);
  81. if (fd < 0)
  82. +#endif
  83. +#ifdef SHM_ANON
  84. + fd = shm_open(SHM_ANON, O_RDWR|O_CLOEXEC, 0600);
  85. + if (fd < 0)
  86. #endif
  87. {
  88. #ifdef O_TMPFILE
  89. @@ -79,10 +88,21 @@ xshmfence_alloc_shm(void)
  90. if (fd < 0)
  91. #endif
  92. {
  93. +#ifdef HAVE_MKOSTEMP
  94. + fd = mkostemp(template, O_CLOEXEC);
  95. +#else
  96. fd = mkstemp(template);
  97. +#endif
  98. if (fd < 0)
  99. return fd;
  100. unlink(template);
  101. +#ifndef HAVE_MKOSTEMP
  102. + flags = fcntl(fd, F_GETFD);
  103. + if (flags != -1) {
  104. + flags |= FD_CLOEXEC;
  105. + fcntl(fd, F_SETFD, &flags);
  106. + }
  107. +#endif
  108. }
  109. }
  110. if (ftruncate(fd, sizeof (struct xshmfence)) < 0) {