emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] pdumper 131d65b 2/6: Use mmap retry on Cygwin too


From: Daniel Colascione
Subject: [Emacs-diffs] pdumper 131d65b 2/6: Use mmap retry on Cygwin too
Date: Mon, 19 Feb 2018 12:02:50 -0500 (EST)

branch: pdumper
commit 131d65b3e8b0d32ffd685249d58fd656cdbc2080
Author: Daniel Colascione <address@hidden>
Commit: Daniel Colascione <address@hidden>

    Use mmap retry on Cygwin too
---
 src/pdumper.c | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/src/pdumper.c b/src/pdumper.c
index dfcf33e..9a0770d 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -172,7 +172,7 @@ ptrdiff_t_to_dump_off (ptrdiff_t value)
 static int
 dump_get_page_size (void)
 {
-#ifdef WINDOWSNT
+#if defined (WINDOWSNT) || defined (CYGWIN)
   return 64 * 1024;  /* Worst-case allocation granularity.  */
 #else
   return getpagesize ();
@@ -4502,6 +4502,16 @@ dump_mmap_release_vm (struct dump_memory_map *map)
 }
 
 static bool
+needs_mmap_retry_p (void)
+{
+#if defined (CYGWIN) || VM_SUPPORTED == VM_MS_WINDOWS
+  return true;
+#else
+  return false;
+#endif
+}
+
+static bool
 dump_mmap_contiguous_vm (
   struct dump_memory_map *maps,
   int nr_maps,
@@ -4510,12 +4520,13 @@ dump_mmap_contiguous_vm (
   bool ret = false;
   void *resv = NULL;
   bool retry = false;
+  const bool need_retry = needs_mmap_retry_p ();
 
   do
     {
       if (retry)
         {
-          eassert (VM_SUPPORTED == VM_MS_WINDOWS);
+          eassert (need_retry);
           retry = false;
           for (int i = 0; i < nr_maps; ++i)
             dump_mmap_release (&maps[i]);
@@ -4530,7 +4541,7 @@ dump_mmap_contiguous_vm (
 
       char *mem = resv;
 
-      if (VM_SUPPORTED == VM_MS_WINDOWS)
+      if (need_retry)
         {
           /* Windows lacks atomic mapping replace; need to release the
              reservation so we can allocate within it.  Will retry the
@@ -4555,9 +4566,13 @@ dump_mmap_contiguous_vm (
             map->mapping = dump_map_file (
               mem, spec.fd, spec.offset, spec.size, spec.protection);
           mem += spec.size;
-          if (VM_SUPPORTED == VM_MS_WINDOWS &&
+          if (need_retry &&
               map->mapping == NULL &&
-              errno == EBUSY)
+              (errno == EBUSY
+#ifdef CYGWIN
+               || errno == EINVAL
+#endif
+               ))
             {
               retry = true;
               continue;
@@ -4578,7 +4593,7 @@ dump_mmap_contiguous_vm (
     {
       for (int i = 0; i < nr_maps; ++i)
        {
-         if (VM_SUPPORTED == VM_MS_WINDOWS)
+         if (need_retry)
            dump_mmap_reset (&maps[i]);
          else
            dump_mmap_release (&maps[i]);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]