can you add a description like i did in eina_mempool.h, please ? Vincent
On Mon, 26 Jul 2010, Enlightenment SVN wrote: > Log: > * eina: add a mempool that just do one big malloc. > > Author: cedric > Date: 2010-07-26 08:52:43 -0700 (Mon, 26 Jul 2010) > New Revision: 50510 > > Modified: > trunk/eina/configure.ac trunk/eina/src/include/eina_mempool.h > trunk/eina/src/lib/Makefile.am trunk/eina/src/lib/eina_mempool.c > trunk/eina/src/lib/eina_stringshare.c trunk/eina/src/modules/mp/Makefile.am > trunk/eina/src/modules/mp/chained_pool/eina_chained_mempool.c > trunk/eina/src/modules/mp/fixed_bitmap/eina_fixed_bitmap.c > > Modified: trunk/eina/configure.ac > =================================================================== > --- trunk/eina/configure.ac 2010-07-26 09:31:40 UTC (rev 50509) > +++ trunk/eina/configure.ac 2010-07-26 15:52:43 UTC (rev 50510) > @@ -496,14 +496,16 @@ > enable_pass_through="no" > fi > > +enable_one_big="static" > + > EINA_CHECK_MODULE([chained-pool], [${enable_chained_pool}], [chained pool]) > EINA_CHECK_MODULE([ememoa-fixed], [${enable_ememoa}], [ememoa fixed]) > EINA_CHECK_MODULE([ememoa-unknown], [${enable_ememoa}], [ememoa > unknown]) > EINA_CHECK_MODULE([fixed-bitmap], [no], [fixed bitmap]) > EINA_CHECK_MODULE([pass-through], [${enable_pass_through}], [pass through]) > EINA_CHECK_MODULE([buddy], [no], [buddy]) > +EINA_CHECK_MODULE([one-big], [${enable_one_big}], [one big]) > > - > ### Make the debug preprocessor configurable > > ### Unit tests, coverage and benchmarking > @@ -555,6 +557,7 @@ > src/modules/mp/pass_through/Makefile > src/modules/mp/fixed_bitmap/Makefile > src/modules/mp/buddy/Makefile > +src/modules/mp/one_big/Makefile > src/tests/Makefile > ]) > > > Modified: trunk/eina/src/include/eina_mempool.h > =================================================================== > --- trunk/eina/src/include/eina_mempool.h 2010-07-26 09:31:40 UTC (rev > 50509) > +++ trunk/eina/src/include/eina_mempool.h 2010-07-26 15:52:43 UTC (rev > 50510) > @@ -62,6 +62,8 @@ > EAPI Eina_Bool eina_mempool_register(Eina_Mempool_Backend *be) > EINA_ARG_NONNULL(1); > EAPI void eina_mempool_unregister(Eina_Mempool_Backend *be) > EINA_ARG_NONNULL(1); > > +EAPI unsigned int eina_mempool_alignof(unsigned int size); > + > #include "eina_inline_mempool.x" > > /** > > Modified: trunk/eina/src/lib/Makefile.am > =================================================================== > --- trunk/eina/src/lib/Makefile.am 2010-07-26 09:31:40 UTC (rev 50509) > +++ trunk/eina/src/lib/Makefile.am 2010-07-26 15:52:43 UTC (rev 50510) > @@ -45,6 +45,10 @@ > base_sources += > $(top_srcdir)/src/modules/mp/chained_pool/eina_chained_mempool.c > endif > > +if EINA_STATIC_BUILD_ONE_BIG > +base_sources += $(top_srcdir)/src/modules/mp/one_big/eina_one_big.c > +endif > + > if EINA_STATIC_BUILD_EMEMOA_FIXED > base_sources += $(top_srcdir)/src/modules/mp/ememoa_fixed/eina_ememoa_fixed.c > endif > > Modified: trunk/eina/src/lib/eina_mempool.c > =================================================================== > --- trunk/eina/src/lib/eina_mempool.c 2010-07-26 09:31:40 UTC (rev 50509) > +++ trunk/eina/src/lib/eina_mempool.c 2010-07-26 15:52:43 UTC (rev 50510) > @@ -118,6 +118,11 @@ > void buddy_shutdown(void); > #endif > > +#ifdef EINA_STATIC_BUILD_ONE_BIG > +Eina_Bool one_big_init(void); > +void one_big_shutdown(void); > +#endif > + > /** > * @endcond > */ > @@ -211,6 +216,9 @@ > #ifdef EINA_STATIC_BUILD_BUDDY > buddy_init(); > #endif > +#ifdef EINA_STATIC_BUILD_ONE_BIG > + one_big_init(); > +#endif > > return EINA_TRUE; > > @@ -243,6 +251,9 @@ > #ifdef EINA_STATIC_BUILD_BUDDY > buddy_shutdown(); > #endif > +#ifdef EINA_STATIC_BUILD_ONE_BIG > + one_big_shutdown(); > +#endif > /* dynamic backends */ > eina_module_list_free(_modules); > if (_modules) > @@ -339,6 +350,28 @@ > mp->backend.statistics(mp->backend_data); > } > > +EAPI unsigned int > +eina_mempool_alignof(unsigned int size) > +{ > + int align; > + > + if (size <= 2) > + align = 2; > + else if (size < 8) > + align = 4; > + else > +#if __WORDSIZE == 32 > + align = 8; > +#else > + if (size < 16) > + align = 8; > + else > + align = 16; > +#endif > + > + return ((size / align) + 1) * align; > +} > + > /** > * @} > */ > > Modified: trunk/eina/src/lib/eina_stringshare.c > =================================================================== > --- trunk/eina/src/lib/eina_stringshare.c 2010-07-26 09:31:40 UTC (rev > 50509) > +++ trunk/eina/src/lib/eina_stringshare.c 2010-07-26 15:52:43 UTC (rev > 50510) > @@ -68,6 +68,7 @@ > # include "config.h" > #endif > > +#define _GNU_SOURCE > #include <stdlib.h> > #include <stdio.h> > #include <string.h> > > Modified: trunk/eina/src/modules/mp/Makefile.am > =================================================================== > --- trunk/eina/src/modules/mp/Makefile.am 2010-07-26 09:31:40 UTC (rev > 50509) > +++ trunk/eina/src/modules/mp/Makefile.am 2010-07-26 15:52:43 UTC (rev > 50510) > @@ -1,4 +1,10 @@ > -SUBDIRS = chained_pool ememoa_fixed pass_through ememoa_unknown fixed_bitmap > buddy > +SUBDIRS = chained_pool \ > + ememoa_fixed \ > + pass_through \ > + ememoa_unknown \ > + fixed_bitmap \ > + buddy \ > + one_big > > MAINTAINERCLEANFILES = \ > Makefile.in > > Modified: trunk/eina/src/modules/mp/chained_pool/eina_chained_mempool.c > =================================================================== > --- trunk/eina/src/modules/mp/chained_pool/eina_chained_mempool.c > 2010-07-26 09:31:40 UTC (rev 50509) > +++ trunk/eina/src/modules/mp/chained_pool/eina_chained_mempool.c > 2010-07-26 15:52:43 UTC (rev 50510) > @@ -2,7 +2,7 @@ > * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 > */ > /* EINA - EFL data type library > - * Copyright (C) 2008 Cedric BAIL > + * Copyright (C) 2008-2010 Cedric BAIL, Vincent Torri > * > * This library is free software; you can redistribute it and/or > * modify it under the terms of the GNU Lesser General Public > @@ -61,6 +61,7 @@ > Eina_Inlist *first; > const char *name; > int item_size; > + int item_alloc; > int pool_size; > int usage; > #ifdef EFL_HAVE_THREADS > @@ -85,14 +86,20 @@ > { > Chained_Pool *p; > unsigned char *ptr; > - int item_alloc, i; > + int i; > > - item_alloc = ((pool->item_size + sizeof(void *) - 1) / sizeof(void *)) * > sizeof(void *); > - p = malloc(sizeof(Chained_Pool) + (pool->pool_size * item_alloc)); > + eina_error_set(0); > + p = malloc(sizeof(Chained_Pool) + (pool->pool_size * pool->item_alloc)); > + if (!p) > + { > + eina_error_set(EINA_ERROR_OUT_OF_MEMORY); > + return NULL; > + } > + > ptr = (unsigned char *) (p + 1); > p->usage = 0; > p->base = NULL; > - for (i = 0; i < pool->pool_size; ++i, ptr += item_alloc) > + for (i = 0; i < pool->pool_size; ++i, ptr += pool->item_alloc) > eina_trash_push(&p->base, ptr); > return p; > } > @@ -249,6 +256,8 @@ > memcpy((char*) mp->name, context, length); > } > > + mp->item_alloc = eina_mempool_alignof(mp->item_size); > + > #ifdef EFL_HAVE_THREADS > # ifdef EFL_HAVE_POSIX_THREADS > pthread_mutex_init(&mp->mutex, NULL); > > Modified: trunk/eina/src/modules/mp/fixed_bitmap/eina_fixed_bitmap.c > =================================================================== > --- trunk/eina/src/modules/mp/fixed_bitmap/eina_fixed_bitmap.c > 2010-07-26 09:31:40 UTC (rev 50509) > +++ trunk/eina/src/modules/mp/fixed_bitmap/eina_fixed_bitmap.c > 2010-07-26 15:52:43 UTC (rev 50510) > @@ -185,11 +185,15 @@ > eina_fixed_bitmap_init(__UNUSED__ const char *context, __UNUSED__ const char > *option, va_list args) > { > Eina_Fixed_Bitmap *mp; > + int item_size; > > mp = malloc(sizeof (Eina_Fixed_Bitmap)); > if (!mp) return NULL; > > - mp->item_size = va_arg(args, int); > + item_size = va_arg(args, int); > + > + mp->item_size = eina_mempool_alignof(item_size); > + > mp->lookup = NULL; > mp->head = NULL; > > > > ------------------------------------------------------------------------------ > The Palm PDK Hot Apps Program offers developers who use the > Plug-In Development Kit to bring their C/C++ apps to Palm for a share > of $1 Million in cash or HP Products. Visit us here for more details: > http://ad.doubleclick.net/clk;226879339;13503038;l? > http://clk.atdmt.com/CRS/go/247765532/direct/01/ > _______________________________________________ > enlightenment-svn mailing list > enlightenment-...@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/enlightenment-svn > > ------------------------------------------------------------------------------ The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://p.sf.net/sfu/dev2dev-palm _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel