forked from enlightenment/efl
parent
98ced4dd20
commit
ca6d71618b
|
@ -14,6 +14,7 @@ eina_hash.h \
|
||||||
eina_inline_hash.x \
|
eina_inline_hash.x \
|
||||||
eina_lalloc.h \
|
eina_lalloc.h \
|
||||||
eina_clist.h \
|
eina_clist.h \
|
||||||
|
eina_inline_clist.x \
|
||||||
eina_inlist.h \
|
eina_inlist.h \
|
||||||
eina_list.h \
|
eina_list.h \
|
||||||
eina_file.h \
|
eina_file.h \
|
||||||
|
|
|
@ -135,13 +135,7 @@ struct _Eina_Clist
|
||||||
* @note There's no need to initialize an element before adding it to the list.
|
* @note There's no need to initialize an element before adding it to the list.
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
static inline void eina_clist_add_after(Eina_Clist *elem, Eina_Clist *to_add)
|
static inline void eina_clist_add_after(Eina_Clist *elem, Eina_Clist *to_add);
|
||||||
{
|
|
||||||
to_add->next = elem->next;
|
|
||||||
to_add->prev = elem;
|
|
||||||
elem->next->prev = to_add;
|
|
||||||
elem->next = to_add;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an element before the specified one.
|
* Add an element before the specified one.
|
||||||
|
@ -154,13 +148,7 @@ static inline void eina_clist_add_after(Eina_Clist *elem, Eina_Clist *to_add)
|
||||||
* @note There's no need to initialize an element before adding it to the list.
|
* @note There's no need to initialize an element before adding it to the list.
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
static inline void eina_clist_add_before(Eina_Clist *elem, Eina_Clist *to_add)
|
static inline void eina_clist_add_before(Eina_Clist *elem, Eina_Clist *to_add);
|
||||||
{
|
|
||||||
to_add->next = elem;
|
|
||||||
to_add->prev = elem->prev;
|
|
||||||
elem->prev->next = to_add;
|
|
||||||
elem->prev = to_add;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add element at the head of the list.
|
* Add element at the head of the list.
|
||||||
|
@ -173,10 +161,7 @@ static inline void eina_clist_add_before(Eina_Clist *elem, Eina_Clist *to_add)
|
||||||
* @note There's no need to initialize an element before adding it to the list.
|
* @note There's no need to initialize an element before adding it to the list.
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
static inline void eina_clist_add_head(Eina_Clist *list, Eina_Clist *elem)
|
static inline void eina_clist_add_head(Eina_Clist *list, Eina_Clist *elem);
|
||||||
{
|
|
||||||
eina_clist_add_after(list, elem);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add element at the tail of the list.
|
* Add element at the tail of the list.
|
||||||
|
@ -189,10 +174,7 @@ static inline void eina_clist_add_head(Eina_Clist *list, Eina_Clist *elem)
|
||||||
* @note There's no need to initialize an element before adding it to the list.
|
* @note There's no need to initialize an element before adding it to the list.
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
static inline void eina_clist_add_tail(Eina_Clist *list, Eina_Clist *elem)
|
static inline void eina_clist_add_tail(Eina_Clist *list, Eina_Clist *elem);
|
||||||
{
|
|
||||||
eina_clist_add_before(list, elem);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init an (unlinked) element.
|
* Init an (unlinked) element.
|
||||||
|
@ -207,11 +189,7 @@ static inline void eina_clist_add_tail(Eina_Clist *list, Eina_Clist *elem)
|
||||||
* @note It is not necessary to call this before adding an element to this list.
|
* @note It is not necessary to call this before adding an element to this list.
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
static inline void eina_clist_element_init(Eina_Clist *elem)
|
static inline void eina_clist_element_init(Eina_Clist *elem);
|
||||||
{
|
|
||||||
elem->next = NULL;
|
|
||||||
elem->prev = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if an element is in a list or not.
|
* Check if an element is in a list or not.
|
||||||
|
@ -222,10 +200,7 @@ static inline void eina_clist_element_init(Eina_Clist *elem)
|
||||||
* it has been added to a list or remove from a list.
|
* it has been added to a list or remove from a list.
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
static inline int eina_clist_element_is_linked(Eina_Clist *elem)
|
static inline int eina_clist_element_is_linked(Eina_Clist *elem);
|
||||||
{
|
|
||||||
return (elem->next != NULL && elem->prev != NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove an element from its list.
|
* Remove an element from its list.
|
||||||
|
@ -235,12 +210,7 @@ static inline int eina_clist_element_is_linked(Eina_Clist *elem)
|
||||||
* @post The element is marked as not being in any list
|
* @post The element is marked as not being in any list
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
static inline void eina_clist_remove(Eina_Clist *elem)
|
static inline void eina_clist_remove(Eina_Clist *elem);
|
||||||
{
|
|
||||||
elem->next->prev = elem->prev;
|
|
||||||
elem->prev->next = elem->next;
|
|
||||||
eina_clist_element_init(elem);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the next element.
|
* Get the next element.
|
||||||
|
@ -251,12 +221,7 @@ static inline void eina_clist_remove(Eina_Clist *elem)
|
||||||
* @return The element after @elem in @list or NULL if @a elem is last in @a list
|
* @return The element after @elem in @list or NULL if @a elem is last in @a list
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
static inline Eina_Clist *eina_clist_next(const Eina_Clist *list, const Eina_Clist *elem)
|
static inline Eina_Clist *eina_clist_next(const Eina_Clist *list, const Eina_Clist *elem);
|
||||||
{
|
|
||||||
Eina_Clist *ret = elem->next;
|
|
||||||
if (elem->next == list) ret = NULL;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the previous element.
|
* Get the previous element.
|
||||||
|
@ -267,12 +232,7 @@ static inline Eina_Clist *eina_clist_next(const Eina_Clist *list, const Eina_Cli
|
||||||
* @return The element before @a elem or NULL if @a elem is the first in the list
|
* @return The element before @a elem or NULL if @a elem is the first in the list
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
static inline Eina_Clist *eina_clist_prev(const Eina_Clist *list, const Eina_Clist *elem)
|
static inline Eina_Clist *eina_clist_prev(const Eina_Clist *list, const Eina_Clist *elem);
|
||||||
{
|
|
||||||
Eina_Clist *ret = elem->prev;
|
|
||||||
if (elem->prev == list) ret = NULL;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the first element.
|
* Get the first element.
|
||||||
|
@ -281,10 +241,7 @@ static inline Eina_Clist *eina_clist_prev(const Eina_Clist *list, const Eina_Cli
|
||||||
* @returns The first element in @a list or NULL if @a list is empty
|
* @returns The first element in @a list or NULL if @a list is empty
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
static inline Eina_Clist *eina_clist_head(const Eina_Clist *list)
|
static inline Eina_Clist *eina_clist_head(const Eina_Clist *list);
|
||||||
{
|
|
||||||
return eina_clist_next(list, list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the last element.
|
* Get the last element.
|
||||||
|
@ -293,10 +250,7 @@ static inline Eina_Clist *eina_clist_head(const Eina_Clist *list)
|
||||||
* @returns The last element in @a list or NULL if @list is empty
|
* @returns The last element in @a list or NULL if @list is empty
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
static inline Eina_Clist *eina_clist_tail(const Eina_Clist *list)
|
static inline Eina_Clist *eina_clist_tail(const Eina_Clist *list);
|
||||||
{
|
|
||||||
return eina_clist_prev(list, list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a list is empty.
|
* Check if a list is empty.
|
||||||
|
@ -305,10 +259,7 @@ static inline Eina_Clist *eina_clist_tail(const Eina_Clist *list)
|
||||||
* @returns non-zero if @a list is empty, zero if it is not
|
* @returns non-zero if @a list is empty, zero if it is not
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
static inline int eina_clist_empty(const Eina_Clist *list)
|
static inline int eina_clist_empty(const Eina_Clist *list);
|
||||||
{
|
|
||||||
return list->next == list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize a list
|
* Initialize a list
|
||||||
|
@ -322,10 +273,7 @@ static inline int eina_clist_empty(const Eina_Clist *list)
|
||||||
* initialize the list by zero'ing out the list head.
|
* initialize the list by zero'ing out the list head.
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
static inline void eina_clist_init(Eina_Clist *list)
|
static inline void eina_clist_init(Eina_Clist *list);
|
||||||
{
|
|
||||||
list->next = list->prev = list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count the elements of a list
|
* Count the elements of a list
|
||||||
|
@ -334,13 +282,7 @@ static inline void eina_clist_init(Eina_Clist *list)
|
||||||
* @returns The number of items in the list
|
* @returns The number of items in the list
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
static inline unsigned int eina_clist_count(const Eina_Clist *list)
|
static inline unsigned int eina_clist_count(const Eina_Clist *list);
|
||||||
{
|
|
||||||
unsigned count = 0;
|
|
||||||
const Eina_Clist *ptr;
|
|
||||||
for (ptr = list->next; ptr != list; ptr = ptr->next) count++;
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move all elements from src to the tail of dst
|
* Move all elements from src to the tail of dst
|
||||||
|
@ -351,16 +293,7 @@ static inline unsigned int eina_clist_count(const Eina_Clist *list)
|
||||||
* @post @a src is initialized but empty after this operation
|
* @post @a src is initialized but empty after this operation
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
static inline void eina_clist_move_tail(Eina_Clist *dst, Eina_Clist *src)
|
static inline void eina_clist_move_tail(Eina_Clist *dst, Eina_Clist *src);
|
||||||
{
|
|
||||||
if (eina_clist_empty(src)) return;
|
|
||||||
|
|
||||||
dst->prev->next = src->next;
|
|
||||||
src->next->prev = dst->prev;
|
|
||||||
dst->prev = src->prev;
|
|
||||||
src->prev->next = dst;
|
|
||||||
eina_clist_init(src);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* move all elements from src to the head of dst
|
* move all elements from src to the head of dst
|
||||||
|
@ -371,16 +304,7 @@ static inline void eina_clist_move_tail(Eina_Clist *dst, Eina_Clist *src)
|
||||||
* @post @a src is initialized but empty after this operation
|
* @post @a src is initialized but empty after this operation
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
static inline void eina_clist_move_head(Eina_Clist *dst, Eina_Clist *src)
|
static inline void eina_clist_move_head(Eina_Clist *dst, Eina_Clist *src);
|
||||||
{
|
|
||||||
if (eina_clist_empty(src)) return;
|
|
||||||
|
|
||||||
dst->next->prev = src->prev;
|
|
||||||
src->prev->next = dst->next;
|
|
||||||
dst->next = src->next;
|
|
||||||
src->next->prev = dst;
|
|
||||||
eina_clist_init(src);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* iterate through the list
|
* iterate through the list
|
||||||
|
@ -441,6 +365,8 @@ static inline void eina_clist_move_head(Eina_Clist *dst, Eina_Clist *src)
|
||||||
#define EINA_CLIST_ENTRY(elem, type, field) \
|
#define EINA_CLIST_ENTRY(elem, type, field) \
|
||||||
((type *)((char *)(elem) - (unsigned long)(&((type *)0)->field)))
|
((type *)((char *)(elem) - (unsigned long)(&((type *)0)->field)))
|
||||||
|
|
||||||
|
#include "eina_inline_clist.x"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,135 @@
|
||||||
|
/*
|
||||||
|
* Linked lists support
|
||||||
|
*
|
||||||
|
* Copyright (C) 2002 Alexandre Julliard
|
||||||
|
* Copyright (C) 2011 Mike McCormack (adapted for Eina)
|
||||||
|
*
|
||||||
|
* 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, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __EINA_CLIST_INLINE_H__
|
||||||
|
#define __EINA_CLIST_INLINE_H__
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
static inline void eina_clist_add_after(Eina_Clist *elem, Eina_Clist *to_add)
|
||||||
|
{
|
||||||
|
to_add->next = elem->next;
|
||||||
|
to_add->prev = elem;
|
||||||
|
elem->next->prev = to_add;
|
||||||
|
elem->next = to_add;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void eina_clist_add_before(Eina_Clist *elem, Eina_Clist *to_add)
|
||||||
|
{
|
||||||
|
to_add->next = elem;
|
||||||
|
to_add->prev = elem->prev;
|
||||||
|
elem->prev->next = to_add;
|
||||||
|
elem->prev = to_add;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void eina_clist_add_head(Eina_Clist *list, Eina_Clist *elem)
|
||||||
|
{
|
||||||
|
eina_clist_add_after(list, elem);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void eina_clist_add_tail(Eina_Clist *list, Eina_Clist *elem)
|
||||||
|
{
|
||||||
|
eina_clist_add_before(list, elem);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void eina_clist_element_init(Eina_Clist *elem)
|
||||||
|
{
|
||||||
|
elem->next = NULL;
|
||||||
|
elem->prev = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int eina_clist_element_is_linked(Eina_Clist *elem)
|
||||||
|
{
|
||||||
|
return (elem->next != NULL && elem->prev != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void eina_clist_remove(Eina_Clist *elem)
|
||||||
|
{
|
||||||
|
elem->next->prev = elem->prev;
|
||||||
|
elem->prev->next = elem->next;
|
||||||
|
eina_clist_element_init(elem);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Eina_Clist *eina_clist_next(const Eina_Clist *list, const Eina_Clist *elem)
|
||||||
|
{
|
||||||
|
Eina_Clist *ret = elem->next;
|
||||||
|
if (elem->next == list) ret = NULL;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Eina_Clist *eina_clist_prev(const Eina_Clist *list, const Eina_Clist *elem)
|
||||||
|
{
|
||||||
|
Eina_Clist *ret = elem->prev;
|
||||||
|
if (elem->prev == list) ret = NULL;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Eina_Clist *eina_clist_head(const Eina_Clist *list)
|
||||||
|
{
|
||||||
|
return eina_clist_next(list, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Eina_Clist *eina_clist_tail(const Eina_Clist *list)
|
||||||
|
{
|
||||||
|
return eina_clist_prev(list, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int eina_clist_empty(const Eina_Clist *list)
|
||||||
|
{
|
||||||
|
return list->next == list;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void eina_clist_init(Eina_Clist *list)
|
||||||
|
{
|
||||||
|
list->next = list->prev = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned int eina_clist_count(const Eina_Clist *list)
|
||||||
|
{
|
||||||
|
unsigned count = 0;
|
||||||
|
const Eina_Clist *ptr;
|
||||||
|
for (ptr = list->next; ptr != list; ptr = ptr->next) count++;
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void eina_clist_move_tail(Eina_Clist *dst, Eina_Clist *src)
|
||||||
|
{
|
||||||
|
if (eina_clist_empty(src)) return;
|
||||||
|
|
||||||
|
dst->prev->next = src->next;
|
||||||
|
src->next->prev = dst->prev;
|
||||||
|
dst->prev = src->prev;
|
||||||
|
src->prev->next = dst;
|
||||||
|
eina_clist_init(src);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void eina_clist_move_head(Eina_Clist *dst, Eina_Clist *src)
|
||||||
|
{
|
||||||
|
if (eina_clist_empty(src)) return;
|
||||||
|
|
||||||
|
dst->next->prev = src->prev;
|
||||||
|
src->prev->next = dst->next;
|
||||||
|
dst->next = src->next;
|
||||||
|
src->next->prev = dst;
|
||||||
|
eina_clist_init(src);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -31,6 +31,7 @@
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
#ifdef EINA_HAVE_DEBUG_THREADS
|
#ifdef EINA_HAVE_DEBUG_THREADS
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
Loading…
Reference in New Issue