[pulseaudio-commits] r1296 - /trunk/src/pulsecore/shm.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Sat Aug 19 10:27:29 PDT 2006


Author: lennart
Date: Sat Aug 19 19:27:27 2006
New Revision: 1296

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1296&root=pulseaudio&view=rev
Log:
if MAP_ANONYMOUS is not supported use posix_memalign if possible to allocate the memory pool

Modified:
    trunk/src/pulsecore/shm.c

Modified: trunk/src/pulsecore/shm.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/shm.c?rev=1296&root=pulseaudio&r1=1295&r2=1296&view=diff
==============================================================================
--- trunk/src/pulsecore/shm.c (original)
+++ trunk/src/pulsecore/shm.c Sat Aug 19 19:27:27 2006
@@ -19,6 +19,10 @@
   USA.
 ***/
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <assert.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -32,6 +36,7 @@
 #include <pulsecore/core-error.h>
 #include <pulsecore/log.h>
 #include <pulsecore/random.h>
+#include <pulse/xmalloc.h>
 
 #include "shm.h"
 
@@ -64,6 +69,15 @@
             pa_log("mmap() failed: %s", pa_cstrerror(errno));
             goto fail;
         }
+#elif defined(HAVE_POSIX_MEMALIGN)
+        {
+            int r;
+            
+            if ((r = posix_memalign(&m->ptr, sysconf(_SC_PAGESIZE), size)) < 0) {
+                pa_log("posix_memalign() failed: %s", pa_cstrerror(r));
+                goto fail;
+            }
+        }
 #else
         m->ptr = pa_xmalloc(m->size);
 #endif
@@ -114,7 +128,11 @@
     assert(m->ptr && m->ptr != MAP_FAILED);
     assert(m->size > 0);
 
-#ifndef MAP_ANONYMOUS
+#if !defined(MAP_ANONYMOUS) && defined(HAVE_POSIX_MEMALIGN)
+    if (!m->shared)
+        free(m->ptr);
+    else
+#elif !defined(MAP_ANONYMOUS)
     if (!m->shared)
         pa_xfree(m->ptr);
     else
@@ -139,7 +157,6 @@
     assert(m);
     assert(m->ptr && m->ptr != MAP_FAILED);
     assert(m->size > 0);
-    assert(m->do_unlink);
     assert(offset < m->size);
     assert(offset+size < m->size);
 




More information about the pulseaudio-commits mailing list