EFL 1.7 svn doobies
[profile/ivi/eina.git] / src / lib / eina_private.h
1 /* EINA - EFL data type library
2  * Copyright (C) 2008 Carsten Haitzler, Vincent Torri, Jorge Luis Zapata Muga
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library;
16  * if not, see <http://www.gnu.org/licenses/>.
17  */
18
19 #ifndef EINA_PRIVATE_H_
20 #define EINA_PRIVATE_H_
21
22 #include <stdarg.h>
23
24 #include "eina_magic.h"
25 #include "eina_iterator.h"
26 #include "eina_accessor.h"
27
28 #ifndef MIN
29 # define MIN(x, y) (((x) > (y)) ? (y) : (x))
30 #endif
31
32 #ifndef MAX
33 # define MAX(x, y) (((x) > (y)) ? (x) : (y))
34 #endif
35
36 #ifndef ABS
37 # define ABS(x) ((x) < 0 ? -(x) : (x))
38 #endif
39
40 #ifndef CLAMP
41 # define CLAMP(x, min, \
42                max) (((x) > (max)) ? (max) : (((x) < (min)) ? (min) : (x)))
43 #endif
44
45 #define EINA_INLIST_JUMP_SIZE 256
46
47 #define READBUFSIZ 65536
48
49 #define EINA_LOG_COLOR_DEFAULT "\033[36m"
50
51 /* eina magic types */
52 #define EINA_MAGIC_SHARE 0x98761234
53 #define EINA_MAGIC_SHARE_HEAD 0x98761235
54 #define EINA_MAGIC_STRINGSHARE_NODE 0x98761254
55 #define EINA_MAGIC_USTRINGSHARE_NODE 0x98761255
56 #define EINA_MAGIC_BINSHARE_NODE 0x98761256
57
58 #define EINA_MAGIC_LIST 0x98761237
59 #define EINA_MAGIC_LIST_ITERATOR 0x98761238
60 #define EINA_MAGIC_LIST_ACCESSOR 0x98761239
61 #define EINA_MAGIC_LIST_ACCOUNTING 0x9876123a
62
63 #define EINA_MAGIC_ARRAY 0x9876123b
64 #define EINA_MAGIC_ARRAY_ITERATOR 0x9876123c
65 #define EINA_MAGIC_ARRAY_ACCESSOR 0x9876123d
66
67 #define EINA_MAGIC_HASH 0x9876123e
68 #define EINA_MAGIC_HASH_ITERATOR 0x9876123f
69
70 #define EINA_MAGIC_TILER 0x98761240
71 #define EINA_MAGIC_TILER_ITERATOR 0x98761241
72
73 #define EINA_MAGIC_MATRIXSPARSE 0x98761242
74 #define EINA_MAGIC_MATRIXSPARSE_ROW 0x98761243
75 #define EINA_MAGIC_MATRIXSPARSE_CELL 0x98761244
76 #define EINA_MAGIC_MATRIXSPARSE_ITERATOR 0x98761245
77 #define EINA_MAGIC_MATRIXSPARSE_ROW_ITERATOR 0x98761246
78 #define EINA_MAGIC_MATRIXSPARSE_ROW_ACCESSOR 0x98761247
79 #define EINA_MAGIC_MATRIXSPARSE_CELL_ITERATOR 0x98761248
80 #define EINA_MAGIC_MATRIXSPARSE_CELL_ACCESSOR 0x98761249
81
82 #define EINA_MAGIC_STRBUF 0x98761250
83 #define EINA_MAGIC_USTRBUF 0x98761257
84 #define EINA_MAGIC_BINBUF 0x98761258
85
86 #define EINA_MAGIC_QUADTREE 0x98761251
87 #define EINA_MAGIC_QUADTREE_ROOT 0x98761252
88 #define EINA_MAGIC_QUADTREE_ITEM 0x98761253
89
90 #define EINA_MAGIC_SIMPLE_XML_TAG 0x98761260
91 #define EINA_MAGIC_SIMPLE_XML_DATA 0x98761261
92 #define EINA_MAGIC_SIMPLE_XML_ATTRIBUTE 0x98761262
93
94 #define EINA_MAGIC_INARRAY 0x98761270
95 #define EINA_MAGIC_INARRAY_ITERATOR 0x98761271
96 #define EINA_MAGIC_INARRAY_ACCESSOR 0x98761272
97
98 #define EINA_MAGIC_MODEL 0x98761280
99
100 #define EINA_MAGIC_CLASS 0x9877CB30
101
102 /* undef the following, we want out version */
103 #undef FREE
104 #define FREE(ptr)                               \
105   do {                                          \
106      free(ptr);                                 \
107      ptr = NULL;                                \
108   } while(0);
109
110 #undef IF_FREE
111 #define IF_FREE(ptr)                            \
112   do {                                          \
113      if (ptr) {                                 \
114         free(ptr);                              \
115         ptr = NULL;                             \
116      }                                          \
117   } while(0);
118
119 #undef IF_FN_DEL
120 #define IF_FN_DEL(_fn, ptr)                     \
121   do {                                          \
122      if (ptr) {                                 \
123         _fn(ptr);                               \
124         ptr = NULL;                             \
125      }                                          \
126   } while(0);
127
128 #define MAGIC_FREE(ptr)                         \
129   do {                                          \
130      if (ptr) {                                 \
131         EINA_MAGIC_SET(ptr, EINA_MAGIC_NONE);   \
132         FREE(ptr);                              \
133      }                                          \
134   } while(0);
135
136 #ifdef EFL_HAVE_THREADS
137 extern Eina_Bool _threads_activated;
138
139 void eina_share_common_threads_init(void);
140 void eina_share_common_threads_shutdown(void);
141 void eina_log_threads_init(void);
142 void eina_log_threads_shutdown(void);
143 #endif
144
145 void eina_cpu_count_internal(void);
146
147 void eina_file_mmap_faulty(void *addr, long page_size);
148
149 #endif /* EINA_PRIVATE_H_ */
150