urcu-bp: use mremap
authorMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Thu, 1 Oct 2009 22:12:20 +0000 (18:12 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Thu, 1 Oct 2009 22:12:20 +0000 (18:12 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
urcu-bp.c

index 0fdf1f44ffa10bb46e15429bdff59356af9167eb..9c3dbe7e15ef210b5da7c9d7638796207ad041c7 100644 (file)
--- a/urcu-bp.c
+++ b/urcu-bp.c
@@ -23,6 +23,7 @@
  * IBM's contributions to this file may be relicensed under LGPLv2 or later.
  */
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <pthread.h>
 #include <signal.h>
@@ -265,10 +266,16 @@ static void resize_arena(struct registry_arena *arena, size_t len)
 {
        void *new_arena;
 
-       new_arena = mmap(arena->p, len,
-                        PROT_READ | PROT_WRITE,
-                        MAP_ANONYMOUS | MAP_PRIVATE,
-                        -1, 0);
+       if (!arena->p)
+               new_arena = mmap(arena->p, len,
+                                PROT_READ | PROT_WRITE,
+                                MAP_ANONYMOUS | MAP_PRIVATE,
+                                -1, 0);
+       else
+               new_arena = mremap(arena->p, arena->len,
+                                  len, MREMAP_MAYMOVE);
+       assert(new_arena != MAP_FAILED);
+
        /*
         * re-used the same region ?
         */
This page took 0.035451 seconds and 4 git commands to generate.