summaryrefslogtreecommitdiff
path: root/src/modules/eina
diff options
context:
space:
mode:
authorCedric Bail <cedric.bail@free.fr>2013-04-04 22:54:12 +0900
committerCedric Bail <cedric.bail@free.fr>2013-04-04 23:50:14 +0900
commitfa8c46945331959c40aed1f9a4b5a1fc47e9ad75 (patch)
tree1f846b4a3a2dd7196ba69f7f8e55a79465bc7640 /src/modules/eina
parentd26f78813f7fc39acfb0b4c099e01aeb6983bf89 (diff)
eina: align allocated memory to 4096.
Diffstat (limited to 'src/modules/eina')
-rw-r--r--src/modules/eina/mp/chained_pool/eina_chained_mempool.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/modules/eina/mp/chained_pool/eina_chained_mempool.c b/src/modules/eina/mp/chained_pool/eina_chained_mempool.c
index 9c7ea5636c..68e7a03411 100644
--- a/src/modules/eina/mp/chained_pool/eina_chained_mempool.c
+++ b/src/modules/eina/mp/chained_pool/eina_chained_mempool.c
@@ -65,6 +65,8 @@ static int _eina_chained_mp_log_dom = -1;
65 65
66#endif 66#endif
67 67
68static int aligned_chained_pool = 0;
69
68typedef struct _Chained_Mempool Chained_Mempool; 70typedef struct _Chained_Mempool Chained_Mempool;
69struct _Chained_Mempool 71struct _Chained_Mempool
70{ 72{
@@ -151,7 +153,7 @@ _eina_chained_mp_pool_new(Chained_Mempool *pool)
151 p->limit = ptr + pool->item_alloc * pool->pool_size; 153 p->limit = ptr + pool->item_alloc * pool->pool_size;
152 154
153#ifndef NVALGRIND 155#ifndef NVALGRIND
154 VALGRIND_MAKE_MEM_NOACCESS(ptr, pool->alloc_size - eina_mempool_alignof(sizeof(Chained_Pool))); 156 VALGRIND_MAKE_MEM_NOACCESS(ptr, pool->alloc_size - aligned_chained_pool);
155#endif 157#endif
156 158
157 return p; 159 return p;
@@ -469,13 +471,18 @@ eina_chained_mempool_init(const char *context,
469 memcpy((char *)mp->name, context, length); 471 memcpy((char *)mp->name, context, length);
470 } 472 }
471 473
474 mp->item_alloc = eina_mempool_alignof(item_size);
475
476 mp->pool_size = (((((mp->item_alloc * mp->pool_size + aligned_chained_pool) / 4096)
477 + 1) * 4096)
478 - aligned_chained_pool) / mp->item_alloc;
479
472#ifdef EINA_DEBUG_MALLOC 480#ifdef EINA_DEBUG_MALLOC
473 mp->minimal_size = item_size * mp->pool_size + sizeof(Chained_Pool); 481 mp->minimal_size = item_size * mp->pool_size + sizeof(Chained_Pool);
474#endif 482#endif
475 483
476 mp->item_alloc = eina_mempool_alignof(item_size);
477 mp->group_size = mp->item_alloc * mp->pool_size; 484 mp->group_size = mp->item_alloc * mp->pool_size;
478 mp->alloc_size = mp->group_size + eina_mempool_alignof(sizeof(Chained_Pool)); 485 mp->alloc_size = mp->group_size + aligned_chained_pool;
479 486
480#ifndef NVALGRIND 487#ifndef NVALGRIND
481 VALGRIND_CREATE_MEMPOOL(mp, 0, 1); 488 VALGRIND_CREATE_MEMPOOL(mp, 0, 1);
@@ -556,6 +563,8 @@ Eina_Bool chained_init(void)
556 } 563 }
557 564
558#endif 565#endif
566 aligned_chained_pool = eina_mempool_alignof(sizeof(Chained_Pool));
567
559 return eina_mempool_register(&_eina_chained_mp_backend); 568 return eina_mempool_register(&_eina_chained_mp_backend);
560} 569}
561 570