pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/devel/wayland wayland: Use NetBSD mremap instead of tr...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/d5958f384066
branches:  trunk
changeset: 401041:d5958f384066
user:      nia <nia%pkgsrc.org@localhost>
date:      Mon Sep 09 20:26:58 2019 +0000

description:
wayland: Use NetBSD mremap instead of trying to roll our own. Simpler.

Bump PKGREVISION.

diffstat:

 devel/wayland/Makefile                        |    4 +-
 devel/wayland/distinfo                        |    4 +-
 devel/wayland/patches/patch-src_wayland-shm.c |  147 +------------------------
 3 files changed, 11 insertions(+), 144 deletions(-)

diffs (193 lines):

diff -r f52a5e5c91be -r d5958f384066 devel/wayland/Makefile
--- a/devel/wayland/Makefile    Mon Sep 09 20:08:29 2019 +0000
+++ b/devel/wayland/Makefile    Mon Sep 09 20:26:58 2019 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.3 2019/09/09 20:08:29 nia Exp $
+# $NetBSD: Makefile,v 1.4 2019/09/09 20:26:58 nia Exp $
 
 DISTNAME=      wayland-1.17.0
-PKGREVISION=   2
+PKGREVISION=   3
 CATEGORIES=    devel
 MASTER_SITES=  https://wayland.freedesktop.org/releases/
 EXTRACT_SUFX=  .tar.xz
diff -r f52a5e5c91be -r d5958f384066 devel/wayland/distinfo
--- a/devel/wayland/distinfo    Mon Sep 09 20:08:29 2019 +0000
+++ b/devel/wayland/distinfo    Mon Sep 09 20:26:58 2019 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.5 2019/09/09 20:08:29 nia Exp $
+$NetBSD: distinfo,v 1.6 2019/09/09 20:26:58 nia Exp $
 
 SHA1 (wayland-1.17.0.tar.xz) = 4d9e08a7a4a07fa37a25d7aa3ef83f08edec0600
 RMD160 (wayland-1.17.0.tar.xz) = 635494fb0f5d9eb1e782f98e08c3e0e26ff44268
@@ -12,7 +12,7 @@
 SHA1 (patch-src_wayland-os.c) = 7297f8259aea9603a7ba20fe58f79e3fd0042990
 SHA1 (patch-src_wayland-os.h) = 1e01dfadb5ed5889d76e024d30537935f33631a3
 SHA1 (patch-src_wayland-server.c) = 335de8f5390eb337dfbde26f523162bd44c06baf
-SHA1 (patch-src_wayland-shm.c) = a59ddce3a161bb21fedb04737ff502da608b1da9
+SHA1 (patch-src_wayland-shm.c) = 694232eac180f1a6a31c96f9ac98cb0b5a016d20
 SHA1 (patch-tests_client-test.c) = 6ffe18dfd64176a92f6f795eb757c54a3cf0ad10
 SHA1 (patch-tests_connection-test.c) = af53116c99cbb8d6570bcec66bfd895c1ae01700
 SHA1 (patch-tests_event-loop-test.c) = 79909fdce7b73a7b19c58d3711329f6288fe7204
diff -r f52a5e5c91be -r d5958f384066 devel/wayland/patches/patch-src_wayland-shm.c
--- a/devel/wayland/patches/patch-src_wayland-shm.c     Mon Sep 09 20:08:29 2019 +0000
+++ b/devel/wayland/patches/patch-src_wayland-shm.c     Mon Sep 09 20:26:58 2019 +0000
@@ -1,151 +1,18 @@
-$NetBSD: patch-src_wayland-shm.c,v 1.1 2019/08/18 16:05:12 nia Exp $
+$NetBSD: patch-src_wayland-shm.c,v 1.2 2019/09/09 20:26:58 nia Exp $
 
-BSD support from FreeBSD
+Support NetBSD-style mremap.
 
 --- src/wayland-shm.c.orig     2019-03-21 00:55:25.000000000 +0000
 +++ src/wayland-shm.c
-@@ -30,6 +30,8 @@
- 
- #define _GNU_SOURCE
- 
-+#include "../config.h"
-+
- #include <stdbool.h>
- #include <stdio.h>
- #include <stdlib.h>
-@@ -59,6 +61,9 @@ struct wl_shm_pool {
-       char *data;
-       int32_t size;
-       int32_t new_size;
-+#ifdef HAVE_SYS_UCRED_H
-+      int fd;
-+#endif
- };
- 
- struct wl_shm_buffer {
-@@ -76,15 +81,24 @@ struct wl_shm_sigbus_data {
-       int fallback_mapping_used;
- };
- 
-+static void *mremap_compat_maymove(void *, size_t, size_t, int, int, int);
-+
- static void
- shm_pool_finish_resize(struct wl_shm_pool *pool)
- {
-       void *data;
-+      int fd = -1;
- 
+@@ -84,7 +84,11 @@ shm_pool_finish_resize(struct wl_shm_poo
        if (pool->size == pool->new_size)
                return;
  
--      data = mremap(pool->data, pool->size, pool->new_size, MREMAP_MAYMOVE);
-+#ifdef HAVE_SYS_UCRED_H
-+      fd = pool->fd;
++#ifdef __NetBSD__
++      data = mremap(pool->data, pool->size, NULL, pool->new_size, 0);
++#else
+       data = mremap(pool->data, pool->size, pool->new_size, MREMAP_MAYMOVE);
 +#endif
-+
-+      data = mremap_compat_maymove(pool->data, pool->size, pool->new_size,
-+                                   PROT_READ | PROT_WRITE, MAP_SHARED, fd);
-+
        if (data == MAP_FAILED) {
                wl_resource_post_error(pool->resource,
                                       WL_SHM_ERROR_INVALID_FD,
-@@ -110,6 +124,10 @@ shm_pool_unref(struct wl_shm_pool *pool,
-       if (pool->internal_refcount + pool->external_refcount)
-               return;
- 
-+#ifdef HAVE_SYS_UCRED_H
-+      close(pool->fd);
-+#endif
-+
-       munmap(pool->data, pool->size);
-       free(pool);
- }
-@@ -223,6 +241,73 @@ shm_pool_destroy(struct wl_client *clien
-       wl_resource_destroy(resource);
- }
- 
-+#ifdef HAVE_MREMAP
-+static void *
-+mremap_compat_maymove(void *old_address, size_t old_size, size_t new_size,
-+                    int old_prot, int old_flags, int old_fd)
-+{
-+      return mremap(old_address, old_size, new_size, MREMAP_MAYMOVE);
-+}
-+#else
-+static void *
-+mremap_compat_maymove(void *old_address, size_t old_size, size_t new_size,
-+                    int old_prot, int old_flags, int old_fd)
-+{
-+      /* FreeBSD doesn't support mremap() yet, so we have to emulate it.
-+       * This assumes MREMAP_MAYMOVE is the only flag in use. */
-+      if (new_size == old_size) {
-+              return old_address;
-+      } else if (new_size < old_size) {
-+              /* Shrinking: munmap() the spare region. */
-+              munmap(old_address + old_size, new_size - old_size);
-+              return old_address;
-+      } else {
-+              void *ret;
-+
-+              /* Growing. Try and mmap() the extra region at the end of
-+               * our existing allocation. If that gets mapped in the
-+               * wrong place, fall back to mmap()ing an entirely new
-+               * region of new_size and copying the data across. */
-+              ret = mmap(old_address + old_size, new_size - old_size,
-+                         old_prot, old_flags, old_fd, 0);
-+
-+/* FIXME TODO: msync() before munmap()? */
-+              if (ret == MAP_FAILED) {
-+                      /* Total failure! */
-+                      return ret;
-+              } else if (ret == old_address + old_size) {
-+                      /* Success. */
-+                      return old_address;
-+              } else if (ret != old_address + old_size) {
-+                      /* Partial failure. Fall back to mapping an
-+                       * entirely new region. Unmap the region we
-+                       * just mapped first. */
-+                      munmap(ret, new_size - old_size);
-+
-+                      /* Map an entirely new region. */
-+                      ret = mmap(NULL, new_size,
-+                                 old_prot, old_flags, old_fd, 0);
-+                      if (ret == MAP_FAILED) {
-+                              /* Total failure! */
-+                              return ret;
-+                      }
-+
-+                      /* Copy the old data across. Implicit assumption
-+                       * that the old and new regions don't overlap. */
-+                      memcpy(ret, old_address, old_size);
-+
-+                      /* Unmap the old region. */
-+                      munmap(old_address, old_size);
-+
-+                      return ret;
-+              }
-+      }
-+
-+      /* Unreachable. */
-+      return MAP_FAILED;
-+}
-+#endif
-+
- static void
- shm_pool_resize(struct wl_client *client, struct wl_resource *resource,
-               int32_t size)
-@@ -284,7 +369,14 @@ shm_create_pool(struct wl_client *client
-                                      "failed mmap fd %d: %m", fd);
-               goto err_free;
-       }
-+
-+#ifdef HAVE_SYS_UCRED_H
-+      /* We need to keep the FD around on FreeBSD so we can implement
-+       * mremap(). See: mremap_compat_maymove(). */
-+      pool->fd = fd;
-+#else
-       close(fd);
-+#endif
- 
-       pool->resource =
-               wl_resource_create(client, &wl_shm_pool_interface, 1, id);



Home | Main Index | Thread Index | Old Index