# New Ticket Created by  Nick Glencross 
# Please include the string:  [perl #37479]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=37479 >


Guys,

This patch fixes a problem caused by a difference in the behaviour of
mmap on HP-UX which was mentioned a few days back as affecting
eval_12.pir:

mmap does not seem to allow multiple calls with MAP_SHARED on the same
file, and will return ENOMEM after the first call. What this change
does is fallback to attempting a private mmap if the preferred shared
one fails.

Regards,

Nick
This patches will allow eval_12.pir to pass on HP-UX.

Index: src/embed.c
===================================================================
--- src/embed.c (revision 9509)
+++ src/embed.c (working copy)
@@ -370,7 +370,14 @@
         program_code =
             mmap(0, program_size, PROT_READ, MAP_SHARED, fd, (off_t)0);
 
+        /* On HP-UX mmap does not work multiple times on the same file, so
+           try a private mmap before giving up on it */
         if (program_code == (void *)MAP_FAILED) {
+            program_code =
+                mmap(0, program_size, PROT_READ, MAP_PRIVATE, fd, (off_t)0);
+        }
+
+        if (program_code == (void *)MAP_FAILED) {
             Parrot_warn(interpreter, PARROT_WARNINGS_IO_FLAG,
                     "Parrot VM: Can't mmap file %s, code %i.\n",
                     fullname, errno);

Reply via email to