2010-02-28 13:56:33 -08:00
|
|
|
/* EINA - EFL data type library
|
2013-08-19 11:11:48 -07:00
|
|
|
* Copyright (C) 2008-2013 Enlightenment Developers:
|
2010-02-25 16:57:20 -08:00
|
|
|
* Albin "Lutin" Tonnerre <albin.tonnerre@gmail.com>
|
|
|
|
* Alexandre "diaxen" Becoulet <diaxen@free.fr>
|
|
|
|
* Andre Dieb <andre.dieb@gmail.com>
|
|
|
|
* Arnaud de Turckheim "quarium" <quarium@gmail.com>
|
|
|
|
* Carsten Haitzler <raster@rasterman.com>
|
|
|
|
* Cedric Bail <cedric.bail@free.fr>
|
|
|
|
* Corey "atmos" Donohoe <atmos@atmos.org>
|
|
|
|
* Fabiano Fidêncio <fidencio@profusion.mobi>
|
|
|
|
* Gustavo Chaves <glima@profusion.mobi>
|
|
|
|
* Gustavo Sverzut Barbieri <barbieri@gmail.com>
|
|
|
|
* Jorge Luis "turran" Zapata <jorgeluis.zapata@gmail.com>
|
|
|
|
* Peter "pfritz" Wehrfritz <peter.wehrfritz@web.de>
|
|
|
|
* Raphael Kubo da Costa <kubo@profusion.mobi>
|
|
|
|
* Tilman Sauerbeck <tilman@code-monkey.de>
|
|
|
|
* Vincent "caro" Torri <vtorri at univ-evry dot fr>
|
2010-07-27 01:55:23 -07:00
|
|
|
* Tom Hacohen <tom@stosb.com>
|
2012-02-11 10:04:32 -08:00
|
|
|
* Jonas M. Gastal <jgastal@profusion.mobi>
|
2008-08-06 11:15:24 -07:00
|
|
|
*
|
|
|
|
* 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-07-30 05:46:55 -07:00
|
|
|
#ifndef EINA_H_
|
|
|
|
#define EINA_H_
|
|
|
|
|
2011-08-02 21:55:12 -07:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief Eina Utility library
|
|
|
|
*
|
|
|
|
* These routines are used for Eina.
|
|
|
|
*/
|
|
|
|
|
2008-07-30 05:46:55 -07:00
|
|
|
/**
|
2012-12-18 08:12:56 -08:00
|
|
|
* @page eina_main Eina
|
2010-02-25 16:57:20 -08:00
|
|
|
*
|
2012-12-28 15:26:05 -08:00
|
|
|
* @date 2008 (created)
|
2011-12-07 04:07:18 -08:00
|
|
|
*
|
2020-02-28 02:01:56 -08:00
|
|
|
* @section eina_toc Table of Contents
|
2012-12-28 15:26:05 -08:00
|
|
|
*
|
|
|
|
* @li @ref eina_main_intro
|
|
|
|
* @li @ref eina_main_compiling
|
|
|
|
* @li @ref eina_main_next_steps
|
|
|
|
* @li @ref eina_main_intro_example
|
|
|
|
*
|
|
|
|
* @section eina_main_intro Introduction
|
2008-08-27 06:34:04 -07:00
|
|
|
*
|
2017-12-07 08:21:11 -08:00
|
|
|
* The Eina library is a library which implements an API for data types
|
2008-08-27 06:34:04 -07:00
|
|
|
* in an efficient way. It also provides some useful tools like
|
2017-12-07 08:21:11 -08:00
|
|
|
* opening shared libraries, error management, type conversion,
|
|
|
|
* time accounting and memory pools.
|
2008-08-27 06:34:04 -07:00
|
|
|
*
|
|
|
|
* This library is cross-platform and can be compiled and used on
|
2017-12-07 08:21:11 -08:00
|
|
|
* Linux, BSD, and Windows.
|
2008-08-27 06:34:04 -07:00
|
|
|
*
|
2017-12-07 08:21:11 -08:00
|
|
|
* The data types available are (see @ref Eina_Data_Types_Group):
|
2014-10-03 02:36:38 -07:00
|
|
|
* @li @ref Eina_Fp_Group standard floating point numbers.
|
2012-01-17 20:32:37 -08:00
|
|
|
* @li @ref Eina_Inline_Array_Group standard array of inlined members.
|
2010-02-28 13:29:30 -08:00
|
|
|
* @li @ref Eina_Array_Group standard array of @c void* data.
|
|
|
|
* @li @ref Eina_Hash_Group standard hash of @c void* data.
|
|
|
|
* @li @ref Eina_Inline_List_Group list with nodes inlined into user type.
|
2011-12-07 04:07:18 -08:00
|
|
|
* @li @ref Eina_CList_Group Compact List.
|
2010-02-28 13:29:30 -08:00
|
|
|
* @li @ref Eina_List_Group standard list of @c void* data.
|
2011-06-10 06:42:19 -07:00
|
|
|
* @li @ref Eina_Iterator_Group Iterator functions.
|
2010-02-28 13:29:30 -08:00
|
|
|
* @li @ref Eina_Matrixsparse_Group sparse matrix of @c void* data.
|
|
|
|
* @li @ref Eina_Rbtree_Group red-black tree with nodes inlined into user type.
|
2010-03-09 08:36:14 -08:00
|
|
|
* @li @ref Eina_String_Buffer_Group mutable string to prepend, insert or append strings to a buffer.
|
2010-02-28 13:29:30 -08:00
|
|
|
* @li @ref Eina_Stringshare_Group saves memory by sharing read-only string references.
|
|
|
|
* @li @ref Eina_Tiler_Group split, merge and navigates into 2D tiled regions.
|
|
|
|
* @li @ref Eina_Trash_Group container of unused but allocated data.
|
2012-02-11 10:04:32 -08:00
|
|
|
* @li @ref Eina_Value_Group container for generic value storage and access.
|
2010-02-28 13:29:30 -08:00
|
|
|
*
|
2017-12-07 08:21:11 -08:00
|
|
|
* The tools available are (see @ref Eina_Tools_Group):
|
2010-02-28 13:29:30 -08:00
|
|
|
* @li @ref Eina_Benchmark_Group helper to write benchmarks.
|
|
|
|
* @li @ref Eina_Convert_Group faster conversion from strings to integers, double, etc.
|
|
|
|
* @li @ref Eina_Counter_Group measures number of calls and their time.
|
2014-10-03 02:36:38 -07:00
|
|
|
* @li @ref Eina_Cpu_Group Cpu and architecture related helpers.
|
2010-02-28 13:29:30 -08:00
|
|
|
* @li @ref Eina_Error_Group error identifiers.
|
|
|
|
* @li @ref Eina_File_Group simple file list and path split.
|
|
|
|
* @li @ref Eina_Lalloc_Group simple lazy allocator.
|
|
|
|
* @li @ref Eina_Log_Group full-featured logging system.
|
|
|
|
* @li @ref Eina_Magic_Group provides runtime type checking.
|
|
|
|
* @li @ref Eina_Memory_Pool_Group abstraction for various memory allocators.
|
|
|
|
* @li @ref Eina_Module_Group lists, loads and share modules using Eina_Module standard.
|
|
|
|
* @li @ref Eina_Rectangle_Group rectangle structure and standard manipulation methods.
|
|
|
|
* @li @ref Eina_Safety_Checks_Group extra checks that will report unexpected conditions and can be disabled at compile time.
|
2010-03-07 06:38:14 -08:00
|
|
|
* @li @ref Eina_String_Group a set of functions that manages C strings.
|
2012-12-28 15:26:05 -08:00
|
|
|
*
|
|
|
|
* @section eina_main_compiling How to compile
|
|
|
|
*
|
2017-12-07 08:21:11 -08:00
|
|
|
* Eina is a library to which your app can link. The procedure for this is
|
2012-12-28 15:26:05 -08:00
|
|
|
* very simple. You simply have to compile your application with the
|
2017-12-07 08:21:11 -08:00
|
|
|
* appropriate compiler flags as outputted by the @c pkg-config script. For
|
2012-12-28 15:26:05 -08:00
|
|
|
* example:
|
|
|
|
*
|
|
|
|
* Compiling C or C++ files into object files:
|
|
|
|
*
|
|
|
|
* @verbatim
|
|
|
|
gcc -c -o main.o main.c `pkg-config --cflags eina`
|
|
|
|
@endverbatim
|
|
|
|
*
|
|
|
|
* Linking object files into a binary executable:
|
|
|
|
*
|
|
|
|
* @verbatim
|
|
|
|
gcc -o my_application main.o `pkg-config --libs eina`
|
|
|
|
@endverbatim
|
|
|
|
*
|
|
|
|
* See @ref pkgconfig
|
|
|
|
*
|
|
|
|
* @section eina_main_next_steps Next Steps
|
|
|
|
*
|
2017-12-07 08:21:11 -08:00
|
|
|
* After you've understood what Eina is and installed it,
|
|
|
|
* you can now learn more about the the programming interface.
|
2012-12-28 15:26:05 -08:00
|
|
|
*
|
|
|
|
* Recommended reading:
|
|
|
|
*
|
|
|
|
* @li @ref Eina_Data_Types_Group to find about implemented types and
|
|
|
|
* how to use them.
|
|
|
|
* @li @ref Eina_Tools_Group to find about helper tools provided by eina.
|
|
|
|
*
|
|
|
|
* @section eina_main_intro_example Introductory Example
|
|
|
|
*
|
|
|
|
* @include eina_list_01.c
|
|
|
|
*
|
|
|
|
* More examples can be found at @ref eina_examples.
|
|
|
|
*
|
2010-02-28 13:29:30 -08:00
|
|
|
*
|
2020-03-27 02:11:12 -07:00
|
|
|
* @defgroup Eina_Core_Group Core
|
2020-03-27 03:40:57 -07:00
|
|
|
* @brief Initialization, shut down and core types.
|
2020-03-27 02:11:12 -07:00
|
|
|
* @ingroup Eina
|
|
|
|
*
|
2011-12-07 04:07:18 -08:00
|
|
|
* @defgroup Eina_Data_Types_Group Data Types
|
2014-10-27 01:08:42 -07:00
|
|
|
* @brief Eina provides an easy to use and optimized data types and structures.
|
2012-12-18 10:38:25 -08:00
|
|
|
* @ingroup Eina
|
2010-02-28 13:29:30 -08:00
|
|
|
*
|
2012-12-28 11:08:42 -08:00
|
|
|
* @defgroup Eina_Content_Access_Group Content Access
|
2017-11-12 19:04:59 -08:00
|
|
|
* @brief Eina provides a uniform way to access elements of a container,
|
2014-10-27 01:08:42 -07:00
|
|
|
* either sequential or indexed.
|
2012-12-28 11:08:42 -08:00
|
|
|
* @ingroup Eina_Data_Types_Group
|
|
|
|
*
|
2010-02-28 13:29:30 -08:00
|
|
|
* @defgroup Eina_Containers_Group Containers
|
2014-10-27 01:08:42 -07:00
|
|
|
* @brief Data types that contains other types. Examples: list, array and hash.
|
2012-12-28 11:08:42 -08:00
|
|
|
* @ingroup Eina_Data_Types_Group
|
|
|
|
*
|
2012-12-18 08:18:28 -08:00
|
|
|
* @section eina_main_Intro Introduction
|
2008-09-06 22:44:00 -07:00
|
|
|
* Containers are data types that hold data and allow iteration over
|
2010-02-28 13:29:30 -08:00
|
|
|
* their elements with an @ref Eina_Iterator_Group, or eventually an
|
2008-09-07 00:19:19 -07:00
|
|
|
* @ref Eina_Accessor_Group.
|
2008-08-27 06:34:04 -07:00
|
|
|
*
|
2012-02-22 08:20:55 -08:00
|
|
|
* The containers in eina are designed with performance in mind, one consequence
|
|
|
|
* of this is that they @b don't check the validity of data structures given to
|
|
|
|
* them(@ref Eina_Magic_Group).
|
|
|
|
*
|
2012-12-18 08:18:28 -08:00
|
|
|
* @section eina_main_Choice Choosing container type
|
2012-07-17 10:51:10 -07:00
|
|
|
*
|
2012-02-22 08:20:55 -08:00
|
|
|
* The choice of which container to use in each situation is very important in
|
|
|
|
* achieving good performance and readable code. The most common container types
|
2017-12-07 08:21:11 -08:00
|
|
|
* used are:
|
2012-02-22 08:20:55 -08:00
|
|
|
* @li List
|
|
|
|
* @li Inline list
|
|
|
|
* @li Array
|
|
|
|
* @li Inline array
|
|
|
|
* @li Hash
|
|
|
|
*
|
2017-12-07 08:21:11 -08:00
|
|
|
* All types have pros and cons. The following considerations are good
|
2012-02-22 08:20:55 -08:00
|
|
|
* starting point in deciding which container to use:
|
2017-12-07 08:21:11 -08:00
|
|
|
* @li Hashes are appropriate for datasets which will be searched often.
|
|
|
|
* @li Arrays are good when accessing members by position;
|
|
|
|
* @li Lists provide good versatility for adding elements in any position with
|
|
|
|
* minimal overhead.
|
|
|
|
* @li Inline arrays use very little memory and don't cause fragmentation so
|
|
|
|
* are a good option in memory constrained systems.
|
|
|
|
* @li Inline lists are the best type to use when list flexibility is
|
|
|
|
* required but no pointer indirection overhead can be allowed.
|
|
|
|
* @warning These are general considerations. Every situation is different.
|
|
|
|
* Don't follow these recommendations blindly.
|
2009-08-19 00:54:13 -07:00
|
|
|
*
|
2012-12-18 08:18:28 -08:00
|
|
|
* @section eina_main_Creation Creating custom container types
|
2012-07-17 10:51:10 -07:00
|
|
|
*
|
2017-12-07 08:21:11 -08:00
|
|
|
* @note Before creating a custom container check if any of the existing ones
|
|
|
|
* suit your needs. For example, while there is no stack type @ref
|
|
|
|
* Eina_Array_Group is a very good substitute. Similarly there is no queue type
|
2012-07-17 10:51:10 -07:00
|
|
|
* however an @ref Eina_List_Group works very well as a queue.
|
|
|
|
*
|
2017-12-07 08:21:11 -08:00
|
|
|
* If creating a custom container type, consider allowing access to the data in
|
2012-07-17 10:51:10 -07:00
|
|
|
* your container through @ref Eina_Iterator_Group "Iterators" and @ref
|
|
|
|
* Eina_Accessor_Group "Accessors". To do so your container should have an
|
2017-12-07 08:21:11 -08:00
|
|
|
* iterator creation function and an accessor creation function. These functions
|
2012-07-17 10:51:10 -07:00
|
|
|
* should return properly populated @ref _Eina_Iterator and @ref _Eina_Accessor.
|
|
|
|
*
|
2010-02-28 13:29:30 -08:00
|
|
|
* @defgroup Eina_Tools_Group Tools
|
2017-02-19 22:18:21 -08:00
|
|
|
* @ingroup Eina
|
2014-10-27 01:08:42 -07:00
|
|
|
* @brief Eina tools aims to help application development, providing ways to
|
|
|
|
* make it safer, log errors, manage memory more efficiently and more.
|
2011-08-02 21:55:12 -07:00
|
|
|
*/
|
|
|
|
|
2008-07-30 05:46:55 -07:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2014-08-02 12:09:57 -07:00
|
|
|
#include <eina_config.h>
|
|
|
|
#include <eina_types.h>
|
|
|
|
#include <eina_alloca.h>
|
|
|
|
#include <eina_main.h>
|
|
|
|
#include <eina_fp.h>
|
|
|
|
#include <eina_rectangle.h>
|
2020-01-22 13:54:44 -08:00
|
|
|
#include <eina_range.h>
|
2014-08-02 12:09:57 -07:00
|
|
|
#include <eina_clist.h>
|
|
|
|
#include <eina_inlist.h>
|
|
|
|
#include <eina_file.h>
|
|
|
|
#include <eina_list.h>
|
|
|
|
#include <eina_hash.h>
|
|
|
|
#include <eina_trash.h>
|
|
|
|
#include <eina_lalloc.h>
|
|
|
|
#include <eina_module.h>
|
|
|
|
#include <eina_mempool.h>
|
|
|
|
#include <eina_error.h>
|
|
|
|
#include <eina_log.h>
|
|
|
|
#include <eina_inarray.h>
|
|
|
|
#include <eina_array.h>
|
|
|
|
#include <eina_binshare.h>
|
|
|
|
#include <eina_stringshare.h>
|
|
|
|
#include <eina_ustringshare.h>
|
|
|
|
#include <eina_magic.h>
|
|
|
|
#include <eina_counter.h>
|
|
|
|
#include <eina_rbtree.h>
|
|
|
|
#include <eina_accessor.h>
|
|
|
|
#include <eina_iterator.h>
|
|
|
|
#include <eina_benchmark.h>
|
|
|
|
#include <eina_convert.h>
|
|
|
|
#include <eina_cpu.h>
|
|
|
|
#include <eina_tiler.h>
|
|
|
|
#include <eina_hamster.h>
|
|
|
|
#include <eina_matrixsparse.h>
|
|
|
|
#include <eina_str.h>
|
|
|
|
#include <eina_strbuf.h>
|
|
|
|
#include <eina_binbuf.h>
|
|
|
|
#include <eina_ustrbuf.h>
|
|
|
|
#include <eina_unicode.h>
|
|
|
|
#include <eina_quadtree.h>
|
|
|
|
#include <eina_simple_xml_parser.h>
|
|
|
|
#include <eina_lock.h>
|
eina/ecore: allow threads to be canceled, use in ecore_con.
As discussed in the mailing list, many people will use worker threads
to execute blocking syscalls and mandating ecore_thread_check() for
voluntary preemption reduces the ecore_thread usefulness a lot.
A clear example is ecore_con usage of connect() and getaddrinfo() in
threads. If the connect timeout expires, the thread will be cancelled,
but it was blocked on syscalls and they will hang around for long
time. If the application exits, ecore will print an error saying it
can SEGV.
Then enable access to pthread_setcancelstate(PTHREAD_CANCEL_ENABLE)
via eina_thread_cancellable_set(EINA_TRUE), to pthread_cancel() via
eina_thread_cancel(), to pthread_cleanup_push()/pthread_cleanup_pop()
via EINA_THREAD_CLEANUP_PUSH()/EINA_THREAD_CLEANUP_POP() and so on.
Ecore threads will enforce non-cancellable threads on its own code,
but the user may decide to enable that and allow cancellation, that's
not an issue since ecore_thread now plays well and use cleanup
functions.
Ecore con connect/resolve make use of that and enable cancellable
state, efl_net_dialer_tcp benefits a lot from that.
A good comparison of the benefit is to run:
./src/examples/ecore/efl_io_copier_example tcp://google.com:1234 :stdout:
before and after. It will timeout after 30s and with this patch the
thread is gone, no ecore error is printed about possible SEGV.
2016-09-13 21:38:58 -07:00
|
|
|
#include <eina_thread.h> /* after eina_lock.h since it will include pthread.h with proper flags */
|
2014-08-02 12:09:57 -07:00
|
|
|
#include <eina_prefix.h>
|
|
|
|
#include <eina_refcount.h>
|
|
|
|
#include <eina_mmap.h>
|
|
|
|
#include <eina_xattr.h>
|
|
|
|
#include <eina_value.h>
|
2014-09-23 12:19:21 -07:00
|
|
|
#include <eina_value_util.h>
|
2014-08-02 12:09:57 -07:00
|
|
|
#include <eina_cow.h>
|
|
|
|
#include <eina_thread_queue.h>
|
2015-04-03 07:12:48 -07:00
|
|
|
#include <eina_matrix.h>
|
2016-01-07 01:58:54 -08:00
|
|
|
#include <eina_vector.h>
|
2015-04-22 06:34:33 -07:00
|
|
|
#include <eina_crc.h>
|
2015-05-10 03:05:54 -07:00
|
|
|
#include <eina_evlog.h>
|
2015-05-13 22:40:33 -07:00
|
|
|
#include <eina_util.h>
|
2015-05-29 08:18:23 -07:00
|
|
|
#include <eina_quaternion.h>
|
2015-04-07 22:13:15 -07:00
|
|
|
#include <eina_bezier.h>
|
2016-06-10 13:42:19 -07:00
|
|
|
#include <eina_safepointer.h>
|
2016-08-12 13:08:38 -07:00
|
|
|
#include <eina_slice.h>
|
2016-11-04 03:06:15 -07:00
|
|
|
#include <eina_freeq.h>
|
2017-01-10 22:34:15 -08:00
|
|
|
#include <eina_slstr.h>
|
2016-11-26 21:48:10 -08:00
|
|
|
#include <eina_debug.h>
|
2017-08-08 14:10:36 -07:00
|
|
|
#include <eina_promise.h>
|
2018-02-18 13:12:58 -08:00
|
|
|
#include <eina_vpath.h>
|
2020-01-04 06:08:08 -08:00
|
|
|
#include <eina_abstract_content.h>
|
2008-08-06 08:37:29 -07:00
|
|
|
|
2015-04-28 05:21:27 -07:00
|
|
|
|
2008-07-30 05:46:55 -07:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* EINA_H */
|