2008-08-06 11:15:24 -07:00
|
|
|
/* EINA - EFL data type library
|
|
|
|
* Copyright (C) 2002-2008 Carsten Haitzler, Vincent Torri
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
2011-09-05 13:15:12 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2009-08-28 05:03:34 -07:00
|
|
|
#include "eina_config.h"
|
2008-07-30 05:46:55 -07:00
|
|
|
#include "eina_private.h"
|
2010-11-25 11:00:59 -08:00
|
|
|
#include "eina_log.h"
|
2009-09-06 15:21:56 -07:00
|
|
|
|
|
|
|
/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
|
2008-12-26 10:31:14 -08:00
|
|
|
#include "eina_safety_checks.h"
|
2009-08-28 05:03:34 -07:00
|
|
|
#include "eina_inlist.h"
|
2008-07-30 05:46:55 -07:00
|
|
|
|
2008-08-06 11:15:24 -07:00
|
|
|
/* FIXME: TODO please, refactor this :) */
|
2008-07-30 05:46:55 -07:00
|
|
|
|
|
|
|
/*============================================================================*
|
2013-03-17 03:00:49 -07:00
|
|
|
* Local *
|
|
|
|
*============================================================================*/
|
2008-08-28 00:46:42 -07:00
|
|
|
|
2009-06-22 13:03:58 -07:00
|
|
|
/**
|
|
|
|
* @cond LOCAL
|
|
|
|
*/
|
|
|
|
|
2011-04-11 02:55:27 -07:00
|
|
|
#define EINA_INLIST_SORT_STACK_SIZE 32
|
|
|
|
|
2008-08-12 08:58:41 -07:00
|
|
|
typedef struct _Eina_Iterator_Inlist Eina_Iterator_Inlist;
|
|
|
|
typedef struct _Eina_Accessor_Inlist Eina_Accessor_Inlist;
|
|
|
|
|
|
|
|
struct _Eina_Iterator_Inlist
|
|
|
|
{
|
2010-07-27 19:37:05 -07:00
|
|
|
Eina_Iterator iterator;
|
|
|
|
const Eina_Inlist *head;
|
|
|
|
const Eina_Inlist *current;
|
2008-08-12 08:58:41 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _Eina_Accessor_Inlist
|
|
|
|
{
|
2010-07-27 19:37:05 -07:00
|
|
|
Eina_Accessor accessor;
|
2008-08-12 08:58:41 -07:00
|
|
|
|
2010-07-27 19:37:05 -07:00
|
|
|
const Eina_Inlist *head;
|
|
|
|
const Eina_Inlist *current;
|
2008-08-12 08:58:41 -07:00
|
|
|
|
2010-07-27 19:37:05 -07:00
|
|
|
unsigned int index;
|
2008-08-12 08:58:41 -07:00
|
|
|
};
|
|
|
|
|
2011-09-05 13:15:12 -07:00
|
|
|
struct _Eina_Inlist_Sorted_State
|
|
|
|
{
|
|
|
|
Eina_Inlist *jump_table[EINA_INLIST_JUMP_SIZE];
|
|
|
|
|
|
|
|
unsigned short jump_limit;
|
|
|
|
int jump_div;
|
|
|
|
|
|
|
|
int inserted;
|
|
|
|
};
|
|
|
|
|
2008-08-12 08:58:41 -07:00
|
|
|
static Eina_Bool
|
2013-03-17 03:00:49 -07:00
|
|
|
eina_inlist_iterator_next(Eina_Iterator_Inlist *it, void **data)
|
|
|
|
{
|
2010-08-21 06:52:25 -07:00
|
|
|
if (!it->current)
|
2013-03-17 03:00:49 -07:00
|
|
|
return EINA_FALSE;
|
2008-08-12 08:58:41 -07:00
|
|
|
|
2010-07-27 19:37:05 -07:00
|
|
|
if (data)
|
2013-03-17 03:00:49 -07:00
|
|
|
*data = (void *)it->current;
|
2008-08-12 08:58:41 -07:00
|
|
|
|
2010-07-27 19:37:05 -07:00
|
|
|
it->current = it->current->next;
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
2008-08-12 08:58:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Inlist *
|
2013-03-17 03:00:49 -07:00
|
|
|
eina_inlist_iterator_get_container(Eina_Iterator_Inlist *it)
|
|
|
|
{
|
2010-07-27 19:37:05 -07:00
|
|
|
return (Eina_Inlist *)it->head;
|
2008-08-12 08:58:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-03-17 03:00:49 -07:00
|
|
|
eina_inlist_iterator_free(Eina_Iterator_Inlist *it)
|
|
|
|
{
|
2010-07-27 19:37:05 -07:00
|
|
|
free(it);
|
2008-08-12 08:58:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2010-07-27 19:37:05 -07:00
|
|
|
eina_inlist_accessor_get_at(Eina_Accessor_Inlist *it,
|
|
|
|
unsigned int idx,
|
2013-03-17 03:00:49 -07:00
|
|
|
void **data)
|
|
|
|
{
|
2010-07-27 19:37:05 -07:00
|
|
|
const Eina_Inlist *over;
|
|
|
|
unsigned int middle;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (it->index == idx)
|
2013-03-17 03:00:49 -07:00
|
|
|
over = it->current;
|
2010-07-27 19:37:05 -07:00
|
|
|
else if (idx > it->index)
|
2013-03-17 03:00:49 -07:00
|
|
|
/* Looking after current. */
|
|
|
|
for (i = it->index, over = it->current;
|
|
|
|
i < idx && over;
|
|
|
|
++i, over = over->next)
|
|
|
|
;
|
2010-07-27 19:37:05 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
middle = it->index >> 1;
|
|
|
|
|
|
|
|
if (idx > middle)
|
2013-03-17 03:00:49 -07:00
|
|
|
/* Looking backward from current. */
|
|
|
|
for (i = it->index, over = it->current;
|
|
|
|
i > idx && over;
|
|
|
|
--i, over = over->prev)
|
|
|
|
;
|
2010-07-27 19:37:05 -07:00
|
|
|
else
|
2013-03-17 03:00:49 -07:00
|
|
|
/* Looking from the start. */
|
|
|
|
for (i = 0, over = it->head;
|
|
|
|
i < idx && over;
|
|
|
|
++i, over = over->next)
|
|
|
|
;
|
2010-07-27 19:37:05 -07:00
|
|
|
}
|
|
|
|
|
2010-08-21 06:52:25 -07:00
|
|
|
if (!over)
|
2013-03-17 03:00:49 -07:00
|
|
|
return EINA_FALSE;
|
2010-07-27 19:37:05 -07:00
|
|
|
|
|
|
|
it->current = over;
|
|
|
|
it->index = idx;
|
|
|
|
|
|
|
|
if (data)
|
2013-03-17 03:00:49 -07:00
|
|
|
*data = (void *)over;
|
2010-07-27 19:37:05 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
2008-08-12 08:58:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Inlist *
|
2013-03-17 03:00:49 -07:00
|
|
|
eina_inlist_accessor_get_container(Eina_Accessor_Inlist *it)
|
|
|
|
{
|
2010-07-27 19:37:05 -07:00
|
|
|
return (Eina_Inlist *)it->head;
|
2008-08-12 08:58:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-03-17 03:00:49 -07:00
|
|
|
eina_inlist_accessor_free(Eina_Accessor_Inlist *it)
|
|
|
|
{
|
2010-07-27 19:37:05 -07:00
|
|
|
free(it);
|
2008-08-12 08:58:41 -07:00
|
|
|
}
|
|
|
|
|
2011-04-11 02:55:27 -07:00
|
|
|
static Eina_Inlist *
|
|
|
|
eina_inlist_sort_merge(Eina_Inlist *a, Eina_Inlist *b, Eina_Compare_Cb func)
|
|
|
|
{
|
|
|
|
Eina_Inlist *first, *last;
|
|
|
|
|
|
|
|
if (func(a, b) < 0)
|
2013-03-17 03:00:49 -07:00
|
|
|
a = (last = first = a)->next;
|
2011-04-11 02:55:27 -07:00
|
|
|
else
|
2013-03-17 03:00:49 -07:00
|
|
|
b = (last = first = b)->next;
|
2011-04-11 02:55:27 -07:00
|
|
|
|
|
|
|
while (a && b)
|
2013-03-17 03:00:49 -07:00
|
|
|
if (func(a, b) < 0)
|
|
|
|
a = (last = last->next = a)->next;
|
|
|
|
else
|
|
|
|
b = (last = last->next = b)->next;
|
2011-04-11 02:55:27 -07:00
|
|
|
|
|
|
|
last->next = a ? a : b;
|
|
|
|
|
|
|
|
return first;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Inlist *
|
|
|
|
eina_inlist_sort_rebuild_prev(Eina_Inlist *list)
|
|
|
|
{
|
|
|
|
Eina_Inlist *prev = NULL;
|
|
|
|
|
|
|
|
for (; list; list = list->next)
|
|
|
|
{
|
|
|
|
list->prev = prev;
|
|
|
|
prev = list;
|
|
|
|
}
|
|
|
|
|
|
|
|
return prev;
|
|
|
|
}
|
|
|
|
|
2011-09-14 15:04:37 -07:00
|
|
|
static void
|
|
|
|
_eina_inlist_sorted_state_compact(Eina_Inlist_Sorted_State *state)
|
|
|
|
{
|
|
|
|
unsigned short i, j;
|
|
|
|
|
|
|
|
/* compress the jump table */
|
|
|
|
state->jump_div *= 2;
|
|
|
|
state->jump_limit /= 2;
|
|
|
|
|
|
|
|
for (i = 2, j = 1;
|
|
|
|
i < EINA_INLIST_JUMP_SIZE;
|
|
|
|
i += 2, j++)
|
|
|
|
state->jump_table[j] = state->jump_table[i];
|
|
|
|
}
|
|
|
|
|
2009-06-22 13:03:58 -07:00
|
|
|
/**
|
|
|
|
* @endcond
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2008-08-12 08:58:41 -07:00
|
|
|
/*============================================================================*
|
2013-03-17 03:00:49 -07:00
|
|
|
* Global *
|
|
|
|
*============================================================================*/
|
2008-08-28 00:46:42 -07:00
|
|
|
|
2008-08-12 08:58:41 -07:00
|
|
|
/*============================================================================*
|
2013-03-17 03:00:49 -07:00
|
|
|
* API *
|
|
|
|
*============================================================================*/
|
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 Eina_Inlist *
|
2008-09-18 07:22:48 -07:00
|
|
|
eina_inlist_append(Eina_Inlist *list, Eina_Inlist *new_l)
|
|
|
|
{
|
|
|
|
Eina_Inlist *l;
|
|
|
|
|
2008-12-26 10:31:14 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(new_l, list);
|
|
|
|
|
2008-09-18 07:22:48 -07:00
|
|
|
new_l->next = NULL;
|
2010-07-27 19:37:05 -07:00
|
|
|
if (!list)
|
|
|
|
{
|
|
|
|
new_l->prev = NULL;
|
|
|
|
new_l->last = new_l;
|
|
|
|
return new_l;
|
|
|
|
}
|
|
|
|
|
2008-09-18 07:22:48 -07:00
|
|
|
if (list->last)
|
2013-03-17 03:00:49 -07:00
|
|
|
l = list->last;
|
2008-09-18 07:22:48 -07:00
|
|
|
else
|
2013-03-17 03:00:49 -07:00
|
|
|
for (l = list; (l) && (l->next); l = l->next)
|
|
|
|
;
|
2010-07-27 19:37:05 -07:00
|
|
|
|
2008-09-18 07:22:48 -07:00
|
|
|
l->next = new_l;
|
|
|
|
new_l->prev = l;
|
|
|
|
list->last = new_l;
|
|
|
|
return list;
|
2008-07-30 05:46:55 -07:00
|
|
|
}
|
2009-06-22 13:03:58 -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 Eina_Inlist *
|
2008-09-18 07:22:48 -07:00
|
|
|
eina_inlist_prepend(Eina_Inlist *list, Eina_Inlist *new_l)
|
|
|
|
{
|
2008-12-26 10:31:14 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(new_l, list);
|
|
|
|
|
2008-09-18 07:22:48 -07:00
|
|
|
new_l->prev = NULL;
|
2010-07-27 19:37:05 -07:00
|
|
|
if (!list)
|
|
|
|
{
|
|
|
|
new_l->next = NULL;
|
|
|
|
new_l->last = new_l;
|
|
|
|
return new_l;
|
|
|
|
}
|
|
|
|
|
2008-09-18 07:22:48 -07:00
|
|
|
new_l->next = list;
|
|
|
|
list->prev = new_l;
|
|
|
|
new_l->last = list->last;
|
|
|
|
list->last = NULL;
|
|
|
|
return new_l;
|
2008-07-30 05:46:55 -07:00
|
|
|
}
|
2009-06-22 13:03:58 -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 Eina_Inlist *
|
2008-09-18 07:22:48 -07:00
|
|
|
eina_inlist_append_relative(Eina_Inlist *list,
|
2010-07-27 19:37:05 -07:00
|
|
|
Eina_Inlist *new_l,
|
|
|
|
Eina_Inlist *relative)
|
2008-09-18 07:22:48 -07:00
|
|
|
{
|
2008-12-26 10:31:14 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(new_l, list);
|
|
|
|
|
2014-01-19 22:16:56 -08:00
|
|
|
if ((relative) && (list))
|
2010-07-27 19:37:05 -07:00
|
|
|
{
|
|
|
|
if (relative->next)
|
|
|
|
{
|
|
|
|
new_l->next = relative->next;
|
|
|
|
relative->next->prev = new_l;
|
|
|
|
}
|
|
|
|
else
|
2013-03-17 03:00:49 -07:00
|
|
|
new_l->next = NULL;
|
2010-07-27 19:37:05 -07:00
|
|
|
|
|
|
|
relative->next = new_l;
|
|
|
|
new_l->prev = relative;
|
|
|
|
if (!new_l->next)
|
2013-03-17 03:00:49 -07:00
|
|
|
list->last = new_l;
|
2010-07-27 19:37:05 -07:00
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2008-09-18 07:22:48 -07:00
|
|
|
return eina_inlist_append(list, new_l);
|
2008-07-30 05:46:55 -07:00
|
|
|
}
|
2009-06-22 13:03:58 -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 Eina_Inlist *
|
2008-09-18 07:22:48 -07:00
|
|
|
eina_inlist_prepend_relative(Eina_Inlist *list,
|
2010-07-27 19:37:05 -07:00
|
|
|
Eina_Inlist *new_l,
|
|
|
|
Eina_Inlist *relative)
|
2008-09-18 07:22:48 -07:00
|
|
|
{
|
2008-12-26 10:31:14 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(new_l, list);
|
|
|
|
|
2014-01-19 22:16:56 -08:00
|
|
|
if ((relative) && (list))
|
2010-07-27 19:37:05 -07:00
|
|
|
{
|
|
|
|
new_l->prev = relative->prev;
|
|
|
|
new_l->next = relative;
|
|
|
|
relative->prev = new_l;
|
|
|
|
if (new_l->prev)
|
|
|
|
{
|
|
|
|
new_l->prev->next = new_l;
|
|
|
|
/* new_l->next could not be NULL, as it was set to 'relative' */
|
|
|
|
assert(new_l->next);
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* new_l->next could not be NULL, as it was set to 'relative' */
|
|
|
|
assert(new_l->next);
|
|
|
|
|
|
|
|
new_l->last = list->last;
|
|
|
|
list->last = NULL;
|
|
|
|
return new_l;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-18 07:22:48 -07:00
|
|
|
return eina_inlist_prepend(list, new_l);
|
2008-07-30 05:46:55 -07:00
|
|
|
}
|
2009-06-22 13:03:58 -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 Eina_Inlist *
|
2008-09-18 07:22:48 -07:00
|
|
|
eina_inlist_remove(Eina_Inlist *list, Eina_Inlist *item)
|
|
|
|
{
|
|
|
|
Eina_Inlist *return_l;
|
|
|
|
|
|
|
|
/* checkme */
|
2008-12-26 10:31:14 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(list, NULL);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(item, list);
|
2010-11-18 21:43:28 -08:00
|
|
|
if (EINA_UNLIKELY((item != list) && (!item->prev) && (!item->next)))
|
|
|
|
{
|
|
|
|
EINA_LOG_ERR("safety check failed: item %p does not appear to be part of an inlist!", item);
|
|
|
|
return list;
|
|
|
|
}
|
2008-09-18 07:22:48 -07:00
|
|
|
|
|
|
|
if (item->next)
|
2013-03-17 03:00:49 -07:00
|
|
|
item->next->prev = item->prev;
|
2010-07-27 19:37:05 -07:00
|
|
|
|
|
|
|
if (item->prev)
|
|
|
|
{
|
|
|
|
item->prev->next = item->next;
|
|
|
|
return_l = list;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return_l = item->next;
|
|
|
|
if (return_l)
|
2013-03-17 03:00:49 -07:00
|
|
|
return_l->last = list->last;
|
2010-07-27 19:37:05 -07:00
|
|
|
}
|
2008-09-18 07:22:48 -07:00
|
|
|
|
|
|
|
if (item == list->last)
|
2013-03-17 03:00:49 -07:00
|
|
|
list->last = item->prev;
|
2010-07-27 19:37:05 -07:00
|
|
|
|
2008-09-18 07:22:48 -07:00
|
|
|
item->next = NULL;
|
|
|
|
item->prev = NULL;
|
|
|
|
return return_l;
|
2008-07-30 05:46:55 -07:00
|
|
|
}
|
2009-06-22 13:03:58 -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 Eina_Inlist *
|
2008-10-01 09:30:30 -07:00
|
|
|
eina_inlist_promote(Eina_Inlist *list, Eina_Inlist *item)
|
|
|
|
{
|
2008-12-26 10:31:14 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(list, NULL);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(item, list);
|
|
|
|
|
2010-07-27 19:37:05 -07:00
|
|
|
if (item == list)
|
2013-03-17 03:00:49 -07:00
|
|
|
return list;
|
2008-10-01 09:30:30 -07:00
|
|
|
|
|
|
|
if (item->next)
|
2013-03-17 03:00:49 -07:00
|
|
|
item->next->prev = item->prev;
|
2010-07-27 19:37:05 -07:00
|
|
|
|
2008-10-01 09:30:30 -07:00
|
|
|
item->prev->next = item->next;
|
|
|
|
|
|
|
|
if (list->last == item)
|
2013-03-17 03:00:49 -07:00
|
|
|
list->last = item->prev;
|
2008-10-01 09:30:30 -07:00
|
|
|
|
|
|
|
item->next = list;
|
|
|
|
item->prev = NULL;
|
|
|
|
item->last = list->last;
|
|
|
|
|
|
|
|
list->prev = item;
|
|
|
|
list->last = NULL;
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
2009-06-22 13:03:58 -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 Eina_Inlist *
|
2008-10-01 09:30:30 -07:00
|
|
|
eina_inlist_demote(Eina_Inlist *list, Eina_Inlist *item)
|
|
|
|
{
|
|
|
|
Eina_Inlist *l;
|
|
|
|
|
2008-12-26 10:31:14 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(list, NULL);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(item, list);
|
|
|
|
|
2010-07-27 19:37:05 -07:00
|
|
|
if (list->last == item)
|
2013-03-17 03:00:49 -07:00
|
|
|
return list;
|
2008-10-01 09:30:30 -07:00
|
|
|
|
|
|
|
if (!list->last)
|
|
|
|
{
|
2010-07-27 19:37:05 -07:00
|
|
|
for (l = list; l->next; l = l->next)
|
2013-03-17 03:00:49 -07:00
|
|
|
;
|
2010-07-27 19:37:05 -07:00
|
|
|
list->last = l;
|
2008-10-01 09:30:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
l = list;
|
|
|
|
if (item->prev)
|
2013-03-17 03:00:49 -07:00
|
|
|
item->prev->next = item->next;
|
2008-10-01 09:30:30 -07:00
|
|
|
else
|
2013-03-17 03:00:49 -07:00
|
|
|
l = item->next;
|
2010-07-27 19:37:05 -07:00
|
|
|
|
2008-10-01 09:30:30 -07:00
|
|
|
item->next->prev = item->prev;
|
|
|
|
|
|
|
|
list->last->next = item;
|
|
|
|
item->prev = list->last;
|
|
|
|
item->next = NULL;
|
|
|
|
|
|
|
|
l->last = item;
|
|
|
|
return l;
|
|
|
|
}
|
2009-06-22 13:03:58 -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 Eina_Inlist *
|
2008-09-18 07:22:48 -07:00
|
|
|
eina_inlist_find(Eina_Inlist *list, Eina_Inlist *item)
|
|
|
|
{
|
|
|
|
Eina_Inlist *l;
|
|
|
|
|
2012-01-20 20:20:32 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
|
|
|
|
|
2013-03-17 03:00:49 -07:00
|
|
|
for (l = list; l; l = l->next)
|
|
|
|
{
|
2010-07-27 19:37:05 -07:00
|
|
|
if (l == item)
|
2013-03-17 03:00:49 -07:00
|
|
|
return item;
|
2010-07-27 19:37:05 -07:00
|
|
|
}
|
2008-09-18 07:22:48 -07:00
|
|
|
return NULL;
|
2008-07-30 05:46:55 -07:00
|
|
|
}
|
2008-08-12 08:58:41 -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 unsigned int
|
2009-03-13 04:32:56 -07:00
|
|
|
eina_inlist_count(const Eina_Inlist *list)
|
|
|
|
{
|
|
|
|
const Eina_Inlist *l;
|
|
|
|
unsigned int i = 0;
|
|
|
|
|
|
|
|
for (l = list; l; l = l->next)
|
2013-02-07 00:03:44 -08:00
|
|
|
i++;
|
2009-03-13 04:32:56 -07:00
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
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 int
|
2011-09-05 13:15:12 -07:00
|
|
|
eina_inlist_sorted_state_init(Eina_Inlist_Sorted_State *state, Eina_Inlist *list)
|
|
|
|
{
|
|
|
|
Eina_Inlist *ct = NULL;
|
|
|
|
int count = 0;
|
|
|
|
int jump_count = 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* prepare a jump table to avoid doing unnecessary rewalk
|
|
|
|
* of the inlist as much as possible.
|
|
|
|
*/
|
|
|
|
for (ct = list; ct; ct = ct->next, jump_count++, count++)
|
|
|
|
{
|
|
|
|
if (jump_count == state->jump_div)
|
|
|
|
{
|
|
|
|
if (state->jump_limit == EINA_INLIST_JUMP_SIZE)
|
|
|
|
{
|
2011-09-14 15:04:37 -07:00
|
|
|
_eina_inlist_sorted_state_compact(state);
|
2011-09-05 13:15:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
state->jump_table[state->jump_limit] = ct;
|
|
|
|
state->jump_limit++;
|
|
|
|
jump_count = 0;
|
|
|
|
}
|
|
|
|
}
|
2011-09-14 15:04:37 -07:00
|
|
|
|
|
|
|
state->inserted = count;
|
|
|
|
return count;
|
2011-09-05 13:15:12 -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 Eina_Inlist_Sorted_State *
|
2011-09-05 13:15:12 -07:00
|
|
|
eina_inlist_sorted_state_new(void)
|
|
|
|
{
|
|
|
|
Eina_Inlist_Sorted_State *r;
|
|
|
|
|
|
|
|
r = calloc(1, sizeof (Eina_Inlist_Sorted_State));
|
|
|
|
if (!r) return NULL;
|
|
|
|
|
|
|
|
r->jump_div = 1;
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
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
|
2011-09-05 13:15:12 -07:00
|
|
|
eina_inlist_sorted_state_free(Eina_Inlist_Sorted_State *state)
|
|
|
|
{
|
|
|
|
free(state);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_eina_inlist_sorted_state_insert(Eina_Inlist_Sorted_State *state,
|
2011-11-14 13:37:25 -08:00
|
|
|
unsigned short idx,
|
2011-09-05 13:15:12 -07:00
|
|
|
int offset)
|
|
|
|
{
|
|
|
|
Eina_Inlist *last;
|
|
|
|
int jump_count;
|
2011-09-14 15:04:37 -07:00
|
|
|
int start;
|
2011-09-05 13:15:12 -07:00
|
|
|
|
|
|
|
state->inserted++;
|
|
|
|
|
2011-11-14 13:37:25 -08:00
|
|
|
if (offset != 0) idx++;
|
|
|
|
for (; idx < state->jump_limit; idx++)
|
2011-09-05 13:15:12 -07:00
|
|
|
{
|
2011-11-14 13:37:25 -08:00
|
|
|
state->jump_table[idx] = state->jump_table[idx]->prev;
|
2011-09-05 13:15:12 -07:00
|
|
|
}
|
|
|
|
|
2011-09-14 15:04:37 -07:00
|
|
|
start = state->jump_limit - 3;
|
|
|
|
if (start < 0)
|
|
|
|
start = 0;
|
2011-09-05 13:15:12 -07:00
|
|
|
|
2011-09-14 15:04:37 -07:00
|
|
|
last = state->jump_table[start];
|
|
|
|
start++;
|
|
|
|
|
|
|
|
/* Correctly rebuild end of list */
|
|
|
|
for (jump_count = 0; last->next != NULL; last = last->next, jump_count++)
|
2011-09-05 13:15:12 -07:00
|
|
|
{
|
2011-09-14 15:04:37 -07:00
|
|
|
if (jump_count == state->jump_div)
|
2011-09-05 13:15:12 -07:00
|
|
|
{
|
2011-09-14 15:04:37 -07:00
|
|
|
if (state->jump_limit == start)
|
|
|
|
{
|
|
|
|
if (state->jump_limit == EINA_INLIST_JUMP_SIZE)
|
|
|
|
{
|
|
|
|
_eina_inlist_sorted_state_compact(state);
|
|
|
|
start = state->jump_limit - 1;
|
|
|
|
continue ;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
state->jump_limit++;
|
|
|
|
}
|
|
|
|
}
|
2011-09-05 13:15:12 -07:00
|
|
|
|
2011-09-14 15:04:37 -07:00
|
|
|
state->jump_table[start++] = last;
|
2011-11-14 13:37:42 -08:00
|
|
|
jump_count = 0;
|
2011-09-05 13:15:12 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-05-24 08:17:56 -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 Eina_Inlist *
|
2011-05-24 08:17:56 -07:00
|
|
|
eina_inlist_sorted_insert(Eina_Inlist *list,
|
2013-03-17 03:00:49 -07:00
|
|
|
Eina_Inlist *item,
|
|
|
|
Eina_Compare_Cb func)
|
2011-05-24 08:17:56 -07:00
|
|
|
{
|
|
|
|
Eina_Inlist *ct = NULL;
|
2011-09-05 13:15:12 -07:00
|
|
|
Eina_Inlist_Sorted_State state;
|
2011-05-24 08:17:56 -07:00
|
|
|
int cmp = 0;
|
|
|
|
int inf, sup;
|
|
|
|
int cur = 0;
|
2011-09-14 15:04:37 -07:00
|
|
|
int count;
|
2011-05-24 08:17:56 -07:00
|
|
|
|
2012-01-20 20:20:32 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(item, list);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(func, list);
|
|
|
|
|
2011-05-24 08:17:56 -07:00
|
|
|
if (!list) return eina_inlist_append(NULL, item);
|
|
|
|
|
|
|
|
if (!list->next)
|
|
|
|
{
|
|
|
|
cmp = func(list, item);
|
|
|
|
|
|
|
|
if (cmp < 0)
|
|
|
|
return eina_inlist_append(list, item);
|
|
|
|
return eina_inlist_prepend(list, item);
|
|
|
|
}
|
|
|
|
|
2011-09-05 13:15:12 -07:00
|
|
|
state.jump_div = 1;
|
|
|
|
state.jump_limit = 0;
|
2011-09-14 15:04:37 -07:00
|
|
|
count = eina_inlist_sorted_state_init(&state, list);
|
2011-09-05 13:15:12 -07:00
|
|
|
|
2011-05-24 08:17:56 -07:00
|
|
|
/*
|
2011-09-05 13:15:12 -07:00
|
|
|
* now do a dychotomic search directly inside the jump_table.
|
2011-05-24 08:17:56 -07:00
|
|
|
*/
|
2011-09-05 13:15:12 -07:00
|
|
|
inf = 0;
|
|
|
|
sup = state.jump_limit - 1;
|
|
|
|
cur = 0;
|
|
|
|
ct = state.jump_table[cur];
|
|
|
|
cmp = func(ct, item);
|
|
|
|
|
|
|
|
while (inf <= sup)
|
2011-05-24 08:17:56 -07:00
|
|
|
{
|
2011-09-05 13:15:12 -07:00
|
|
|
cur = inf + ((sup - inf) >> 1);
|
|
|
|
ct = state.jump_table[cur];
|
|
|
|
|
|
|
|
cmp = func(ct, item);
|
|
|
|
if (cmp == 0)
|
|
|
|
break ;
|
|
|
|
else if (cmp < 0)
|
|
|
|
inf = cur + 1;
|
2014-08-14 02:29:32 -07:00
|
|
|
else
|
2011-05-24 08:17:56 -07:00
|
|
|
{
|
2011-09-05 13:15:12 -07:00
|
|
|
if (cur > 0)
|
|
|
|
sup = cur - 1;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-05-24 08:17:56 -07:00
|
|
|
|
2011-09-05 13:15:12 -07:00
|
|
|
/* If at the beginning of the table and cmp < 0,
|
|
|
|
* insert just after the head */
|
|
|
|
if (cur == 0 && cmp > 0)
|
|
|
|
return eina_inlist_prepend_relative(list, item, ct);
|
2011-05-24 08:17:56 -07:00
|
|
|
|
2011-09-05 13:15:12 -07:00
|
|
|
/* If at the end of the table and cmp >= 0,
|
|
|
|
* just append the item to the list */
|
|
|
|
if (cmp < 0 && ct == list->last)
|
|
|
|
return eina_inlist_append(list, item);
|
2011-05-24 08:17:56 -07:00
|
|
|
|
2011-09-05 13:15:12 -07:00
|
|
|
/*
|
|
|
|
* Now do a dychotomic search between two entries inside the jump_table
|
|
|
|
*/
|
|
|
|
cur *= state.jump_div;
|
2011-09-14 15:04:37 -07:00
|
|
|
inf = cur - state.jump_div - 1;
|
|
|
|
sup = cur + state.jump_div + 1;
|
2011-09-05 13:15:12 -07:00
|
|
|
|
|
|
|
if (sup > count - 1) sup = count - 1;
|
|
|
|
if (inf < 0) inf = 0;
|
|
|
|
|
|
|
|
while (inf <= sup)
|
|
|
|
{
|
|
|
|
int tmp = cur;
|
|
|
|
|
|
|
|
cur = inf + ((sup - inf) >> 1);
|
|
|
|
if (tmp < cur)
|
|
|
|
for (; tmp != cur; tmp++, ct = ct->next);
|
|
|
|
else if (tmp > cur)
|
|
|
|
for (; tmp != cur; tmp--, ct = ct->prev);
|
|
|
|
|
|
|
|
cmp = func(ct, item);
|
|
|
|
if (cmp == 0)
|
|
|
|
break ;
|
|
|
|
else if (cmp < 0)
|
|
|
|
inf = cur + 1;
|
2014-09-29 10:47:09 -07:00
|
|
|
else
|
2011-09-05 13:15:12 -07:00
|
|
|
{
|
|
|
|
if (cur > 0)
|
|
|
|
sup = cur - 1;
|
|
|
|
else
|
|
|
|
break;
|
2011-05-24 08:17:56 -07:00
|
|
|
}
|
2011-09-05 13:15:12 -07:00
|
|
|
}
|
|
|
|
|
2011-09-14 15:04:37 -07:00
|
|
|
if (cmp <= 0)
|
2011-09-05 13:15:12 -07:00
|
|
|
return eina_inlist_append_relative(list, item, ct);
|
|
|
|
return eina_inlist_prepend_relative(list, item, ct);
|
|
|
|
}
|
|
|
|
|
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_Inlist *
|
2011-09-05 13:15:12 -07:00
|
|
|
eina_inlist_sorted_state_insert(Eina_Inlist *list,
|
|
|
|
Eina_Inlist *item,
|
|
|
|
Eina_Compare_Cb func,
|
|
|
|
Eina_Inlist_Sorted_State *state)
|
|
|
|
{
|
|
|
|
Eina_Inlist *ct = NULL;
|
|
|
|
int cmp = 0;
|
|
|
|
int inf, sup;
|
|
|
|
int cur = 0;
|
2011-09-14 15:04:37 -07:00
|
|
|
int count;
|
2011-09-05 13:15:12 -07:00
|
|
|
unsigned short head;
|
|
|
|
unsigned int offset;
|
|
|
|
|
|
|
|
if (!list)
|
|
|
|
{
|
|
|
|
state->inserted = 1;
|
|
|
|
state->jump_limit = 1;
|
|
|
|
state->jump_table[0] = item;
|
|
|
|
return eina_inlist_append(NULL, item);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!list->next)
|
|
|
|
{
|
|
|
|
cmp = func(list, item);
|
|
|
|
|
|
|
|
state->jump_limit = 2;
|
|
|
|
state->inserted = 2;
|
|
|
|
|
|
|
|
if (cmp < 0)
|
|
|
|
{
|
|
|
|
state->jump_table[1] = item;
|
|
|
|
return eina_inlist_append(list, item);
|
|
|
|
}
|
|
|
|
state->jump_table[1] = state->jump_table[0];
|
|
|
|
state->jump_table[0] = item;
|
|
|
|
return eina_inlist_prepend(list, item);
|
2011-05-24 08:17:56 -07:00
|
|
|
}
|
|
|
|
|
2011-09-14 15:04:37 -07:00
|
|
|
count = state->inserted;
|
|
|
|
|
2011-05-24 08:17:56 -07:00
|
|
|
/*
|
|
|
|
* now do a dychotomic search directly inside the jump_table.
|
|
|
|
*/
|
|
|
|
inf = 0;
|
2011-09-05 13:15:12 -07:00
|
|
|
sup = state->jump_limit - 1;
|
2011-05-24 08:17:56 -07:00
|
|
|
cur = 0;
|
2011-09-05 13:15:12 -07:00
|
|
|
ct = state->jump_table[cur];
|
2011-05-25 06:18:21 -07:00
|
|
|
cmp = func(ct, item);
|
2011-05-24 08:17:56 -07:00
|
|
|
|
|
|
|
while (inf <= sup)
|
|
|
|
{
|
|
|
|
cur = inf + ((sup - inf) >> 1);
|
2011-09-05 13:15:12 -07:00
|
|
|
ct = state->jump_table[cur];
|
2011-05-24 08:17:56 -07:00
|
|
|
|
|
|
|
cmp = func(ct, item);
|
|
|
|
if (cmp == 0)
|
|
|
|
break ;
|
|
|
|
else if (cmp < 0)
|
|
|
|
inf = cur + 1;
|
2014-08-14 02:31:04 -07:00
|
|
|
else
|
2011-05-24 08:17:56 -07:00
|
|
|
{
|
|
|
|
if (cur > 0)
|
|
|
|
sup = cur - 1;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If at the beginning of the table and cmp < 0,
|
|
|
|
* insert just after the head */
|
2011-05-25 06:18:21 -07:00
|
|
|
if (cur == 0 && cmp > 0)
|
2011-09-05 13:15:12 -07:00
|
|
|
{
|
|
|
|
ct = eina_inlist_prepend_relative(list, item, ct);
|
|
|
|
_eina_inlist_sorted_state_insert(state, 0, 0);
|
|
|
|
return ct;
|
|
|
|
}
|
2011-05-24 08:17:56 -07:00
|
|
|
|
|
|
|
/* If at the end of the table and cmp >= 0,
|
|
|
|
* just append the item to the list */
|
2011-05-25 06:18:21 -07:00
|
|
|
if (cmp < 0 && ct == list->last)
|
2011-09-05 13:15:12 -07:00
|
|
|
{
|
|
|
|
ct = eina_inlist_append(list, item);
|
|
|
|
_eina_inlist_sorted_state_insert(state, state->jump_limit - 1, 1);
|
|
|
|
return ct;
|
|
|
|
}
|
2011-05-24 08:17:56 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Now do a dychotomic search between two entries inside the jump_table
|
|
|
|
*/
|
2011-09-05 13:15:12 -07:00
|
|
|
cur *= state->jump_div;
|
2011-09-14 15:04:37 -07:00
|
|
|
inf = cur - state->jump_div - 1;
|
|
|
|
sup = cur + state->jump_div + 1;
|
2011-05-24 08:17:56 -07:00
|
|
|
|
|
|
|
if (sup > count - 1) sup = count - 1;
|
2011-09-14 15:04:37 -07:00
|
|
|
if (inf < 0) inf = 0;
|
2011-05-24 08:17:56 -07:00
|
|
|
|
|
|
|
while (inf <= sup)
|
|
|
|
{
|
|
|
|
int tmp = cur;
|
|
|
|
|
|
|
|
cur = inf + ((sup - inf) >> 1);
|
|
|
|
if (tmp < cur)
|
|
|
|
for (; tmp != cur; tmp++, ct = ct->next);
|
|
|
|
else if (tmp > cur)
|
|
|
|
for (; tmp != cur; tmp--, ct = ct->prev);
|
|
|
|
|
|
|
|
cmp = func(ct, item);
|
|
|
|
if (cmp == 0)
|
|
|
|
break ;
|
|
|
|
else if (cmp < 0)
|
|
|
|
inf = cur + 1;
|
|
|
|
else if (cmp > 0)
|
|
|
|
{
|
|
|
|
if (cur > 0)
|
|
|
|
sup = cur - 1;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-14 15:04:37 -07:00
|
|
|
if (cmp <= 0)
|
2011-09-05 13:15:12 -07:00
|
|
|
{
|
|
|
|
cur++;
|
|
|
|
|
|
|
|
ct = eina_inlist_append_relative(list, item, ct);
|
|
|
|
}
|
2011-09-14 15:04:37 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
ct = eina_inlist_prepend_relative(list, item, ct);
|
|
|
|
}
|
|
|
|
|
2011-09-05 13:15:12 -07:00
|
|
|
head = cur / state->jump_div;
|
|
|
|
offset = cur % state->jump_div;
|
|
|
|
|
|
|
|
_eina_inlist_sorted_state_insert(state, head, offset);
|
|
|
|
return ct;
|
2011-05-24 08:17:56 -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 Eina_Inlist *
|
2011-04-11 02:55:27 -07:00
|
|
|
eina_inlist_sort(Eina_Inlist *head, Eina_Compare_Cb func)
|
|
|
|
{
|
2013-03-17 03:00:49 -07:00
|
|
|
unsigned int i = 0;
|
|
|
|
unsigned int n = 0;
|
|
|
|
Eina_Inlist *tail = head;
|
|
|
|
Eina_Inlist *stack[EINA_INLIST_SORT_STACK_SIZE];
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(head, NULL);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(func, head);
|
|
|
|
|
|
|
|
while (tail)
|
|
|
|
{
|
|
|
|
unsigned int idx, tmp;
|
|
|
|
|
|
|
|
Eina_Inlist *a = tail;
|
|
|
|
Eina_Inlist *b = tail->next;
|
|
|
|
|
|
|
|
if (!b)
|
|
|
|
{
|
|
|
|
stack[i++] = a;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
tail = b->next;
|
|
|
|
|
|
|
|
if (func(a, b) < 0)
|
|
|
|
((stack[i++] = a)->next = b)->next = 0;
|
|
|
|
else
|
|
|
|
((stack[i++] = b)->next = a)->next = 0;
|
|
|
|
|
|
|
|
tmp = n++;
|
|
|
|
for (idx = n ^ tmp; idx &= idx - 1; i--)
|
|
|
|
stack[i - 2] = eina_inlist_sort_merge(stack[i - 2], stack[i - 1], func);
|
2011-04-11 02:55:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
while (i-- > 1)
|
2013-03-17 03:00:49 -07:00
|
|
|
stack[i - 1] = eina_inlist_sort_merge(stack[i - 1], stack[i], func);
|
2011-04-11 02:55:27 -07:00
|
|
|
|
|
|
|
head = stack[0];
|
|
|
|
tail = eina_inlist_sort_rebuild_prev(head);
|
|
|
|
|
|
|
|
head->last = tail;
|
|
|
|
|
|
|
|
return head;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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_Iterator *
|
2008-09-18 07:22:48 -07:00
|
|
|
eina_inlist_iterator_new(const Eina_Inlist *list)
|
|
|
|
{
|
|
|
|
Eina_Iterator_Inlist *it;
|
2008-08-12 08:58:41 -07:00
|
|
|
|
2008-09-18 07:22:48 -07:00
|
|
|
it = calloc(1, sizeof (Eina_Iterator_Inlist));
|
2013-10-11 00:49:13 -07:00
|
|
|
if (!it) return NULL;
|
2008-08-12 08:58:41 -07:00
|
|
|
|
2008-09-18 07:22:48 -07:00
|
|
|
it->head = list;
|
|
|
|
it->current = list;
|
2008-08-12 08:58:41 -07:00
|
|
|
|
2010-08-19 05:02:28 -07:00
|
|
|
it->iterator.version = EINA_ITERATOR_VERSION;
|
2008-09-18 07:22:48 -07:00
|
|
|
it->iterator.next = FUNC_ITERATOR_NEXT(eina_inlist_iterator_next);
|
2010-07-27 19:37:05 -07:00
|
|
|
it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
|
2013-03-17 03:00:49 -07:00
|
|
|
eina_inlist_iterator_get_container);
|
2008-09-18 07:22:48 -07:00
|
|
|
it->iterator.free = FUNC_ITERATOR_FREE(eina_inlist_iterator_free);
|
2008-08-12 08:58:41 -07:00
|
|
|
|
2008-12-05 22:17:11 -08:00
|
|
|
EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
|
|
|
|
|
2008-09-18 07:22:48 -07:00
|
|
|
return &it->iterator;
|
2008-08-12 08:58:41 -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 Eina_Accessor *
|
2008-09-18 07:22:48 -07:00
|
|
|
eina_inlist_accessor_new(const Eina_Inlist *list)
|
|
|
|
{
|
2010-09-11 23:49:57 -07:00
|
|
|
Eina_Accessor_Inlist *ac;
|
2008-08-12 08:58:41 -07:00
|
|
|
|
2010-09-11 23:49:57 -07:00
|
|
|
ac = calloc(1, sizeof (Eina_Accessor_Inlist));
|
2013-10-11 00:49:13 -07:00
|
|
|
if (!ac) return NULL;
|
2008-08-12 08:58:41 -07:00
|
|
|
|
2010-09-11 23:49:57 -07:00
|
|
|
ac->head = list;
|
|
|
|
ac->current = list;
|
|
|
|
ac->index = 0;
|
2008-08-12 08:58:41 -07:00
|
|
|
|
2010-09-11 23:49:57 -07:00
|
|
|
ac->accessor.version = EINA_ACCESSOR_VERSION;
|
|
|
|
ac->accessor.get_at = FUNC_ACCESSOR_GET_AT(eina_inlist_accessor_get_at);
|
|
|
|
ac->accessor.get_container = FUNC_ACCESSOR_GET_CONTAINER(
|
2013-03-17 03:00:49 -07:00
|
|
|
eina_inlist_accessor_get_container);
|
2010-09-11 23:49:57 -07:00
|
|
|
ac->accessor.free = FUNC_ACCESSOR_FREE(eina_inlist_accessor_free);
|
2008-08-12 08:58:41 -07:00
|
|
|
|
2010-09-11 23:49:57 -07:00
|
|
|
EINA_MAGIC_SET(&ac->accessor, EINA_MAGIC_ACCESSOR);
|
2008-12-05 22:17:11 -08:00
|
|
|
|
2010-09-11 23:49:57 -07:00
|
|
|
return &ac->accessor;
|
2008-08-12 08:58:41 -07:00
|
|
|
}
|