summaryrefslogtreecommitdiff
path: root/tests/suite/ecore/src/lib/eina_private.h
blob: 30b3859a1a7f4a3907a959ea515af6e92a3c7ccf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/* EINA - EFL data type library
 * Copyright (C) 2008 Carsten Haitzler, Vincent Torri, Jorge Luis Zapata Muga
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library;
 * if not, see <http://www.gnu.org/licenses/>.
 */

#ifndef EINA_PRIVATE_H_
#define EINA_PRIVATE_H_

#include <stdarg.h>

#if HAVE___ATTRIBUTE__
#define __UNUSED__ __attribute__((unused))
#else
#define __UNUSED__
#endif

#include "eina_magic.h"
#include "eina_iterator.h"
#include "eina_accessor.h"

#ifndef MIN
#define MIN(x, y) (((x) > (y)) ? (y) : (x))
#endif

#ifndef MAX
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#endif

#ifndef ABS
#define ABS(x) ((x) < 0 ? -(x) : (x))
#endif

#ifndef CLAMP
#define CLAMP(x, min, \
               max) (((x) > (max)) ? (max) : (((x) < (min)) ? (min) : (x)))
#endif

#define READBUFSIZ 65536

#define EINA_LOG_COLOR_DEFAULT "\033[36m"

/* eina magic types */
#define EINA_MAGIC_SHARE 0x98761234
#define EINA_MAGIC_SHARE_HEAD 0x98761235
#define EINA_MAGIC_STRINGSHARE_NODE 0x98761254
#define EINA_MAGIC_USTRINGSHARE_NODE 0x98761255
#define EINA_MAGIC_BINSHARE_NODE 0x98761256

#define EINA_MAGIC_LIST 0x98761237
#define EINA_MAGIC_LIST_ITERATOR 0x98761238
#define EINA_MAGIC_LIST_ACCESSOR 0x98761239
#define EINA_MAGIC_LIST_ACCOUNTING 0x9876123a

#define EINA_MAGIC_ARRAY 0x9876123b
#define EINA_MAGIC_ARRAY_ITERATOR 0x9876123c
#define EINA_MAGIC_ARRAY_ACCESSOR 0x9876123d

#define EINA_MAGIC_HASH 0x9876123e
#define EINA_MAGIC_HASH_ITERATOR 0x9876123f

#define EINA_MAGIC_TILER 0x98761240
#define EINA_MAGIC_TILER_ITERATOR 0x98761241

#define EINA_MAGIC_MATRIXSPARSE 0x98761242
#define EINA_MAGIC_MATRIXSPARSE_ROW 0x98761243
#define EINA_MAGIC_MATRIXSPARSE_CELL 0x98761244
#define EINA_MAGIC_MATRIXSPARSE_ITERATOR 0x98761245
#define EINA_MAGIC_MATRIXSPARSE_ROW_ITERATOR 0x98761246
#define EINA_MAGIC_MATRIXSPARSE_ROW_ACCESSOR 0x98761247
#define EINA_MAGIC_MATRIXSPARSE_CELL_ITERATOR 0x98761248
#define EINA_MAGIC_MATRIXSPARSE_CELL_ACCESSOR 0x98761249

#define EINA_MAGIC_STRBUF 0x98761250
#define EINA_MAGIC_USTRBUF 0x98761257

#define EINA_MAGIC_QUADTREE 0x98761251
#define EINA_MAGIC_QUADTREE_ROOT 0x98761252
#define EINA_MAGIC_QUADTREE_ITEM 0x98761253

/* undef the following, we want out version */
#undef FREE
#define FREE(ptr)				\
  do {						\
     free(ptr);					\
     ptr = NULL;				\
  } while(0);

#undef IF_FREE
#define IF_FREE(ptr)				\
  do {						\
     if (ptr) {					\
	free(ptr);				\
	ptr = NULL;				\
     }						\
  } while(0);

#undef IF_FN_DEL
#define IF_FN_DEL(_fn, ptr)			\
  do {						\
     if (ptr) {					\
	_fn(ptr);				\
	ptr = NULL;				\
     }						\
  } while(0);

#define MAGIC_FREE(ptr)				\
  do {						\
     if (ptr) {					\
	EINA_MAGIC_SET(ptr, EINA_MAGIC_NONE);	\
	FREE(ptr);				\
     }						\
  } while(0);

#ifdef EFL_HAVE_THREADS
void eina_share_common_threads_init(void);
void eina_share_common_threads_shutdown(void);
void eina_log_threads_init(void);
void eina_log_threads_shutdown(void);
#endif

#endif				/* EINA_PRIVATE_H_ */