aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/eina/src/modules/mp/chained_pool
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-01-04 18:41:13 +1000
committerDavid Walter Seikel2012-01-04 18:41:13 +1000
commitdd7595a3475407a7fa96a97393bae8c5220e8762 (patch)
treee341e911d7eb911a51684a7412ef7f7c7605d28e /libraries/eina/src/modules/mp/chained_pool
parentAdd the skeleton. (diff)
downloadSledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.zip
SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.gz
SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.bz2
SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.xz
Add the base Enlightenment Foundation Libraries - eina, eet, evas, ecore, embryo, and edje.
Note that embryo wont be used, but I'm not sure yet if you can build edje without it.
Diffstat (limited to 'libraries/eina/src/modules/mp/chained_pool')
-rw-r--r--libraries/eina/src/modules/mp/chained_pool/Makefile.am30
-rw-r--r--libraries/eina/src/modules/mp/chained_pool/Makefile.in644
-rw-r--r--libraries/eina/src/modules/mp/chained_pool/eina_chained_mempool.c547
3 files changed, 1221 insertions, 0 deletions
diff --git a/libraries/eina/src/modules/mp/chained_pool/Makefile.am b/libraries/eina/src/modules/mp/chained_pool/Makefile.am
new file mode 100644
index 0000000..815bab7
--- /dev/null
+++ b/libraries/eina/src/modules/mp/chained_pool/Makefile.am
@@ -0,0 +1,30 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3AM_CPPFLAGS = \
4-I. \
5-I$(top_srcdir)/src/include \
6-I$(top_builddir)/src/include \
7-I$(top_srcdir)/src/lib \
8-I$(top_builddir)/src/lib \
9@EINA_CPPFLAGS@ \
10@EFL_EINA_BUILD@ \
11@VALGRIND_CFLAGS@
12
13controllerdir = $(libdir)/eina/modules/mp/chained_pool/$(MODULE_ARCH)
14controller_LTLIBRARIES = module.la
15
16module_la_SOURCES = \
17eina_chained_mempool.c
18
19module_la_CFLAGS = @EINA_CFLAGS@ @EFL_PTHREAD_CFLAGS@
20module_la_LIBADD = $(top_builddir)/src/lib/libeina.la @EINA_LIBS@
21module_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -module -avoid-version @EFL_PTHREAD_LIBS@
22module_la_LIBTOOLFLAGS = --tag=disable-static
23
24install-data-hook:
25 rm -f $(DESTDIR)$(controllerdir)/$(controller_LTLIBRARIES)
26uninstall-hook:
27 rm -f $(DESTDIR)$(controllerdir)/module.*
28
29clean-local:
30 rm -rf *.gcno
diff --git a/libraries/eina/src/modules/mp/chained_pool/Makefile.in b/libraries/eina/src/modules/mp/chained_pool/Makefile.in
new file mode 100644
index 0000000..b728672
--- /dev/null
+++ b/libraries/eina/src/modules/mp/chained_pool/Makefile.in
@@ -0,0 +1,644 @@
1# Makefile.in generated by automake 1.11.1 from Makefile.am.
2# @configure_input@
3
4# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
6# Inc.
7# This Makefile.in is free software; the Free Software Foundation
8# gives unlimited permission to copy and/or distribute it,
9# with or without modifications, as long as this notice is preserved.
10
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
13# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14# PARTICULAR PURPOSE.
15
16@SET_MAKE@
17
18VPATH = @srcdir@
19pkgdatadir = $(datadir)/@PACKAGE@
20pkgincludedir = $(includedir)/@PACKAGE@
21pkglibdir = $(libdir)/@PACKAGE@
22pkglibexecdir = $(libexecdir)/@PACKAGE@
23am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
24install_sh_DATA = $(install_sh) -c -m 644
25install_sh_PROGRAM = $(install_sh) -c
26install_sh_SCRIPT = $(install_sh) -c
27INSTALL_HEADER = $(INSTALL_DATA)
28transform = $(program_transform_name)
29NORMAL_INSTALL = :
30PRE_INSTALL = :
31POST_INSTALL = :
32NORMAL_UNINSTALL = :
33PRE_UNINSTALL = :
34POST_UNINSTALL = :
35build_triplet = @build@
36host_triplet = @host@
37subdir = src/modules/mp/chained_pool
38DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
39ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
40am__aclocal_m4_deps = $(top_srcdir)/m4/efl_attribute.m4 \
41 $(top_srcdir)/m4/efl_benchmark.m4 \
42 $(top_srcdir)/m4/efl_compiler_flag.m4 \
43 $(top_srcdir)/m4/efl_coverage.m4 $(top_srcdir)/m4/efl_cpu.m4 \
44 $(top_srcdir)/m4/efl_doxygen.m4 \
45 $(top_srcdir)/m4/efl_examples.m4 \
46 $(top_srcdir)/m4/efl_fnmatch.m4 \
47 $(top_srcdir)/m4/efl_path_max.m4 $(top_srcdir)/m4/efl_tests.m4 \
48 $(top_srcdir)/m4/efl_threads.m4 \
49 $(top_srcdir)/m4/efl_voltron.m4 $(top_srcdir)/m4/eina_bench.m4 \
50 $(top_srcdir)/m4/eina_check.m4 $(top_srcdir)/m4/libtool.m4 \
51 $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
52 $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
53 $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
54am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
55 $(ACLOCAL_M4)
56mkinstalldirs = $(install_sh) -d
57CONFIG_HEADER = $(top_builddir)/config.h
58CONFIG_CLEAN_FILES =
59CONFIG_CLEAN_VPATH_FILES =
60am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
61am__vpath_adj = case $$p in \
62 $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
63 *) f=$$p;; \
64 esac;
65am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
66am__install_max = 40
67am__nobase_strip_setup = \
68 srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
69am__nobase_strip = \
70 for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
71am__nobase_list = $(am__nobase_strip_setup); \
72 for p in $$list; do echo "$$p $$p"; done | \
73 sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
74 $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
75 if (++n[$$2] == $(am__install_max)) \
76 { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
77 END { for (dir in files) print dir, files[dir] }'
78am__base_list = \
79 sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
80 sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
81am__installdirs = "$(DESTDIR)$(controllerdir)"
82LTLIBRARIES = $(controller_LTLIBRARIES)
83module_la_DEPENDENCIES = $(top_builddir)/src/lib/libeina.la
84am_module_la_OBJECTS = module_la-eina_chained_mempool.lo
85module_la_OBJECTS = $(am_module_la_OBJECTS)
86AM_V_lt = $(am__v_lt_$(V))
87am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
88am__v_lt_0 = --silent
89module_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
90 $(module_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
91 $(module_la_CFLAGS) $(CFLAGS) $(module_la_LDFLAGS) $(LDFLAGS) \
92 -o $@
93DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
94depcomp = $(SHELL) $(top_srcdir)/depcomp
95am__depfiles_maybe = depfiles
96am__mv = mv -f
97COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
98 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
99LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
100 $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
101 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
102 $(AM_CFLAGS) $(CFLAGS)
103AM_V_CC = $(am__v_CC_$(V))
104am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
105am__v_CC_0 = @echo " CC " $@;
106AM_V_at = $(am__v_at_$(V))
107am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
108am__v_at_0 = @
109CCLD = $(CC)
110LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
111 $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
112 $(AM_LDFLAGS) $(LDFLAGS) -o $@
113AM_V_CCLD = $(am__v_CCLD_$(V))
114am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
115am__v_CCLD_0 = @echo " CCLD " $@;
116AM_V_GEN = $(am__v_GEN_$(V))
117am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
118am__v_GEN_0 = @echo " GEN " $@;
119SOURCES = $(module_la_SOURCES)
120DIST_SOURCES = $(module_la_SOURCES)
121ETAGS = etags
122CTAGS = ctags
123DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
124ACLOCAL = @ACLOCAL@
125ALLOCA = @ALLOCA@
126AMTAR = @AMTAR@
127AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
128AR = @AR@
129AS = @AS@
130AUTOCONF = @AUTOCONF@
131AUTOHEADER = @AUTOHEADER@
132AUTOMAKE = @AUTOMAKE@
133AWK = @AWK@
134CC = @CC@
135CCDEPMODE = @CCDEPMODE@
136CFLAGS = @CFLAGS@
137CHECK_CFLAGS = @CHECK_CFLAGS@
138CHECK_LIBS = @CHECK_LIBS@
139CPP = @CPP@
140CPPFLAGS = @CPPFLAGS@
141CXX = @CXX@
142CXXCPP = @CXXCPP@
143CXXDEPMODE = @CXXDEPMODE@
144CXXFLAGS = @CXXFLAGS@
145CYGPATH_W = @CYGPATH_W@
146DEFS = @DEFS@
147DEPDIR = @DEPDIR@
148DLLTOOL = @DLLTOOL@
149DSYMUTIL = @DSYMUTIL@
150DUMPBIN = @DUMPBIN@
151ECHO_C = @ECHO_C@
152ECHO_N = @ECHO_N@
153ECHO_T = @ECHO_T@
154ECORE_EVAS_CFLAGS = @ECORE_EVAS_CFLAGS@
155ECORE_EVAS_LIBS = @ECORE_EVAS_LIBS@
156EFL_COVERAGE_CFLAGS = @EFL_COVERAGE_CFLAGS@
157EFL_COVERAGE_LIBS = @EFL_COVERAGE_LIBS@
158EFL_EINA_BUILD = @EFL_EINA_BUILD@
159EFL_FNMATCH_LIBS = @EFL_FNMATCH_LIBS@
160EFL_PTHREAD_CFLAGS = @EFL_PTHREAD_CFLAGS@
161EFL_PTHREAD_LIBS = @EFL_PTHREAD_LIBS@
162EFL_SIMD_FLAGS = @EFL_SIMD_FLAGS@
163EGREP = @EGREP@
164EINA_CFLAGS = @EINA_CFLAGS@
165EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@
166EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@
167EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@
168EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@
169EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@
170EINA_CONFIGURE_HAVE_THREADS = @EINA_CONFIGURE_HAVE_THREADS@
171EINA_CONFIGURE_MAGIC_DEBUG = @EINA_CONFIGURE_MAGIC_DEBUG@
172EINA_CONFIGURE_SAFETY_CHECKS = @EINA_CONFIGURE_SAFETY_CHECKS@
173EINA_CPPFLAGS = @EINA_CPPFLAGS@
174EINA_LIBS = @EINA_LIBS@
175EINA_SIZEOF_WCHAR_T = @EINA_SIZEOF_WCHAR_T@
176EMEMOA_CFLAGS = @EMEMOA_CFLAGS@
177EMEMOA_LIBS = @EMEMOA_LIBS@
178ESCAPE_CFLAGS = @ESCAPE_CFLAGS@
179ESCAPE_LIBS = @ESCAPE_LIBS@
180EVIL_CFLAGS = @EVIL_CFLAGS@
181EVIL_LIBS = @EVIL_LIBS@
182EXEEXT = @EXEEXT@
183FGREP = @FGREP@
184GLIB_CFLAGS = @GLIB_CFLAGS@
185GLIB_LIBS = @GLIB_LIBS@
186GREP = @GREP@
187INSTALL = @INSTALL@
188INSTALL_DATA = @INSTALL_DATA@
189INSTALL_PROGRAM = @INSTALL_PROGRAM@
190INSTALL_SCRIPT = @INSTALL_SCRIPT@
191INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
192LD = @LD@
193LDFLAGS = @LDFLAGS@
194LIBOBJS = @LIBOBJS@
195LIBS = @LIBS@
196LIBTOOL = @LIBTOOL@
197LIPO = @LIPO@
198LN_S = @LN_S@
199LTLIBOBJS = @LTLIBOBJS@
200MAKEINFO = @MAKEINFO@
201MKDIR_P = @MKDIR_P@
202MODULE_ARCH = @MODULE_ARCH@
203NM = @NM@
204NMEDIT = @NMEDIT@
205OBJDUMP = @OBJDUMP@
206OBJEXT = @OBJEXT@
207OTOOL = @OTOOL@
208OTOOL64 = @OTOOL64@
209PACKAGE = @PACKAGE@
210PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
211PACKAGE_NAME = @PACKAGE_NAME@
212PACKAGE_STRING = @PACKAGE_STRING@
213PACKAGE_TARNAME = @PACKAGE_TARNAME@
214PACKAGE_URL = @PACKAGE_URL@
215PACKAGE_VERSION = @PACKAGE_VERSION@
216PATH_SEPARATOR = @PATH_SEPARATOR@
217PKG_CONFIG = @PKG_CONFIG@
218PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
219PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
220RANLIB = @RANLIB@
221SED = @SED@
222SET_MAKE = @SET_MAKE@
223SHELL = @SHELL@
224STRIP = @STRIP@
225VALGRIND_CFLAGS = @VALGRIND_CFLAGS@
226VALGRIND_LIBS = @VALGRIND_LIBS@
227VERSION = @VERSION@
228VMAJ = @VMAJ@
229abs_builddir = @abs_builddir@
230abs_srcdir = @abs_srcdir@
231abs_top_builddir = @abs_top_builddir@
232abs_top_srcdir = @abs_top_srcdir@
233ac_ct_CC = @ac_ct_CC@
234ac_ct_CXX = @ac_ct_CXX@
235ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
236am__include = @am__include@
237am__leading_dot = @am__leading_dot@
238am__quote = @am__quote@
239am__tar = @am__tar@
240am__untar = @am__untar@
241bindir = @bindir@
242build = @build@
243build_alias = @build_alias@
244build_cpu = @build_cpu@
245build_os = @build_os@
246build_vendor = @build_vendor@
247builddir = @builddir@
248datadir = @datadir@
249datarootdir = @datarootdir@
250dlopen_libs = @dlopen_libs@
251docdir = @docdir@
252dvidir = @dvidir@
253efl_doxygen = @efl_doxygen@
254efl_have_doxygen = @efl_have_doxygen@
255exec_prefix = @exec_prefix@
256have_lcov = @have_lcov@
257host = @host@
258host_alias = @host_alias@
259host_cpu = @host_cpu@
260host_os = @host_os@
261host_vendor = @host_vendor@
262htmldir = @htmldir@
263iconv_libs = @iconv_libs@
264includedir = @includedir@
265infodir = @infodir@
266install_sh = @install_sh@
267libdir = @libdir@
268libexecdir = @libexecdir@
269localedir = @localedir@
270localstatedir = @localstatedir@
271lt_ECHO = @lt_ECHO@
272lt_enable_auto_import = @lt_enable_auto_import@
273mandir = @mandir@
274mkdir_p = @mkdir_p@
275oldincludedir = @oldincludedir@
276pdfdir = @pdfdir@
277pkgconfig_requires_private = @pkgconfig_requires_private@
278prefix = @prefix@
279program_transform_name = @program_transform_name@
280psdir = @psdir@
281release_info = @release_info@
282requirement_eina = @requirement_eina@
283rt_libs = @rt_libs@
284sbindir = @sbindir@
285sharedstatedir = @sharedstatedir@
286srcdir = @srcdir@
287sysconfdir = @sysconfdir@
288target_alias = @target_alias@
289top_build_prefix = @top_build_prefix@
290top_builddir = @top_builddir@
291top_srcdir = @top_srcdir@
292version_info = @version_info@
293MAINTAINERCLEANFILES = Makefile.in
294AM_CPPFLAGS = \
295-I. \
296-I$(top_srcdir)/src/include \
297-I$(top_builddir)/src/include \
298-I$(top_srcdir)/src/lib \
299-I$(top_builddir)/src/lib \
300@EINA_CPPFLAGS@ \
301@EFL_EINA_BUILD@ \
302@VALGRIND_CFLAGS@
303
304controllerdir = $(libdir)/eina/modules/mp/chained_pool/$(MODULE_ARCH)
305controller_LTLIBRARIES = module.la
306module_la_SOURCES = \
307eina_chained_mempool.c
308
309module_la_CFLAGS = @EINA_CFLAGS@ @EFL_PTHREAD_CFLAGS@
310module_la_LIBADD = $(top_builddir)/src/lib/libeina.la @EINA_LIBS@
311module_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -module -avoid-version @EFL_PTHREAD_LIBS@
312module_la_LIBTOOLFLAGS = --tag=disable-static
313all: all-am
314
315.SUFFIXES:
316.SUFFIXES: .c .lo .o .obj
317$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
318 @for dep in $?; do \
319 case '$(am__configure_deps)' in \
320 *$$dep*) \
321 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
322 && { if test -f $@; then exit 0; else break; fi; }; \
323 exit 1;; \
324 esac; \
325 done; \
326 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/modules/mp/chained_pool/Makefile'; \
327 $(am__cd) $(top_srcdir) && \
328 $(AUTOMAKE) --gnu src/modules/mp/chained_pool/Makefile
329.PRECIOUS: Makefile
330Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
331 @case '$?' in \
332 *config.status*) \
333 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
334 *) \
335 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
336 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
337 esac;
338
339$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
340 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
341
342$(top_srcdir)/configure: $(am__configure_deps)
343 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
344$(ACLOCAL_M4): $(am__aclocal_m4_deps)
345 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
346$(am__aclocal_m4_deps):
347install-controllerLTLIBRARIES: $(controller_LTLIBRARIES)
348 @$(NORMAL_INSTALL)
349 test -z "$(controllerdir)" || $(MKDIR_P) "$(DESTDIR)$(controllerdir)"
350 @list='$(controller_LTLIBRARIES)'; test -n "$(controllerdir)" || list=; \
351 list2=; for p in $$list; do \
352 if test -f $$p; then \
353 list2="$$list2 $$p"; \
354 else :; fi; \
355 done; \
356 test -z "$$list2" || { \
357 echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(controllerdir)'"; \
358 $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(controllerdir)"; \
359 }
360
361uninstall-controllerLTLIBRARIES:
362 @$(NORMAL_UNINSTALL)
363 @list='$(controller_LTLIBRARIES)'; test -n "$(controllerdir)" || list=; \
364 for p in $$list; do \
365 $(am__strip_dir) \
366 echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(controllerdir)/$$f'"; \
367 $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(controllerdir)/$$f"; \
368 done
369
370clean-controllerLTLIBRARIES:
371 -test -z "$(controller_LTLIBRARIES)" || rm -f $(controller_LTLIBRARIES)
372 @list='$(controller_LTLIBRARIES)'; for p in $$list; do \
373 dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
374 test "$$dir" != "$$p" || dir=.; \
375 echo "rm -f \"$${dir}/so_locations\""; \
376 rm -f "$${dir}/so_locations"; \
377 done
378module.la: $(module_la_OBJECTS) $(module_la_DEPENDENCIES)
379 $(AM_V_CCLD)$(module_la_LINK) -rpath $(controllerdir) $(module_la_OBJECTS) $(module_la_LIBADD) $(LIBS)
380
381mostlyclean-compile:
382 -rm -f *.$(OBJEXT)
383
384distclean-compile:
385 -rm -f *.tab.c
386
387@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/module_la-eina_chained_mempool.Plo@am__quote@
388
389.c.o:
390@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
391@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
392@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
393@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
394@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
395@am__fastdepCC_FALSE@ $(COMPILE) -c $<
396
397.c.obj:
398@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
399@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
400@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
401@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
402@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
403@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
404
405.c.lo:
406@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
407@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
408@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
409@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
410@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
411@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
412
413module_la-eina_chained_mempool.lo: eina_chained_mempool.c
414@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(module_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(module_la_CFLAGS) $(CFLAGS) -MT module_la-eina_chained_mempool.lo -MD -MP -MF $(DEPDIR)/module_la-eina_chained_mempool.Tpo -c -o module_la-eina_chained_mempool.lo `test -f 'eina_chained_mempool.c' || echo '$(srcdir)/'`eina_chained_mempool.c
415@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/module_la-eina_chained_mempool.Tpo $(DEPDIR)/module_la-eina_chained_mempool.Plo
416@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
417@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='eina_chained_mempool.c' object='module_la-eina_chained_mempool.lo' libtool=yes @AMDEPBACKSLASH@
418@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
419@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(module_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(module_la_CFLAGS) $(CFLAGS) -c -o module_la-eina_chained_mempool.lo `test -f 'eina_chained_mempool.c' || echo '$(srcdir)/'`eina_chained_mempool.c
420
421mostlyclean-libtool:
422 -rm -f *.lo
423
424clean-libtool:
425 -rm -rf .libs _libs
426
427ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
428 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
429 unique=`for i in $$list; do \
430 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
431 done | \
432 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
433 END { if (nonempty) { for (i in files) print i; }; }'`; \
434 mkid -fID $$unique
435tags: TAGS
436
437TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
438 $(TAGS_FILES) $(LISP)
439 set x; \
440 here=`pwd`; \
441 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
442 unique=`for i in $$list; do \
443 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
444 done | \
445 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
446 END { if (nonempty) { for (i in files) print i; }; }'`; \
447 shift; \
448 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
449 test -n "$$unique" || unique=$$empty_fix; \
450 if test $$# -gt 0; then \
451 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
452 "$$@" $$unique; \
453 else \
454 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
455 $$unique; \
456 fi; \
457 fi
458ctags: CTAGS
459CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
460 $(TAGS_FILES) $(LISP)
461 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
462 unique=`for i in $$list; do \
463 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
464 done | \
465 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
466 END { if (nonempty) { for (i in files) print i; }; }'`; \
467 test -z "$(CTAGS_ARGS)$$unique" \
468 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
469 $$unique
470
471GTAGS:
472 here=`$(am__cd) $(top_builddir) && pwd` \
473 && $(am__cd) $(top_srcdir) \
474 && gtags -i $(GTAGS_ARGS) "$$here"
475
476distclean-tags:
477 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
478
479distdir: $(DISTFILES)
480 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
481 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
482 list='$(DISTFILES)'; \
483 dist_files=`for file in $$list; do echo $$file; done | \
484 sed -e "s|^$$srcdirstrip/||;t" \
485 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
486 case $$dist_files in \
487 */*) $(MKDIR_P) `echo "$$dist_files" | \
488 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
489 sort -u` ;; \
490 esac; \
491 for file in $$dist_files; do \
492 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
493 if test -d $$d/$$file; then \
494 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
495 if test -d "$(distdir)/$$file"; then \
496 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
497 fi; \
498 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
499 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
500 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
501 fi; \
502 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
503 else \
504 test -f "$(distdir)/$$file" \
505 || cp -p $$d/$$file "$(distdir)/$$file" \
506 || exit 1; \
507 fi; \
508 done
509check-am: all-am
510check: check-am
511all-am: Makefile $(LTLIBRARIES)
512installdirs:
513 for dir in "$(DESTDIR)$(controllerdir)"; do \
514 test -z "$$dir" || $(MKDIR_P) "$$dir"; \
515 done
516install: install-am
517install-exec: install-exec-am
518install-data: install-data-am
519uninstall: uninstall-am
520
521install-am: all-am
522 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
523
524installcheck: installcheck-am
525install-strip:
526 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
527 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
528 `test -z '$(STRIP)' || \
529 echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
530mostlyclean-generic:
531
532clean-generic:
533
534distclean-generic:
535 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
536 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
537
538maintainer-clean-generic:
539 @echo "This command is intended for maintainers to use"
540 @echo "it deletes files that may require special tools to rebuild."
541 -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
542clean: clean-am
543
544clean-am: clean-controllerLTLIBRARIES clean-generic clean-libtool \
545 clean-local mostlyclean-am
546
547distclean: distclean-am
548 -rm -rf ./$(DEPDIR)
549 -rm -f Makefile
550distclean-am: clean-am distclean-compile distclean-generic \
551 distclean-tags
552
553dvi: dvi-am
554
555dvi-am:
556
557html: html-am
558
559html-am:
560
561info: info-am
562
563info-am:
564
565install-data-am: install-controllerLTLIBRARIES
566 @$(NORMAL_INSTALL)
567 $(MAKE) $(AM_MAKEFLAGS) install-data-hook
568install-dvi: install-dvi-am
569
570install-dvi-am:
571
572install-exec-am:
573
574install-html: install-html-am
575
576install-html-am:
577
578install-info: install-info-am
579
580install-info-am:
581
582install-man:
583
584install-pdf: install-pdf-am
585
586install-pdf-am:
587
588install-ps: install-ps-am
589
590install-ps-am:
591
592installcheck-am:
593
594maintainer-clean: maintainer-clean-am
595 -rm -rf ./$(DEPDIR)
596 -rm -f Makefile
597maintainer-clean-am: distclean-am maintainer-clean-generic
598
599mostlyclean: mostlyclean-am
600
601mostlyclean-am: mostlyclean-compile mostlyclean-generic \
602 mostlyclean-libtool
603
604pdf: pdf-am
605
606pdf-am:
607
608ps: ps-am
609
610ps-am:
611
612uninstall-am: uninstall-controllerLTLIBRARIES
613 @$(NORMAL_INSTALL)
614 $(MAKE) $(AM_MAKEFLAGS) uninstall-hook
615.MAKE: install-am install-data-am install-strip uninstall-am
616
617.PHONY: CTAGS GTAGS all all-am check check-am clean \
618 clean-controllerLTLIBRARIES clean-generic clean-libtool \
619 clean-local ctags distclean distclean-compile \
620 distclean-generic distclean-libtool distclean-tags distdir dvi \
621 dvi-am html html-am info info-am install install-am \
622 install-controllerLTLIBRARIES install-data install-data-am \
623 install-data-hook install-dvi install-dvi-am install-exec \
624 install-exec-am install-html install-html-am install-info \
625 install-info-am install-man install-pdf install-pdf-am \
626 install-ps install-ps-am install-strip installcheck \
627 installcheck-am installdirs maintainer-clean \
628 maintainer-clean-generic mostlyclean mostlyclean-compile \
629 mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
630 tags uninstall uninstall-am uninstall-controllerLTLIBRARIES \
631 uninstall-hook
632
633
634install-data-hook:
635 rm -f $(DESTDIR)$(controllerdir)/$(controller_LTLIBRARIES)
636uninstall-hook:
637 rm -f $(DESTDIR)$(controllerdir)/module.*
638
639clean-local:
640 rm -rf *.gcno
641
642# Tell versions [3.59,3.63) of GNU make to not export all variables.
643# Otherwise a system limit (for SysV at least) may be exceeded.
644.NOEXPORT:
diff --git a/libraries/eina/src/modules/mp/chained_pool/eina_chained_mempool.c b/libraries/eina/src/modules/mp/chained_pool/eina_chained_mempool.c
new file mode 100644
index 0000000..009b62b
--- /dev/null
+++ b/libraries/eina/src/modules/mp/chained_pool/eina_chained_mempool.c
@@ -0,0 +1,547 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008-2010 Cedric BAIL, Vincent Torri
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifdef HAVE_CONFIG_H
20# include "config.h"
21#endif
22
23#include <stdlib.h>
24#include <string.h>
25
26#ifdef EFL_HAVE_POSIX_THREADS
27#include <pthread.h>
28
29# ifdef EFL_DEBUG_THREADS
30# include <assert.h>
31# endif
32#endif
33
34#ifdef EFL_HAVE_WIN32_THREADS
35# define WIN32_LEAN_AND_MEAN
36# include <windows.h>
37# undef WIN32_LEAN_AND_MEAN
38#endif
39
40#include "eina_inlist.h"
41#include "eina_error.h"
42#include "eina_module.h"
43#include "eina_mempool.h"
44#include "eina_trash.h"
45#include "eina_rbtree.h"
46#include "eina_lock.h"
47
48#include "eina_private.h"
49
50#ifndef NVALGRIND
51# include <valgrind/memcheck.h>
52#endif
53
54#ifdef DEBUG
55#include <assert.h>
56#include "eina_log.h"
57
58static int _eina_chained_mp_log_dom = -1;
59
60#ifdef INF
61#undef INF
62#endif
63#define INF(...) EINA_LOG_DOM_INFO(_eina_chained_mp_log_dom, __VA_ARGS__)
64#endif
65
66typedef struct _Chained_Mempool Chained_Mempool;
67struct _Chained_Mempool
68{
69 Eina_Inlist *first;
70 Eina_Rbtree *root;
71 const char *name;
72 int item_alloc;
73 int pool_size;
74 int alloc_size;
75 int group_size;
76 int usage;
77#ifdef EFL_DEBUG_THREADS
78 pthread_t self;
79#endif
80 Eina_Lock mutex;
81};
82
83typedef struct _Chained_Pool Chained_Pool;
84struct _Chained_Pool
85{
86 EINA_INLIST;
87 EINA_RBTREE;
88 Eina_Trash *base;
89 int usage;
90
91 unsigned char *last;
92 unsigned char *limit;
93};
94
95static inline Eina_Rbtree_Direction
96_eina_chained_mp_pool_cmp(const Eina_Rbtree *left, const Eina_Rbtree *right, __UNUSED__ void *data)
97{
98 if (left < right) return EINA_RBTREE_LEFT;
99 return EINA_RBTREE_RIGHT;
100}
101
102static inline int
103_eina_chained_mp_pool_key_cmp(const Eina_Rbtree *node, const void *key,
104 __UNUSED__ int length, __UNUSED__ void *data)
105{
106 const Chained_Pool *r = EINA_RBTREE_CONTAINER_GET(node, const Chained_Pool);
107
108 if (key > (void *) r->limit) return -1;
109 if (key < (void *) r) return 1;
110 return 0;
111}
112
113static inline Chained_Pool *
114_eina_chained_mp_pool_new(Chained_Mempool *pool)
115{
116 Chained_Pool *p;
117 unsigned char *ptr;
118 unsigned int alignof;
119
120 eina_error_set(0);
121 p = malloc(pool->alloc_size);
122 if (!p)
123 {
124 eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
125 return NULL;
126 }
127
128 alignof = eina_mempool_alignof(sizeof(Chained_Pool));
129 ptr = (unsigned char *)p + alignof;
130 p->usage = 0;
131 p->base = NULL;
132
133 p->last = ptr;
134 p->limit = ptr + pool->item_alloc * pool->pool_size;
135
136#ifndef NVALGRIND
137 VALGRIND_MAKE_MEM_NOACCESS(ptr, pool->alloc_size - alignof);
138#endif
139
140 return p;
141}
142
143static inline void
144_eina_chained_mp_pool_free(Chained_Pool *p)
145{
146 free(p);
147}
148
149static int
150_eina_chained_mempool_usage_cmp(const Eina_Inlist *l1, const Eina_Inlist *l2)
151{
152 const Chained_Pool *p1;
153 const Chained_Pool *p2;
154
155 p1 = EINA_INLIST_CONTAINER_GET(l1, const Chained_Pool);
156 p2 = EINA_INLIST_CONTAINER_GET(l2, const Chained_Pool);
157
158 return p2->usage - p1->usage;
159}
160
161static void *
162_eina_chained_mempool_alloc_in(Chained_Mempool *pool, Chained_Pool *p)
163{
164 void *mem;
165
166 if (p->last)
167 {
168 mem = p->last;
169 p->last += pool->item_alloc;
170 if (p->last >= p->limit)
171 p->last = NULL;
172 }
173 else
174 {
175#ifndef NVALGRIND
176 VALGRIND_MAKE_MEM_DEFINED(p->base, pool->item_alloc);
177#endif
178 // Request a free pointer
179 mem = eina_trash_pop(&p->base);
180 }
181
182 // move to end - it just filled up
183 if (!p->base && !p->last)
184 pool->first = eina_inlist_demote(pool->first, EINA_INLIST_GET(p));
185
186 p->usage++;
187 pool->usage++;
188
189#ifndef NVALGRIND
190 VALGRIND_MEMPOOL_ALLOC(pool, mem, pool->item_alloc);
191#endif
192
193 return mem;
194}
195
196static Eina_Bool
197_eina_chained_mempool_free_in(Chained_Mempool *pool, Chained_Pool *p, void *ptr)
198{
199 void *pmem;
200
201 // pool mem base
202 pmem = (void *)(((unsigned char *)p) + sizeof(Chained_Pool));
203
204 // is it in pool mem?
205 if (ptr < pmem)
206 {
207#ifdef DEBUG
208 INF("%p is inside the private part of %p pool from %p Chained_Mempool (could be the sign of a buffer underrun).", ptr, p, pool);
209#endif
210 return EINA_FALSE;
211 }
212
213 // freed node points to prev free node
214 eina_trash_push(&p->base, ptr);
215 // next free node is now the one we freed
216 p->usage--;
217 pool->usage--;
218 if (p->usage == 0)
219 {
220 // free bucket
221 pool->first = eina_inlist_remove(pool->first, EINA_INLIST_GET(p));
222 pool->root = eina_rbtree_inline_remove(pool->root, EINA_RBTREE_GET(p),
223 _eina_chained_mp_pool_cmp, NULL);
224 _eina_chained_mp_pool_free(p);
225
226 return EINA_TRUE;
227 }
228 else
229 {
230 // move to front
231 pool->first = eina_inlist_promote(pool->first, EINA_INLIST_GET(p));
232 }
233
234 return EINA_FALSE;
235}
236
237static void *
238eina_chained_mempool_malloc(void *data, __UNUSED__ unsigned int size)
239{
240 Chained_Mempool *pool = data;
241 Chained_Pool *p = NULL;
242 void *mem;
243
244 if (!eina_lock_take(&pool->mutex))
245 {
246#ifdef EFL_DEBUG_THREADS
247 assert(pthread_equal(pool->self, pthread_self()));
248#endif
249 }
250
251 // Either we have some free space in the first one, or there is no free space.
252 if (pool->first) p = EINA_INLIST_CONTAINER_GET(pool->first, Chained_Pool);
253
254 // base is not NULL - has a free slot
255 if (p && !p->base && !p->last)
256 p = NULL;
257
258#ifdef DEBUG
259 if (p == NULL)
260 EINA_INLIST_FOREACH(pool->first, p)
261 assert(!p->base && !p->last);
262#endif
263
264 // we have reached the end of the list - no free pools
265 if (!p)
266 {
267 p = _eina_chained_mp_pool_new(pool);
268 if (!p)
269 {
270 eina_lock_release(&pool->mutex);
271 return NULL;
272 }
273
274 pool->first = eina_inlist_prepend(pool->first, EINA_INLIST_GET(p));
275 pool->root = eina_rbtree_inline_insert(pool->root, EINA_RBTREE_GET(p),
276 _eina_chained_mp_pool_cmp, NULL);
277 }
278
279 mem = _eina_chained_mempool_alloc_in(pool, p);
280
281 eina_lock_release(&pool->mutex);
282
283 return mem;
284}
285
286static void
287eina_chained_mempool_free(void *data, void *ptr)
288{
289 Chained_Mempool *pool = data;
290 Eina_Rbtree *r;
291 Chained_Pool *p;
292
293 // look 4 pool
294 if (!eina_lock_take(&pool->mutex))
295 {
296#ifdef EFL_DEBUG_THREADS
297 assert(pthread_equal(pool->self, pthread_self()));
298#endif
299 }
300
301 // searching for the right mempool
302 r = eina_rbtree_inline_lookup(pool->root, ptr, 0, _eina_chained_mp_pool_key_cmp, NULL);
303
304 // related mempool not found
305 if (!r)
306 {
307#ifdef DEBUG
308 INF("%p is not the property of %p Chained_Mempool", ptr, pool);
309#endif
310 goto on_error;
311 }
312
313 p = EINA_RBTREE_CONTAINER_GET(r, Chained_Pool);
314
315 _eina_chained_mempool_free_in(pool, p, ptr);
316
317 on_error:
318#ifndef NVALGRIND
319 if (ptr)
320 {
321 VALGRIND_MEMPOOL_FREE(pool, ptr);
322 }
323#endif
324
325 eina_lock_release(&pool->mutex);
326 return;
327}
328
329static void
330eina_chained_mempool_repack(void *data,
331 Eina_Mempool_Repack_Cb cb,
332 void *cb_data)
333{
334 Chained_Mempool *pool = data;
335 Chained_Pool *start;
336 Chained_Pool *tail;
337
338 /* FIXME: Improvement - per Chained_Pool lock */
339 if (!eina_lock_take(&pool->mutex))
340 {
341#ifdef EFL_DEBUG_THREADS
342 assert(pthread_equal(pool->self, pthread_self()));
343#endif
344 }
345
346 pool->first = eina_inlist_sort(pool->first,
347 (Eina_Compare_Cb) _eina_chained_mempool_usage_cmp);
348
349 /*
350 idea : remove the almost empty pool at the beginning of the list by
351 moving data in the last pool with empty slot
352 */
353 tail = EINA_INLIST_CONTAINER_GET(pool->first->last, Chained_Pool);
354 while (tail && tail->usage == pool->pool_size)
355 tail = EINA_INLIST_CONTAINER_GET((EINA_INLIST_GET(tail)->prev), Chained_Pool);
356
357 while (tail)
358 {
359 unsigned char *src;
360 unsigned char *dst;
361
362 start = EINA_INLIST_CONTAINER_GET(pool->first, Chained_Pool);
363
364 if (start == tail || start->usage == pool->pool_size)
365 break;
366
367 for (src = start->limit - pool->group_size;
368 src != start->limit;
369 src += pool->item_alloc)
370 {
371 Eina_Bool is_free = EINA_FALSE;
372 Eina_Bool is_dead;
373
374 /* Do we have something inside that piece of memory */
375 if (start->last != NULL && src >= start->last)
376 {
377 is_free = EINA_TRUE;
378 }
379 else
380 {
381 Eina_Trash *over = start->base;
382
383 while (over != NULL && (unsigned char*) over != src)
384 over = over->next;
385
386 if (over == NULL)
387 is_free = EINA_TRUE;
388 }
389
390 if (is_free) continue ;
391
392 /* get a new memory pointer from the latest most occuped pool */
393 dst = _eina_chained_mempool_alloc_in(pool, tail);
394 /* move data from one to another */
395 memcpy(dst, src, pool->item_alloc);
396 /* notify caller */
397 cb(dst, src, cb_data);
398 /* destroy old pointer */
399 is_dead = _eina_chained_mempool_free_in(pool, start, src);
400
401 /* search last tail with empty slot */
402 while (tail && tail->usage == pool->pool_size)
403 tail = EINA_INLIST_CONTAINER_GET((EINA_INLIST_GET(tail)->prev),
404 Chained_Pool);
405 /* no more free space */
406 if (!tail || tail == start) break;
407 if (is_dead) break;
408 }
409 }
410
411 /* FIXME: improvement - reorder pool so that the most used one get in front */
412 eina_lock_release(&pool->mutex);
413}
414
415static void *
416eina_chained_mempool_realloc(__UNUSED__ void *data,
417 __UNUSED__ void *element,
418 __UNUSED__ unsigned int size)
419{
420 return NULL;
421}
422
423static void *
424eina_chained_mempool_init(const char *context,
425 __UNUSED__ const char *option,
426 va_list args)
427{
428 Chained_Mempool *mp;
429 int item_size;
430 size_t length;
431
432 length = context ? strlen(context) + 1 : 0;
433
434 mp = calloc(1, sizeof(Chained_Mempool) + length);
435 if (!mp)
436 return NULL;
437
438 item_size = va_arg(args, int);
439 mp->pool_size = va_arg(args, int);
440
441 if (length)
442 {
443 mp->name = (const char *)(mp + 1);
444 memcpy((char *)mp->name, context, length);
445 }
446
447 mp->item_alloc = eina_mempool_alignof(item_size);
448 mp->group_size = mp->item_alloc * mp->pool_size;
449 mp->alloc_size = mp->group_size + eina_mempool_alignof(sizeof(Chained_Pool));
450
451#ifndef NVALGRIND
452 VALGRIND_CREATE_MEMPOOL(mp, 0, 1);
453#endif
454
455#ifdef EFL_DEBUG_THREADS
456 mp->self = pthread_self();
457#endif
458
459 eina_lock_new(&mp->mutex);
460
461 return mp;
462}
463
464static void
465eina_chained_mempool_shutdown(void *data)
466{
467 Chained_Mempool *mp;
468
469 mp = (Chained_Mempool *)data;
470
471 while (mp->first)
472 {
473 Chained_Pool *p = (Chained_Pool *)mp->first;
474
475#ifdef DEBUG
476 if (p->usage > 0)
477 INF("Bad news we are destroying not an empty mempool [%s]\n",
478 mp->name);
479
480#endif
481
482 mp->first = eina_inlist_remove(mp->first, mp->first);
483 mp->root = eina_rbtree_inline_remove(mp->root, EINA_RBTREE_GET(p),
484 _eina_chained_mp_pool_cmp, NULL);
485 _eina_chained_mp_pool_free(p);
486 }
487
488#ifdef DEBUG
489 if (mp->root)
490 INF("Bad news, list of pool and rbtree are out of sync for %p !", mp);
491#endif
492
493#ifndef NVALGRIND
494 VALGRIND_DESTROY_MEMPOOL(mp);
495#endif
496
497 eina_lock_free(&mp->mutex);
498
499#ifdef EFL_DEBUG_THREADS
500 assert(pthread_equal(mp->self, pthread_self()));
501#endif
502
503 free(mp);
504}
505
506static Eina_Mempool_Backend _eina_chained_mp_backend = {
507 "chained_mempool",
508 &eina_chained_mempool_init,
509 &eina_chained_mempool_free,
510 &eina_chained_mempool_malloc,
511 &eina_chained_mempool_realloc,
512 NULL,
513 NULL,
514 &eina_chained_mempool_shutdown,
515 &eina_chained_mempool_repack
516};
517
518Eina_Bool chained_init(void)
519{
520#ifdef DEBUG
521 _eina_chained_mp_log_dom = eina_log_domain_register("eina_mempool",
522 EINA_LOG_COLOR_DEFAULT);
523 if (_eina_chained_mp_log_dom < 0)
524 {
525 EINA_LOG_ERR("Could not register log domain: eina_mempool");
526 return EINA_FALSE;
527 }
528
529#endif
530 return eina_mempool_register(&_eina_chained_mp_backend);
531}
532
533void chained_shutdown(void)
534{
535 eina_mempool_unregister(&_eina_chained_mp_backend);
536#ifdef DEBUG
537 eina_log_domain_unregister(_eina_chained_mp_log_dom);
538 _eina_chained_mp_log_dom = -1;
539#endif
540}
541
542#ifndef EINA_STATIC_BUILD_CHAINED_POOL
543
544EINA_MODULE_INIT(chained_init);
545EINA_MODULE_SHUTDOWN(chained_shutdown);
546
547#endif /* ! EINA_STATIC_BUILD_CHAINED_POOL */