2008-08-06 11:15:24 -07:00
|
|
|
/* EINA - EFL data type library
|
|
|
|
* Copyright (C) 2007-2008 Jorge Luis Zapata Muga
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library;
|
|
|
|
* if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2008-08-28 00:46:42 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2009-09-06 21:32:49 -07:00
|
|
|
# include "config.h"
|
2008-08-28 00:46:42 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <assert.h>
|
2008-09-29 06:28:42 -07:00
|
|
|
#include <stdlib.h>
|
2008-10-29 16:12:56 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2008-08-28 00:46:42 -07:00
|
|
|
|
2009-08-28 05:03:34 -07:00
|
|
|
#include "eina_config.h"
|
|
|
|
#include "eina_private.h"
|
2008-09-24 05:55:31 -07:00
|
|
|
#include "eina_hash.h"
|
2008-07-30 06:35:49 -07:00
|
|
|
#include "eina_module.h"
|
2009-09-03 18:13:49 -07:00
|
|
|
#include "eina_log.h"
|
2009-09-06 15:21:56 -07:00
|
|
|
#include "eina_main.h"
|
|
|
|
|
|
|
|
/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
|
2009-09-03 18:13:49 -07:00
|
|
|
#include "eina_safety_checks.h"
|
|
|
|
#include "eina_mempool.h"
|
2008-08-28 00:46:42 -07:00
|
|
|
|
2008-07-30 05:46:55 -07:00
|
|
|
/*============================================================================*
|
2010-07-27 19:37:05 -07:00
|
|
|
* Local *
|
|
|
|
*============================================================================*/
|
2009-01-20 00:29:41 -08:00
|
|
|
|
2009-06-22 13:03:58 -07:00
|
|
|
/**
|
|
|
|
* @cond LOCAL
|
|
|
|
*/
|
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
static Eina_Hash *_backends;
|
2008-09-29 06:28:42 -07:00
|
|
|
static Eina_Array *_modules;
|
2009-09-06 21:23:05 -07:00
|
|
|
static int _eina_mempool_log_dom = -1;
|
2009-09-03 18:13:49 -07:00
|
|
|
|
2009-09-06 21:23:05 -07:00
|
|
|
#ifdef ERR
|
|
|
|
#undef ERR
|
|
|
|
#endif
|
|
|
|
#define ERR(...) EINA_LOG_DOM_ERR(_eina_mempool_log_dom, __VA_ARGS__)
|
|
|
|
|
|
|
|
#ifdef DBG
|
|
|
|
#undef DBG
|
|
|
|
#endif
|
|
|
|
#define DBG(...) EINA_LOG_DOM_DBG(_eina_mempool_log_dom, __VA_ARGS__)
|
2009-09-03 18:13:49 -07:00
|
|
|
|
2008-07-30 05:46:55 -07:00
|
|
|
|
2008-07-31 10:00:56 -07:00
|
|
|
static Eina_Mempool *
|
2010-07-27 19:37:05 -07:00
|
|
|
_new_va(const char *name,
|
|
|
|
const char *context,
|
|
|
|
const char *options,
|
|
|
|
va_list args)
|
2008-07-30 05:46:55 -07:00
|
|
|
{
|
2017-09-16 05:17:25 -07:00
|
|
|
Eina_Mempool_Backend *be;
|
|
|
|
Eina_Mempool *mp = NULL;
|
2009-01-20 00:29:41 -08:00
|
|
|
|
2019-08-08 15:55:40 -07:00
|
|
|
static signed char mempool_pass = -1;
|
|
|
|
|
|
|
|
if (mempool_pass == -1)
|
|
|
|
{
|
|
|
|
if (getenv("EINA_MEMPOOL_PASS")) mempool_pass = 1;
|
|
|
|
else mempool_pass = 0;
|
|
|
|
}
|
|
|
|
if (mempool_pass == 1)
|
2012-06-16 18:12:16 -07:00
|
|
|
{
|
|
|
|
be = eina_hash_find(_backends, "pass_through");
|
|
|
|
if (!be) be = eina_hash_find(_backends, name);
|
|
|
|
}
|
|
|
|
else be = eina_hash_find(_backends, name);
|
|
|
|
if ((!be) || (!be->init)) goto on_error;
|
2008-08-18 01:18:16 -07:00
|
|
|
|
2010-08-22 15:35:24 -07:00
|
|
|
mp = calloc(1, sizeof(Eina_Mempool));
|
2013-10-11 00:49:13 -07:00
|
|
|
if (!mp) goto on_error;
|
2008-09-24 05:55:31 -07:00
|
|
|
|
2011-04-11 10:45:01 -07:00
|
|
|
/* Work around ABI incompability introduced in Eina 1.1 */
|
|
|
|
#define SBP(Property) mp->backend.Property = be->Property;
|
|
|
|
SBP(name);
|
|
|
|
SBP(init);
|
|
|
|
SBP(free);
|
|
|
|
SBP(alloc);
|
|
|
|
SBP(realloc);
|
|
|
|
SBP(garbage_collect);
|
|
|
|
SBP(statistics);
|
|
|
|
SBP(shutdown);
|
|
|
|
#undef SBP
|
2011-04-12 01:52:59 -07:00
|
|
|
|
2019-10-25 08:01:35 -07:00
|
|
|
if (be->repack || be->from || be->iterator || be->alloc_near)
|
2011-04-12 01:52:59 -07:00
|
|
|
{
|
|
|
|
mp->backend2 = calloc(1, sizeof (Eina_Mempool_Backend_ABI2));
|
2017-08-15 13:46:34 -07:00
|
|
|
if (!mp->backend2) goto on_error;
|
|
|
|
mp->backend2->repack = be->repack;
|
|
|
|
mp->backend2->from = be->from;
|
2019-09-14 10:54:05 -07:00
|
|
|
mp->backend2->iterator = be->iterator;
|
2019-10-25 08:01:35 -07:00
|
|
|
mp->backend2->alloc_near = be->alloc_near;
|
2011-04-12 01:52:59 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 19:37:05 -07:00
|
|
|
mp->backend_data = mp->backend.init(context, options, args);
|
2017-09-16 05:17:25 -07:00
|
|
|
if (EINA_UNLIKELY(! mp->backend_data)) goto clean_mp;
|
2010-07-27 19:37:05 -07:00
|
|
|
return mp;
|
2008-08-18 01:18:16 -07:00
|
|
|
|
2017-09-16 05:17:25 -07:00
|
|
|
clean_mp:
|
|
|
|
free(mp->backend2);
|
2010-07-27 19:37:05 -07:00
|
|
|
on_error:
|
2017-09-16 05:17:25 -07:00
|
|
|
free(mp);
|
2010-07-27 19:37:05 -07:00
|
|
|
return NULL;
|
2008-07-30 05:46:55 -07:00
|
|
|
}
|
2008-08-18 01:18:16 -07:00
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
/* Built-in backend's prototypes */
|
2011-04-27 09:58:23 -07:00
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
#ifdef EINA_STATIC_BUILD_CHAINED_POOL
|
|
|
|
Eina_Bool chained_init(void);
|
2010-07-27 19:37:05 -07:00
|
|
|
void chained_shutdown(void);
|
2008-09-24 05:55:31 -07:00
|
|
|
#endif
|
|
|
|
|
2010-07-26 08:52:43 -07:00
|
|
|
#ifdef EINA_STATIC_BUILD_ONE_BIG
|
|
|
|
Eina_Bool one_big_init(void);
|
2010-07-27 19:37:05 -07:00
|
|
|
void one_big_shutdown(void);
|
2010-07-26 08:52:43 -07:00
|
|
|
#endif
|
|
|
|
|
2011-04-27 09:58:23 -07:00
|
|
|
#ifdef EINA_STATIC_BUILD_PASS_THROUGH
|
|
|
|
Eina_Bool pass_through_init(void);
|
|
|
|
void pass_through_shutdown(void);
|
|
|
|
#endif
|
|
|
|
|
2009-06-22 13:03:58 -07:00
|
|
|
/**
|
|
|
|
* @endcond
|
|
|
|
*/
|
|
|
|
|
2008-08-28 00:46:42 -07:00
|
|
|
/*============================================================================*
|
2010-07-27 19:37:05 -07:00
|
|
|
* Global *
|
|
|
|
*============================================================================*/
|
2009-01-20 00:29:41 -08:00
|
|
|
|
2009-12-27 00:45:30 -08:00
|
|
|
/**
|
|
|
|
* @cond LOCAL
|
|
|
|
*/
|
|
|
|
|
eina: Rename EAPI macro to EINA_API in Eina library
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: jptiz, lucas, woohyun, vtorri, raster
Reviewed By: jptiz, lucas, vtorri
Subscribers: ProhtMeyhet, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12188
2020-11-25 04:35:48 -08:00
|
|
|
EINA_API Eina_Error EINA_ERROR_NOT_MEMPOOL_MODULE = 0;
|
2009-12-27 00:45:30 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @endcond
|
|
|
|
*/
|
|
|
|
|
eina: Rename EAPI macro to EINA_API in Eina library
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: jptiz, lucas, woohyun, vtorri, raster
Reviewed By: jptiz, lucas, vtorri
Subscribers: ProhtMeyhet, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12188
2020-11-25 04:35:48 -08:00
|
|
|
EINA_API Eina_Bool
|
2009-09-03 18:13:49 -07:00
|
|
|
eina_mempool_register(Eina_Mempool_Backend *be)
|
2008-09-24 05:55:31 -07:00
|
|
|
{
|
2009-09-03 18:13:49 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(be, 0);
|
|
|
|
DBG("be=%p, name=%p", be, be->name);
|
|
|
|
return eina_hash_add(_backends, be->name, be);
|
2008-09-24 05:55:31 -07:00
|
|
|
}
|
2008-08-28 00:46:42 -07:00
|
|
|
|
eina: Rename EAPI macro to EINA_API in Eina library
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: jptiz, lucas, woohyun, vtorri, raster
Reviewed By: jptiz, lucas, vtorri
Subscribers: ProhtMeyhet, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12188
2020-11-25 04:35:48 -08:00
|
|
|
EINA_API void
|
2009-09-03 18:13:49 -07:00
|
|
|
eina_mempool_unregister(Eina_Mempool_Backend *be)
|
2008-09-24 05:55:31 -07:00
|
|
|
{
|
2009-09-03 18:13:49 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(be);
|
|
|
|
DBG("be=%p, name=%p", be, be->name);
|
|
|
|
eina_hash_del(_backends, be->name, be);
|
2008-09-24 05:55:31 -07:00
|
|
|
}
|
2009-01-20 00:29:41 -08:00
|
|
|
|
2009-09-06 15:21:56 -07:00
|
|
|
Eina_Bool
|
2008-07-31 10:00:56 -07:00
|
|
|
eina_mempool_init(void)
|
2008-07-30 05:46:55 -07:00
|
|
|
{
|
2009-09-06 15:21:56 -07:00
|
|
|
char *path;
|
|
|
|
|
2010-07-27 19:37:05 -07:00
|
|
|
_eina_mempool_log_dom = eina_log_domain_register("eina_mempool",
|
|
|
|
EINA_LOG_COLOR_DEFAULT);
|
2009-09-06 21:23:05 -07:00
|
|
|
if (_eina_mempool_log_dom < 0)
|
2009-09-06 15:21:56 -07:00
|
|
|
{
|
2010-07-27 19:37:05 -07:00
|
|
|
EINA_LOG_ERR("Could not register log domain: eina_mempool");
|
|
|
|
return 0;
|
2009-09-06 15:21:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
_backends = eina_hash_string_superfast_new(NULL);
|
|
|
|
|
|
|
|
/* dynamic backends */
|
2010-07-27 19:37:05 -07:00
|
|
|
_modules = eina_module_arch_list_get(NULL,
|
|
|
|
PACKAGE_LIB_DIR "/eina/modules/mp",
|
|
|
|
MODULE_ARCH);
|
2009-09-06 15:21:56 -07:00
|
|
|
|
2010-07-27 19:37:05 -07:00
|
|
|
path = eina_module_symbol_path_get((const void *)eina_init,
|
|
|
|
"/eina/modules/mp");
|
2010-01-26 07:54:28 -08:00
|
|
|
_modules = eina_module_arch_list_get(_modules, path, MODULE_ARCH);
|
2010-07-27 19:37:05 -07:00
|
|
|
if (path)
|
|
|
|
free(path);
|
2009-09-06 15:21:56 -07:00
|
|
|
|
|
|
|
if (!_modules)
|
|
|
|
{
|
2010-07-27 19:37:05 -07:00
|
|
|
ERR("no mempool modules able to be loaded.");
|
|
|
|
eina_hash_free(_backends);
|
|
|
|
goto mempool_init_error;
|
2009-09-06 15:21:56 -07:00
|
|
|
}
|
2010-07-27 19:37:05 -07:00
|
|
|
|
2014-01-05 19:16:36 -08:00
|
|
|
// XXX: MODFIX: do not list ALL modules and load them ALL! this is
|
|
|
|
// wrong. load the module we need WHEN we need it (by name etc. etc.
|
|
|
|
// from api).
|
2009-09-06 15:21:56 -07:00
|
|
|
eina_module_list_load(_modules);
|
2010-07-27 19:37:05 -07:00
|
|
|
|
2009-09-06 15:21:56 -07:00
|
|
|
/* builtin backends */
|
2008-09-24 05:55:31 -07:00
|
|
|
#ifdef EINA_STATIC_BUILD_CHAINED_POOL
|
2009-09-06 15:21:56 -07:00
|
|
|
chained_init();
|
2008-09-24 05:55:31 -07:00
|
|
|
#endif
|
2010-07-26 08:52:43 -07:00
|
|
|
#ifdef EINA_STATIC_BUILD_ONE_BIG
|
|
|
|
one_big_init();
|
|
|
|
#endif
|
2011-04-27 09:58:23 -07:00
|
|
|
#ifdef EINA_STATIC_BUILD_PASS_THROUGH
|
|
|
|
pass_through_init();
|
|
|
|
#endif
|
2009-06-09 09:02:20 -07:00
|
|
|
|
2009-09-06 15:21:56 -07:00
|
|
|
return EINA_TRUE;
|
2009-06-09 09:02:20 -07:00
|
|
|
|
2010-07-27 19:37:05 -07:00
|
|
|
mempool_init_error:
|
2009-09-06 21:23:05 -07:00
|
|
|
eina_log_domain_unregister(_eina_mempool_log_dom);
|
|
|
|
_eina_mempool_log_dom = -1;
|
2009-09-06 15:21:56 -07:00
|
|
|
|
|
|
|
return EINA_FALSE;
|
2008-07-30 05:46:55 -07:00
|
|
|
}
|
2008-08-18 01:18:16 -07:00
|
|
|
|
2009-09-06 15:21:56 -07:00
|
|
|
Eina_Bool
|
2008-07-31 10:00:56 -07:00
|
|
|
eina_mempool_shutdown(void)
|
2008-07-30 05:46:55 -07:00
|
|
|
{
|
2009-09-06 15:21:56 -07:00
|
|
|
/* builtin backends */
|
2008-09-24 05:55:31 -07:00
|
|
|
#ifdef EINA_STATIC_BUILD_CHAINED_POOL
|
2009-09-06 15:21:56 -07:00
|
|
|
chained_shutdown();
|
2008-09-24 05:55:31 -07:00
|
|
|
#endif
|
2010-07-26 08:52:43 -07:00
|
|
|
#ifdef EINA_STATIC_BUILD_ONE_BIG
|
|
|
|
one_big_shutdown();
|
2011-04-27 09:58:23 -07:00
|
|
|
#endif
|
|
|
|
#ifdef EINA_STATIC_BUILD_PASS_THROUGH
|
|
|
|
pass_through_shutdown();
|
2008-09-24 05:55:31 -07:00
|
|
|
#endif
|
2009-09-06 15:21:56 -07:00
|
|
|
/* dynamic backends */
|
2010-01-08 04:22:23 -08:00
|
|
|
eina_module_list_free(_modules);
|
2009-09-06 15:21:56 -07:00
|
|
|
if (_modules)
|
2010-07-27 19:37:05 -07:00
|
|
|
eina_array_free(_modules);
|
2009-06-09 09:02:20 -07:00
|
|
|
|
2009-09-06 15:21:56 -07:00
|
|
|
if (_backends)
|
2010-07-27 19:37:05 -07:00
|
|
|
eina_hash_free(_backends);
|
2009-06-09 09:02:20 -07:00
|
|
|
|
2009-09-06 21:23:05 -07:00
|
|
|
eina_log_domain_unregister(_eina_mempool_log_dom);
|
|
|
|
_eina_mempool_log_dom = -1;
|
2009-06-09 09:02:20 -07:00
|
|
|
|
2009-09-06 15:21:56 -07:00
|
|
|
return EINA_TRUE;
|
2008-07-30 05:46:55 -07:00
|
|
|
}
|
2008-08-18 01:18:16 -07:00
|
|
|
|
2009-12-27 00:45:30 -08:00
|
|
|
/*============================================================================*
|
2010-07-27 19:37:05 -07:00
|
|
|
* API *
|
|
|
|
*============================================================================*/
|
2009-12-27 00:45:30 -08:00
|
|
|
|
eina: Rename EAPI macro to EINA_API in Eina library
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: jptiz, lucas, woohyun, vtorri, raster
Reviewed By: jptiz, lucas, vtorri
Subscribers: ProhtMeyhet, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12188
2020-11-25 04:35:48 -08:00
|
|
|
EINA_API Eina_Mempool *
|
2010-07-27 19:37:05 -07:00
|
|
|
eina_mempool_add(const char *name,
|
|
|
|
const char *context,
|
|
|
|
const char *options,
|
|
|
|
...)
|
2008-07-30 05:46:55 -07:00
|
|
|
{
|
2010-07-27 19:37:05 -07:00
|
|
|
Eina_Mempool *mp;
|
|
|
|
va_list args;
|
2008-07-31 10:00:56 -07:00
|
|
|
|
2010-07-27 19:37:05 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
|
|
|
|
DBG("name=%s, context=%s, options=%s",
|
|
|
|
name, context ? context : "", options ? options : "");
|
2008-07-31 10:00:56 -07:00
|
|
|
|
2010-07-27 19:37:05 -07:00
|
|
|
va_start(args, options);
|
|
|
|
mp = _new_va(name, context, options, args);
|
|
|
|
va_end(args);
|
2008-07-31 10:00:56 -07:00
|
|
|
|
2010-07-27 19:37:05 -07:00
|
|
|
DBG("name=%s, context=%s, options=%s, mp=%p",
|
|
|
|
name, context ? context : "", options ? options : "", mp);
|
2009-09-03 18:13:49 -07:00
|
|
|
|
2010-07-27 19:37:05 -07:00
|
|
|
return mp;
|
2008-07-30 05:46:55 -07:00
|
|
|
}
|
2008-08-18 01:18:16 -07:00
|
|
|
|
eina: Rename EAPI macro to EINA_API in Eina library
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: jptiz, lucas, woohyun, vtorri, raster
Reviewed By: jptiz, lucas, vtorri
Subscribers: ProhtMeyhet, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12188
2020-11-25 04:35:48 -08:00
|
|
|
EINA_API void eina_mempool_del(Eina_Mempool *mp)
|
2008-07-30 05:46:55 -07:00
|
|
|
{
|
2010-07-27 19:37:05 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(mp);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(mp->backend.shutdown);
|
|
|
|
DBG("mp=%p", mp);
|
|
|
|
mp->backend.shutdown(mp->backend_data);
|
2011-04-12 01:52:59 -07:00
|
|
|
free(mp->backend2);
|
2010-07-27 19:37:05 -07:00
|
|
|
free(mp);
|
2008-07-30 05:46:55 -07:00
|
|
|
}
|
2008-08-18 01:18:16 -07:00
|
|
|
|
eina: Rename EAPI macro to EINA_API in Eina library
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: jptiz, lucas, woohyun, vtorri, raster
Reviewed By: jptiz, lucas, vtorri
Subscribers: ProhtMeyhet, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12188
2020-11-25 04:35:48 -08:00
|
|
|
EINA_API void eina_mempool_repack(Eina_Mempool *mp, Eina_Mempool_Repack_Cb cb, void *data)
|
2011-04-11 07:07:42 -07:00
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(mp);
|
2011-04-12 01:52:59 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(mp->backend2);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(mp->backend2->repack);
|
2011-04-11 07:07:42 -07:00
|
|
|
DBG("mp=%p", mp);
|
2011-04-12 01:52:59 -07:00
|
|
|
mp->backend2->repack(mp->backend_data, cb, data);
|
2011-04-11 07:07:42 -07:00
|
|
|
}
|
|
|
|
|
eina: Rename EAPI macro to EINA_API in Eina library
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: jptiz, lucas, woohyun, vtorri, raster
Reviewed By: jptiz, lucas, vtorri
Subscribers: ProhtMeyhet, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12188
2020-11-25 04:35:48 -08:00
|
|
|
EINA_API void eina_mempool_gc(Eina_Mempool *mp)
|
2008-09-17 08:20:35 -07:00
|
|
|
{
|
2010-07-27 19:37:05 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(mp);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(mp->backend.garbage_collect);
|
|
|
|
DBG("mp=%p", mp);
|
|
|
|
mp->backend.garbage_collect(mp->backend_data);
|
2008-09-17 08:20:35 -07:00
|
|
|
}
|
|
|
|
|
eina: Rename EAPI macro to EINA_API in Eina library
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: jptiz, lucas, woohyun, vtorri, raster
Reviewed By: jptiz, lucas, vtorri
Subscribers: ProhtMeyhet, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12188
2020-11-25 04:35:48 -08:00
|
|
|
EINA_API void eina_mempool_statistics(Eina_Mempool *mp)
|
2008-09-17 08:20:35 -07:00
|
|
|
{
|
2010-07-27 19:37:05 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(mp);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(mp->backend.statistics);
|
|
|
|
DBG("mp=%p", mp);
|
|
|
|
mp->backend.statistics(mp->backend_data);
|
2008-09-17 08:20:35 -07:00
|
|
|
}
|
2009-06-22 13:03:58 -07:00
|
|
|
|