dotgnu-pnet-commits
[Top][All Lists]
Advanced

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

[dotgnu-pnet-commits] [SCM] DotGNU Portable.NET engine, compilers and to


From: Klaus Treichel
Subject: [dotgnu-pnet-commits] [SCM] DotGNU Portable.NET engine, compilers and tools (pnet) branch, master, updated. 3baf94734d8dc3fdabba68a8891e67a43ed6c4bd
Date: Wed, 15 Jun 2011 06:35:19 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "DotGNU Portable.NET engine, compilers and tools (pnet)".

The branch, master has been updated
       via  3baf94734d8dc3fdabba68a8891e67a43ed6c4bd (commit)
      from  2df493e8c0f5e8076e4d4136bced60842c154aa8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/pnet.git/commit/?id=3baf94734d8dc3fdabba68a8891e67a43ed6c4bd

commit 3baf94734d8dc3fdabba68a8891e67a43ed6c4bd
Author: Klaus Treichel <address@hidden>
Date:   Wed Jun 15 08:34:45 2011 +0200

    Use a constant -1 file descriptor if mmap is used to map anonymous memory
    (MAP_ANON or MAP_ANONYMOUS is defined).

diff --git a/ChangeLog b/ChangeLog
index ddbaefe..446abd4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-06-15  Klaus Treichel  <address@hidden>
+
+       * support/allocate.c (PageInit, ILPageAlloc): Use a constant -1 file
+       descriptor if MAP_ANON (or MAP_ANONYMOUS) is defined.
+
 2011-06-13  Klaus Treichel  <address@hidden>
 
        * support/pt_defs.c (_ILThreadSuspendUntinResumed): Clear 
resumeRequested
diff --git a/support/allocate.c b/support/allocate.c
index ca0507d..eee4600 100644
--- a/support/allocate.c
+++ b/support/allocate.c
@@ -255,9 +255,7 @@ unsigned long ILPageMapSize(void)
  * may not exist on some variants of Unix.
  */
 #ifndef MAP_ANON
-    #ifndef MAP_ANONYMOUS
-        #define MAP_ANON        0
-    #else
+    #ifdef MAP_ANONYMOUS
         #define MAP_ANON        MAP_ANONYMOUS
     #endif
 #endif
@@ -274,6 +272,20 @@ static void PageInit(void)
 {
 #ifndef IL_MEMUSAGE_DEBUG
        void *addr;
+#ifdef MAP_ANON
+       addr = mmap((void *)0, ILPageAllocSize(),
+                               PROT_READ | PROT_WRITE | PROT_EXEC,
+                               MAP_PRIVATE | MAP_ANON, -1, 0);
+       if(addr == (void *)(-1))
+       {
+               zero_fd = -1;
+       }
+       else
+       {
+               munmap(addr, ILPageAllocSize());
+               zero_fd = 0;
+       }
+#else /* !MAP_ANON */
        zero_fd = open("/dev/zero", O_RDWR, 0);
        if(zero_fd != -1)
        {
@@ -284,7 +296,7 @@ static void PageInit(void)
                   is actually live and working on this platform */
                addr = mmap((void *)0, ILPageAllocSize(),
                                    PROT_READ | PROT_WRITE | PROT_EXEC,
-                                   MAP_SHARED | MAP_ANON, zero_fd, 0);
+                                   MAP_SHARED, zero_fd, 0);
                if(addr == (void *)(-1))
                {
                        close(zero_fd);
@@ -295,6 +307,7 @@ static void PageInit(void)
                        munmap(addr, ILPageAllocSize());
                }
        }
+#endif /* !MAP_ANON */
 #endif
 }
 
@@ -311,9 +324,15 @@ void *ILPageAlloc(unsigned long size)
        /* Determine if we can should mmap or calloc */
        if(zero_fd != -1)
        {
+       #ifdef MAP_ANON
                void *addr = mmap((void *)0, size,
                                                  PROT_READ | PROT_WRITE | 
PROT_EXEC,
-                                                 MAP_SHARED | MAP_ANON, 
zero_fd, 0);
+                                                 MAP_PRIVATE | MAP_ANON, -1, 
0);
+       #else
+               void *addr = mmap((void *)0, size,
+                                                 PROT_READ | PROT_WRITE | 
PROT_EXEC,
+                                                 MAP_SHARED, zero_fd, 0);
+       #endif
                if(addr == (void *)(-1))
                {
                        /* The allocation failed */

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog          |    5 +++++
 support/allocate.c |   29 ++++++++++++++++++++++++-----
 2 files changed, 29 insertions(+), 5 deletions(-)


hooks/post-receive
-- 
DotGNU Portable.NET engine, compilers and tools (pnet)



reply via email to

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