summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2010-08-16 15:02:37 +0000
committerCedric BAIL <cedric.bail@free.fr>2010-08-16 15:02:37 +0000
commitc45c36bd80f229cf84a04b7d7e0146386274c092 (patch)
tree418c48a0470a15ba946519167275768bdb3d5edc
parent6293bd87fa96005181612754f952c09b7f4a74d8 (diff)
* eina: attempt to improve a little bit more the header.
Mainly trailing space and macro indentation. SVN revision: 51217
-rw-r--r--legacy/eina/src/include/eina_accessor.h20
-rw-r--r--legacy/eina/src/include/eina_array.h16
-rw-r--r--legacy/eina/src/include/eina_convert.h11
-rw-r--r--legacy/eina/src/include/eina_inline_str.x22
-rw-r--r--legacy/eina/src/include/eina_list.h72
-rw-r--r--legacy/eina/src/include/eina_log.h30
-rw-r--r--legacy/eina/src/include/eina_magic.h13
-rw-r--r--legacy/eina/src/include/eina_private.h54
-rw-r--r--legacy/eina/src/include/eina_rectangle.h6
-rw-r--r--legacy/eina/src/include/eina_safety_checks.h216
-rw-r--r--legacy/eina/src/include/eina_str.h21
11 files changed, 238 insertions, 243 deletions
diff --git a/legacy/eina/src/include/eina_accessor.h b/legacy/eina/src/include/eina_accessor.h
index 3e715dbcbd..ae8197869c 100644
--- a/legacy/eina/src/include/eina_accessor.h
+++ b/legacy/eina/src/include/eina_accessor.h
@@ -68,14 +68,14 @@ struct _Eina_Accessor
68#define FUNC_ACCESSOR_LOCK(Function) ((Eina_Accessor_Lock_Callback)Function) 68#define FUNC_ACCESSOR_LOCK(Function) ((Eina_Accessor_Lock_Callback)Function)
69 69
70EAPI void eina_accessor_free(Eina_Accessor *accessor) EINA_ARG_NONNULL(1); 70EAPI void eina_accessor_free(Eina_Accessor *accessor) EINA_ARG_NONNULL(1);
71EAPI Eina_Bool eina_accessor_data_get(Eina_Accessor *accessor, 71EAPI Eina_Bool eina_accessor_data_get(Eina_Accessor *accessor,
72 unsigned int position, 72 unsigned int position,
73 void **data) EINA_ARG_NONNULL(1); 73 void **data) EINA_ARG_NONNULL(1);
74EAPI void * eina_accessor_container_get(Eina_Accessor *accessor) EINA_ARG_NONNULL(1) EINA_PURE; 74EAPI void * eina_accessor_container_get(Eina_Accessor *accessor) EINA_ARG_NONNULL(1) EINA_PURE;
75EAPI void eina_accessor_over(Eina_Accessor *accessor, 75EAPI void eina_accessor_over(Eina_Accessor *accessor,
76 Eina_Each_Cb cb, 76 Eina_Each_Cb cb,
77 unsigned int start, 77 unsigned int start,
78 unsigned int end, 78 unsigned int end,
79 const void *fdata) EINA_ARG_NONNULL(1, 2); 79 const void *fdata) EINA_ARG_NONNULL(1, 2);
80EAPI Eina_Bool eina_accessor_lock(Eina_Accessor *accessor) EINA_ARG_NONNULL(1); 80EAPI Eina_Bool eina_accessor_lock(Eina_Accessor *accessor) EINA_ARG_NONNULL(1);
81EAPI Eina_Bool eina_accessor_unlock(Eina_Accessor *accessor) EINA_ARG_NONNULL(1); 81EAPI Eina_Bool eina_accessor_unlock(Eina_Accessor *accessor) EINA_ARG_NONNULL(1);
@@ -129,10 +129,10 @@ EAPI Eina_Bool eina_accessor_unlock(Eina_Accessor *accessor) EINA_ARG_NONNULL(1)
129 * rather in the accessors implementations to keep them as simple 129 * rather in the accessors implementations to keep them as simple
130 * and fast as possible. 130 * and fast as possible.
131 */ 131 */
132#define EINA_ACCESSOR_FOREACH(accessor, counter, data) \ 132#define EINA_ACCESSOR_FOREACH(accessor, counter, data) \
133 for ((counter) = 0; \ 133 for ((counter) = 0; \
134 eina_accessor_data_get((accessor), (counter), (void **)&(data)); \ 134 eina_accessor_data_get((accessor), (counter), (void **)&(data)); \
135 (counter)++) 135 (counter)++)
136 136
137/** 137/**
138 * @} 138 * @}
diff --git a/legacy/eina/src/include/eina_array.h b/legacy/eina/src/include/eina_array.h
index a5e071ef5c..bec7ac52f2 100644
--- a/legacy/eina/src/include/eina_array.h
+++ b/legacy/eina/src/include/eina_array.h
@@ -83,16 +83,16 @@ EAPI void eina_array_step_set(Eina_Array *array,
83 unsigned int step) EINA_ARG_NONNULL(1); 83 unsigned int step) EINA_ARG_NONNULL(1);
84EAPI void eina_array_clean(Eina_Array *array) EINA_ARG_NONNULL(1); 84EAPI void eina_array_clean(Eina_Array *array) EINA_ARG_NONNULL(1);
85EAPI void eina_array_flush(Eina_Array *array) EINA_ARG_NONNULL(1); 85EAPI void eina_array_flush(Eina_Array *array) EINA_ARG_NONNULL(1);
86EAPI Eina_Bool eina_array_remove(Eina_Array *array, 86EAPI Eina_Bool eina_array_remove(Eina_Array *array,
87 Eina_Bool(*keep)(void *data, void *gdata), 87 Eina_Bool(*keep)(void *data, void *gdata),
88 void *gdata) EINA_ARG_NONNULL(1, 2); 88 void *gdata) EINA_ARG_NONNULL(1, 2);
89static inline Eina_Bool eina_array_push(Eina_Array *array, 89static inline Eina_Bool eina_array_push(Eina_Array *array,
90 const void *data) EINA_ARG_NONNULL(1, 2); 90 const void *data) EINA_ARG_NONNULL(1, 2);
91static inline void * eina_array_pop(Eina_Array *array) EINA_ARG_NONNULL(1); 91static inline void * eina_array_pop(Eina_Array *array) EINA_ARG_NONNULL(1);
92static inline void * eina_array_data_get(const Eina_Array *array, 92static inline void * eina_array_data_get(const Eina_Array *array,
93 unsigned int idx) EINA_ARG_NONNULL(1); 93 unsigned int idx) EINA_ARG_NONNULL(1);
94static inline void eina_array_data_set(const Eina_Array *array, 94static inline void eina_array_data_set(const Eina_Array *array,
95 unsigned int idx, 95 unsigned int idx,
96 const void *data) EINA_ARG_NONNULL(1, 3); 96 const void *data) EINA_ARG_NONNULL(1, 3);
97static inline unsigned int eina_array_count_get(const Eina_Array *array) EINA_ARG_NONNULL(1); 97static inline unsigned int eina_array_count_get(const Eina_Array *array) EINA_ARG_NONNULL(1);
98EAPI Eina_Iterator * eina_array_iterator_new(const Eina_Array *array) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; 98EAPI Eina_Iterator * eina_array_iterator_new(const Eina_Array *array) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
@@ -135,10 +135,10 @@ static inline Eina_Bool eina_array_foreach(Eina_Array *array,
135 * free(item); 135 * free(item);
136 * @endcode 136 * @endcode
137 */ 137 */
138#define EINA_ARRAY_ITER_NEXT(array, index, item, iterator) \ 138#define EINA_ARRAY_ITER_NEXT(array, index, item, iterator) \
139 for (index = 0, iterator = (array)->data; \ 139 for (index = 0, iterator = (array)->data; \
140 (index < eina_array_count_get(array)) && ((item = *((iterator)++))); \ 140 (index < eina_array_count_get(array)) && ((item = *((iterator)++))); \
141 ++(index)) 141 ++(index))
142 142
143#include "eina_inline_array.x" 143#include "eina_inline_array.x"
144 144
diff --git a/legacy/eina/src/include/eina_convert.h b/legacy/eina/src/include/eina_convert.h
index d185ae1a3c..8cd64334f5 100644
--- a/legacy/eina/src/include/eina_convert.h
+++ b/legacy/eina/src/include/eina_convert.h
@@ -54,16 +54,15 @@ EAPI extern Eina_Error EINA_ERROR_CONVERT_0X_NOT_FOUND;
54 */ 54 */
55EAPI extern Eina_Error EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH; 55EAPI extern Eina_Error EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH;
56 56
57EAPI int eina_convert_itoa(int n, 57EAPI int eina_convert_itoa(int n, char *s) EINA_ARG_NONNULL(2);
58 char *s) EINA_ARG_NONNULL(2); 58EAPI int eina_convert_xtoa(unsigned int n, char *s) EINA_ARG_NONNULL(2);
59EAPI int eina_convert_xtoa(unsigned int n, 59
60 char *s) EINA_ARG_NONNULL(2); 60EAPI int eina_convert_dtoa(double d, char *des) EINA_ARG_NONNULL(2);
61EAPI int eina_convert_dtoa(double d,
62 char *des) EINA_ARG_NONNULL(2);
63EAPI Eina_Bool eina_convert_atod(const char *src, 61EAPI Eina_Bool eina_convert_atod(const char *src,
64 int length, 62 int length,
65 long long *m, 63 long long *m,
66 long *e) EINA_ARG_NONNULL(1,3,4); 64 long *e) EINA_ARG_NONNULL(1,3,4);
65
67EAPI int eina_convert_fptoa(Eina_F32p32 fp, 66EAPI int eina_convert_fptoa(Eina_F32p32 fp,
68 char *des) EINA_ARG_NONNULL(2); 67 char *des) EINA_ARG_NONNULL(2);
69EAPI Eina_Bool eina_convert_atofp(const char *src, 68EAPI Eina_Bool eina_convert_atofp(const char *src,
diff --git a/legacy/eina/src/include/eina_inline_str.x b/legacy/eina/src/include/eina_inline_str.x
index 27b3540ce6..2daeb8524c 100644
--- a/legacy/eina/src/include/eina_inline_str.x
+++ b/legacy/eina/src/include/eina_inline_str.x
@@ -48,6 +48,28 @@ eina_strlen_bounded(const char *str, size_t maxlen)
48} 48}
49 49
50/** 50/**
51 * @brief Join two strings of known length.
52 *
53 * @param dst The buffer to store the result.
54 * @param size Size (in byte) of the buffer.
55 * @param sep The separator character to use.
56 * @param a First string to use, before @p sep.
57 * @param b Second string to use, after @p sep.
58 * @return The number of characters printed.
59 *
60 * This function is similar to eina_str_join_len(), but will compute
61 * the length of @p a and @p b using strlen().
62 *
63 * @see eina_str_join_len()
64 * @see eina_str_join_static()
65 */
66static inline size_t
67eina_str_join(char *dst, size_t size, char sep, const char *a, const char *b)
68{
69 return eina_str_join_len(dst, size, sep, a, strlen(a), b, strlen(b));
70}
71
72/**
51 * @} 73 * @}
52 */ 74 */
53 75
diff --git a/legacy/eina/src/include/eina_list.h b/legacy/eina/src/include/eina_list.h
index 359e0110ba..a549076851 100644
--- a/legacy/eina/src/include/eina_list.h
+++ b/legacy/eina/src/include/eina_list.h
@@ -156,11 +156,12 @@ EAPI Eina_Accessor * eina_list_accessor_new(const Eina_List *list)
156 * For destructive operations such as this, consider 156 * For destructive operations such as this, consider
157 * using EINA_LIST_FOREACH_SAFE(). 157 * using EINA_LIST_FOREACH_SAFE().
158 */ 158 */
159#define EINA_LIST_FOREACH(list, l, data) for (l = list, \ 159#define EINA_LIST_FOREACH(list, l, data) \
160 data = eina_list_data_get(l); \ 160 for (l = list, \
161 l; \ 161 data = eina_list_data_get(l); \
162 l = eina_list_next(l), data = \ 162 l; \
163 eina_list_data_get(l)) 163 l = eina_list_next(l), \
164 data = eina_list_data_get(l))
164 165
165/** 166/**
166 * @def EINA_LIST_REVERSE_FOREACH 167 * @def EINA_LIST_REVERSE_FOREACH
@@ -203,13 +204,12 @@ EAPI Eina_Accessor * eina_list_accessor_new(const Eina_List *list)
203 * For destructive operations such as this, consider 204 * For destructive operations such as this, consider
204 * using EINA_LIST_REVERSE_FOREACH_SAFE(). 205 * using EINA_LIST_REVERSE_FOREACH_SAFE().
205 */ 206 */
206#define EINA_LIST_REVERSE_FOREACH(list, l, data) for (l = eina_list_last(list), \ 207#define EINA_LIST_REVERSE_FOREACH(list, l, data) \
207 data = \ 208 for (l = eina_list_last(list), \
208 eina_list_data_get(l); \ 209 data = eina_list_data_get(l); \
209 l; \ 210 l; \
210 l = eina_list_prev(l), \ 211 l = eina_list_prev(l), \
211 data = \ 212 data = eina_list_data_get(l))
212 eina_list_data_get(l))
213 213
214/** 214/**
215 * @def EINA_LIST_FOREACH_SAFE 215 * @def EINA_LIST_FOREACH_SAFE
@@ -246,16 +246,14 @@ EAPI Eina_Accessor * eina_list_accessor_new(const Eina_List *list)
246 * } 246 * }
247 * @endcode 247 * @endcode
248 */ 248 */
249#define EINA_LIST_FOREACH_SAFE(list, l, l_next, data) for (l = list, \ 249#define EINA_LIST_FOREACH_SAFE(list, l, l_next, data) \
250 l_next = \ 250 for (l = list, \
251 eina_list_next(l), \ 251 l_next = eina_list_next(l), \
252 data = \ 252 data = eina_list_data_get(l); \
253 eina_list_data_get(l); \ 253 l; \
254 l; \ 254 l = l_next, \
255 l = l_next, l_next = \ 255 l_next = eina_list_next(l), \
256 eina_list_next(l), \ 256 data = eina_list_data_get(l))
257 data = \
258 eina_list_data_get(l))
259 257
260/** 258/**
261 * @def EINA_LIST_REVERSE_FOREACH_SAFE 259 * @def EINA_LIST_REVERSE_FOREACH_SAFE
@@ -294,18 +292,14 @@ EAPI Eina_Accessor * eina_list_accessor_new(const Eina_List *list)
294 * } 292 * }
295 * @endcode 293 * @endcode
296 */ 294 */
297#define EINA_LIST_REVERSE_FOREACH_SAFE(list, l, l_prev, data) for (l = \ 295#define EINA_LIST_REVERSE_FOREACH_SAFE(list, l, l_prev, data) \
298 eina_list_last(list), \ 296 for (l = eina_list_last(list), \
299 l_prev = \ 297 l_prev = eina_list_prev(l), \
300 eina_list_prev(l), \ 298 data = eina_list_data_get(l); \
301 data = \ 299 l; \
302 eina_list_data_get(l); \ 300 l = l_prev, \
303 l; \ 301 l_prev = eina_list_prev(l), \
304 l = l_prev, \ 302 data = eina_list_data_get(l))
305 l_prev = \
306 eina_list_prev(l), \
307 data = \
308 eina_list_data_get(l))
309 303
310/** 304/**
311 * @def EINA_LIST_FREE 305 * @def EINA_LIST_FREE
@@ -332,11 +326,11 @@ EAPI Eina_Accessor * eina_list_accessor_new(const Eina_List *list)
332 * 326 *
333 * @see eina_list_free() 327 * @see eina_list_free()
334 */ 328 */
335#define EINA_LIST_FREE(list, data) for (data = eina_list_data_get(list); list; \ 329#define EINA_LIST_FREE(list, data) \
336 list = \ 330 for (data = eina_list_data_get(list); \
337 eina_list_remove_list(list, \ 331 list; \
338 list), data = \ 332 list = eina_list_remove_list(list, list), \
339 eina_list_data_get(list)) 333 data = eina_list_data_get(list))
340 334
341#include "eina_inline_list.x" 335#include "eina_inline_list.x"
342 336
diff --git a/legacy/eina/src/include/eina_log.h b/legacy/eina/src/include/eina_log.h
index fd1948e9e9..76b7864281 100644
--- a/legacy/eina/src/include/eina_log.h
+++ b/legacy/eina/src/include/eina_log.h
@@ -123,20 +123,20 @@ EAPI extern int EINA_LOG_DOMAIN_GLOBAL;
123 */ 123 */
124#ifdef EINA_LOG_LEVEL_MAXIMUM 124#ifdef EINA_LOG_LEVEL_MAXIMUM
125#define EINA_LOG(DOM, LEVEL, fmt, ...) \ 125#define EINA_LOG(DOM, LEVEL, fmt, ...) \
126 do { \ 126 do { \
127 if (LEVEL <= EINA_LOG_LEVEL_MAXIMUM) { \ 127 if (LEVEL <= EINA_LOG_LEVEL_MAXIMUM) { \
128 eina_log_print(DOM, LEVEL, __FILE__, __FUNCTION__, __LINE__, \ 128 eina_log_print(DOM, LEVEL, __FILE__, __FUNCTION__, __LINE__, \
129 fmt, ## __VA_ARGS__); } \ 129 fmt, ## __VA_ARGS__); } \
130 } while (0) 130 } while (0)
131#else 131#else
132#define EINA_LOG(DOM, LEVEL, fmt, ...) \ 132#define EINA_LOG(DOM, LEVEL, fmt, ...) \
133 eina_log_print(DOM, \ 133 eina_log_print(DOM, \
134 LEVEL, \ 134 LEVEL, \
135 __FILE__, \ 135 __FILE__, \
136 __FUNCTION__, \ 136 __FUNCTION__, \
137 __LINE__, \ 137 __LINE__, \
138 fmt, \ 138 fmt, \
139 ## __VA_ARGS__) 139 ## __VA_ARGS__)
140#endif 140#endif
141 141
142/** 142/**
@@ -179,10 +179,10 @@ EAPI extern int EINA_LOG_DOMAIN_GLOBAL;
179 * Logs a message with level CRITICAL on the default domain with the specified 179 * Logs a message with level CRITICAL on the default domain with the specified
180 * format. 180 * format.
181 */ 181 */
182#define EINA_LOG_CRIT(fmt, ...) \ 182#define EINA_LOG_CRIT(fmt, ...) \
183 EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, \ 183 EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, \
184 EINA_LOG_LEVEL_CRITICAL, \ 184 EINA_LOG_LEVEL_CRITICAL, \
185 fmt, \ 185 fmt, \
186 ## __VA_ARGS__) 186 ## __VA_ARGS__)
187 187
188/** 188/**
diff --git a/legacy/eina/src/include/eina_magic.h b/legacy/eina/src/include/eina_magic.h
index 866d2ff34a..dd1a9f3a56 100644
--- a/legacy/eina/src/include/eina_magic.h
+++ b/legacy/eina/src/include/eina_magic.h
@@ -111,12 +111,13 @@ EAPI Eina_Bool eina_magic_string_static_set(Eina_Magic magic,
111 * If the magic feature of Eina is disabled, #EINA_MAGIC_FAIL does 111 * If the magic feature of Eina is disabled, #EINA_MAGIC_FAIL does
112 * nothing. 112 * nothing.
113 */ 113 */
114#define EINA_MAGIC_FAIL(d, m) eina_magic_fail((void *)(d), \ 114#define EINA_MAGIC_FAIL(d, m) \
115 (d) ? (d)->__magic : 0, \ 115 eina_magic_fail((void *)(d), \
116 (m), \ 116 (d) ? (d)->__magic : 0, \
117 __FILE__, \ 117 (m), \
118 __FUNCTION__, \ 118 __FILE__, \
119 __LINE__); 119 __FUNCTION__, \
120 __LINE__);
120 121
121EAPI void eina_magic_fail(void *d, Eina_Magic m, Eina_Magic req_m, 122EAPI void eina_magic_fail(void *d, Eina_Magic m, Eina_Magic req_m,
122 const char *file, const char *fnc, 123 const char *file, const char *fnc,
diff --git a/legacy/eina/src/include/eina_private.h b/legacy/eina/src/include/eina_private.h
index 7e8074bc14..2f8ff8117d 100644
--- a/legacy/eina/src/include/eina_private.h
+++ b/legacy/eina/src/include/eina_private.h
@@ -92,37 +92,37 @@
92 92
93/* undef the following, we want out version */ 93/* undef the following, we want out version */
94#undef FREE 94#undef FREE
95#define FREE(ptr) \ 95#define FREE(ptr) \
96 do { \ 96 do { \
97 free(ptr); \ 97 free(ptr); \
98 ptr = NULL; \ 98 ptr = NULL; \
99 } while(0); 99 } while(0);
100 100
101#undef IF_FREE 101#undef IF_FREE
102#define IF_FREE(ptr) \ 102#define IF_FREE(ptr) \
103 do { \ 103 do { \
104 if (ptr) { \ 104 if (ptr) { \
105 free(ptr); \ 105 free(ptr); \
106 ptr = NULL; \ 106 ptr = NULL; \
107 } \ 107 } \
108 } while(0); 108 } while(0);
109 109
110#undef IF_FN_DEL 110#undef IF_FN_DEL
111#define IF_FN_DEL(_fn, ptr) \ 111#define IF_FN_DEL(_fn, ptr) \
112 do { \ 112 do { \
113 if (ptr) { \ 113 if (ptr) { \
114 _fn(ptr); \ 114 _fn(ptr); \
115 ptr = NULL; \ 115 ptr = NULL; \
116 } \ 116 } \
117 } while(0); 117 } while(0);
118 118
119#define MAGIC_FREE(ptr) \ 119#define MAGIC_FREE(ptr) \
120 do { \ 120 do { \
121 if (ptr) { \ 121 if (ptr) { \
122 EINA_MAGIC_SET(ptr, EINA_MAGIC_NONE); \ 122 EINA_MAGIC_SET(ptr, EINA_MAGIC_NONE); \
123 FREE(ptr); \ 123 FREE(ptr); \
124 } \ 124 } \
125 } while(0); 125 } while(0);
126 126
127#ifdef EFL_HAVE_THREADS 127#ifdef EFL_HAVE_THREADS
128void eina_share_common_threads_init(void); 128void eina_share_common_threads_init(void);
diff --git a/legacy/eina/src/include/eina_rectangle.h b/legacy/eina/src/include/eina_rectangle.h
index 2d31fbb822..4ce3955d53 100644
--- a/legacy/eina/src/include/eina_rectangle.h
+++ b/legacy/eina/src/include/eina_rectangle.h
@@ -83,9 +83,9 @@ EAPI void eina_rectangle_pool_release(Eina_Rectangle *rect) EINA_ARG_NONNULL(1);
83 * width and @p H is its height. 83 * width and @p H is its height.
84 */ 84 */
85#define EINA_RECTANGLE_SET(Rectangle, X, Y, W, H) \ 85#define EINA_RECTANGLE_SET(Rectangle, X, Y, W, H) \
86 (Rectangle)->x = X; \ 86 (Rectangle)->x = X; \
87 (Rectangle)->y = Y; \ 87 (Rectangle)->y = Y; \
88 (Rectangle)->w = W; \ 88 (Rectangle)->w = W; \
89 (Rectangle)->h = H; 89 (Rectangle)->h = H;
90 90
91EAPI Eina_Rectangle *eina_rectangle_new(int x, int y, int w, int h) EINA_MALLOC EINA_WARN_UNUSED_RESULT; 91EAPI Eina_Rectangle *eina_rectangle_new(int x, int y, int w, int h) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
diff --git a/legacy/eina/src/include/eina_safety_checks.h b/legacy/eina/src/include/eina_safety_checks.h
index b668d0e9b9..79ebc54fd3 100644
--- a/legacy/eina/src/include/eina_safety_checks.h
+++ b/legacy/eina/src/include/eina_safety_checks.h
@@ -79,112 +79,112 @@ EAPI extern Eina_Error EINA_ERROR_SAFETY_FAILED;
79#include "eina_log.h" 79#include "eina_log.h"
80 80
81#define EINA_SAFETY_ON_NULL_RETURN(exp) \ 81#define EINA_SAFETY_ON_NULL_RETURN(exp) \
82 do \ 82 do \
83 { \ 83 { \
84 if (EINA_UNLIKELY((exp) == NULL)) \ 84 if (EINA_UNLIKELY((exp) == NULL)) \
85 { \ 85 { \
86 eina_error_set(EINA_ERROR_SAFETY_FAILED); \ 86 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
87 EINA_LOG_ERR("%s", "safety check failed: " # exp " == NULL"); \ 87 EINA_LOG_ERR("%s", "safety check failed: " # exp " == NULL"); \
88 return; \ 88 return; \
89 } \ 89 } \
90 } \ 90 } \
91 while (0) 91 while (0)
92 92
93#define EINA_SAFETY_ON_NULL_RETURN_VAL(exp, val) \ 93#define EINA_SAFETY_ON_NULL_RETURN_VAL(exp, val) \
94 do \ 94 do \
95 { \ 95 { \
96 if (EINA_UNLIKELY((exp) == NULL)) \ 96 if (EINA_UNLIKELY((exp) == NULL)) \
97 { \ 97 { \
98 eina_error_set(EINA_ERROR_SAFETY_FAILED); \ 98 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
99 EINA_LOG_ERR("%s", "safety check failed: " # exp " == NULL"); \ 99 EINA_LOG_ERR("%s", "safety check failed: " # exp " == NULL"); \
100 return (val); \ 100 return (val); \
101 } \ 101 } \
102 } \ 102 } \
103 while (0) 103 while (0)
104 104
105#define EINA_SAFETY_ON_NULL_GOTO(exp, label) \ 105#define EINA_SAFETY_ON_NULL_GOTO(exp, label) \
106 do \ 106 do \
107 { \ 107 { \
108 if (EINA_UNLIKELY((exp) == NULL)) \ 108 if (EINA_UNLIKELY((exp) == NULL)) \
109 { \ 109 { \
110 eina_error_set(EINA_ERROR_SAFETY_FAILED); \ 110 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
111 EINA_LOG_ERR("%s", "safety check failed: " # exp " == NULL"); \ 111 EINA_LOG_ERR("%s", "safety check failed: " # exp " == NULL"); \
112 goto label; \ 112 goto label; \
113 } \ 113 } \
114 } \ 114 } \
115 while (0) 115 while (0)
116 116
117#define EINA_SAFETY_ON_TRUE_RETURN(exp) \ 117#define EINA_SAFETY_ON_TRUE_RETURN(exp) \
118 do \ 118 do \
119 { \ 119 { \
120 if (EINA_UNLIKELY(exp)) \ 120 if (EINA_UNLIKELY(exp)) \
121 { \ 121 { \
122 eina_error_set(EINA_ERROR_SAFETY_FAILED); \ 122 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
123 EINA_LOG_ERR("%s", "safety check failed: " # exp " is true"); \ 123 EINA_LOG_ERR("%s", "safety check failed: " # exp " is true"); \
124 return; \ 124 return; \
125 } \ 125 } \
126 } \ 126 } \
127 while (0) 127 while (0)
128 128
129#define EINA_SAFETY_ON_TRUE_RETURN_VAL(exp, val) \ 129#define EINA_SAFETY_ON_TRUE_RETURN_VAL(exp, val) \
130 do \ 130 do \
131 { \ 131 { \
132 if (EINA_UNLIKELY(exp)) \ 132 if (EINA_UNLIKELY(exp)) \
133 { \ 133 { \
134 eina_error_set(EINA_ERROR_SAFETY_FAILED); \ 134 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
135 EINA_LOG_ERR("%s", "safety check failed: " # exp " is true"); \ 135 EINA_LOG_ERR("%s", "safety check failed: " # exp " is true"); \
136 return val; \ 136 return val; \
137 } \ 137 } \
138 } \ 138 } \
139 while (0) 139 while (0)
140 140
141#define EINA_SAFETY_ON_TRUE_GOTO(exp, label) \ 141#define EINA_SAFETY_ON_TRUE_GOTO(exp, label) \
142 do \ 142 do \
143 { \ 143 { \
144 if (EINA_UNLIKELY(exp)) \ 144 if (EINA_UNLIKELY(exp)) \
145 { \ 145 { \
146 eina_error_set(EINA_ERROR_SAFETY_FAILED); \ 146 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
147 EINA_LOG_ERR("%s", "safety check failed: " # exp " is true"); \ 147 EINA_LOG_ERR("%s", "safety check failed: " # exp " is true"); \
148 goto label; \ 148 goto label; \
149 } \ 149 } \
150 } \ 150 } \
151 while (0) 151 while (0)
152 152
153#define EINA_SAFETY_ON_FALSE_RETURN(exp) \ 153#define EINA_SAFETY_ON_FALSE_RETURN(exp) \
154 do \ 154 do \
155 { \ 155 { \
156 if (EINA_UNLIKELY(!(exp))) \ 156 if (EINA_UNLIKELY(!(exp))) \
157 { \ 157 { \
158 eina_error_set(EINA_ERROR_SAFETY_FAILED); \ 158 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
159 EINA_LOG_ERR("%s", "safety check failed: " # exp " is false"); \ 159 EINA_LOG_ERR("%s", "safety check failed: " # exp " is false"); \
160 return; \ 160 return; \
161 } \ 161 } \
162 } \ 162 } \
163 while (0) 163 while (0)
164 164
165#define EINA_SAFETY_ON_FALSE_RETURN_VAL(exp, val) \ 165#define EINA_SAFETY_ON_FALSE_RETURN_VAL(exp, val) \
166 do \ 166 do \
167 { \ 167 { \
168 if (EINA_UNLIKELY(!(exp))) \ 168 if (EINA_UNLIKELY(!(exp))) \
169 { \ 169 { \
170 eina_error_set(EINA_ERROR_SAFETY_FAILED); \ 170 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
171 EINA_LOG_ERR("%s", "safety check failed: " # exp " is false"); \ 171 EINA_LOG_ERR("%s", "safety check failed: " # exp " is false"); \
172 return val; \ 172 return val; \
173 } \ 173 } \
174 } \ 174 } \
175 while (0) 175 while (0)
176 176
177#define EINA_SAFETY_ON_FALSE_GOTO(exp, label) \ 177#define EINA_SAFETY_ON_FALSE_GOTO(exp, label) \
178 do \ 178 do \
179 { \ 179 { \
180 if (EINA_UNLIKELY(!(exp))) \ 180 if (EINA_UNLIKELY(!(exp))) \
181 { \ 181 { \
182 eina_error_set(EINA_ERROR_SAFETY_FAILED); \ 182 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
183 EINA_LOG_ERR("%s", "safety check failed: " # exp " is false"); \ 183 EINA_LOG_ERR("%s", "safety check failed: " # exp " is false"); \
184 goto label; \ 184 goto label; \
185 } \ 185 } \
186 } \ 186 } \
187 while (0) 187 while (0)
188 188
189#ifdef EINA_ARG_NONNULL 189#ifdef EINA_ARG_NONNULL
190/* make EINA_ARG_NONNULL void so GCC does not optimize safety checks */ 190/* make EINA_ARG_NONNULL void so GCC does not optimize safety checks */
@@ -195,32 +195,32 @@ EAPI extern Eina_Error EINA_ERROR_SAFETY_FAILED;
195 195
196#else /* no safety checks */ 196#else /* no safety checks */
197 197
198#define EINA_SAFETY_ON_NULL_RETURN(exp) \ 198#define EINA_SAFETY_ON_NULL_RETURN(exp) \
199 do { (void)((exp) == NULL); } while (0) 199 do { (void)((exp) == NULL); } while (0)
200 200
201#define EINA_SAFETY_ON_NULL_RETURN_VAL(exp, val) \ 201#define EINA_SAFETY_ON_NULL_RETURN_VAL(exp, val) \
202 do { if (0 && (exp) == NULL) { (void)val; } } while (0) 202 do { if (0 && (exp) == NULL) { (void)val; } } while (0)
203 203
204#define EINA_SAFETY_ON_NULL_GOTO(exp, label) \ 204#define EINA_SAFETY_ON_NULL_GOTO(exp, label) \
205 do { if (0 && (exp) == NULL) { goto label; } } while (0) 205 do { if (0 && (exp) == NULL) { goto label; } } while (0)
206 206
207#define EINA_SAFETY_ON_TRUE_RETURN(exp) \ 207#define EINA_SAFETY_ON_TRUE_RETURN(exp) \
208 do { (void)(exp); } while (0) 208 do { (void)(exp); } while (0)
209 209
210#define EINA_SAFETY_ON_TRUE_RETURN_VAL(exp, val) \ 210#define EINA_SAFETY_ON_TRUE_RETURN_VAL(exp, val) \
211 do { if (0 && (exp)) { (void)val; } } while (0) 211 do { if (0 && (exp)) { (void)val; } } while (0)
212 212
213#define EINA_SAFETY_ON_TRUE_GOTO(exp, label) \ 213#define EINA_SAFETY_ON_TRUE_GOTO(exp, label) \
214 do { if (0 && (exp)) { goto label; } } while (0) 214 do { if (0 && (exp)) { goto label; } } while (0)
215 215
216#define EINA_SAFETY_ON_FALSE_RETURN(exp) \ 216#define EINA_SAFETY_ON_FALSE_RETURN(exp) \
217 do { (void)(!(exp)); } while (0) 217 do { (void)(!(exp)); } while (0)
218 218
219#define EINA_SAFETY_ON_FALSE_RETURN_VAL(exp, val) \ 219#define EINA_SAFETY_ON_FALSE_RETURN_VAL(exp, val) \
220 do { if (0 && !(exp)) { (void)val; } } while (0) 220 do { if (0 && !(exp)) { (void)val; } } while (0)
221 221
222#define EINA_SAFETY_ON_FALSE_GOTO(exp, label) \ 222#define EINA_SAFETY_ON_FALSE_GOTO(exp, label) \
223 do { if (0 && !(exp)) { goto label; } } while (0) 223 do { if (0 && !(exp)) { goto label; } } while (0)
224 224
225#endif /* safety checks macros */ 225#endif /* safety checks macros */
226#endif /* EINA_SAFETY_CHECKS_H_ */ 226#endif /* EINA_SAFETY_CHECKS_H_ */
diff --git a/legacy/eina/src/include/eina_str.h b/legacy/eina/src/include/eina_str.h
index 2d36c98295..1d12615e5a 100644
--- a/legacy/eina/src/include/eina_str.h
+++ b/legacy/eina/src/include/eina_str.h
@@ -41,27 +41,6 @@ EAPI void eina_str_toupper(char **str);
41static inline size_t eina_str_join(char *dst, size_t size, char sep, const char *a, const char *b) EINA_ARG_NONNULL(1, 4, 5); 41static inline size_t eina_str_join(char *dst, size_t size, char sep, const char *a, const char *b) EINA_ARG_NONNULL(1, 4, 5);
42 42
43/** 43/**
44 * @brief Join two strings of known length.
45 *
46 * @param dst The buffer to store the result.
47 * @param size Size (in byte) of the buffer.
48 * @param sep The separator character to use.
49 * @param a First string to use, before @p sep.
50 * @param b Second string to use, after @p sep.
51 * @return The number of characters printed.
52 *
53 * This function is similar to eina_str_join_len(), but will compute
54 * the length of @p a and @p b using strlen().
55 *
56 * @see eina_str_join_len()
57 * @see eina_str_join_static()
58 */
59static inline size_t eina_str_join(char *dst, size_t size, char sep, const char *a, const char *b)
60{
61 return eina_str_join_len(dst, size, sep, a, strlen(a), b, strlen(b));
62}
63
64/**
65 * @def eina_str_join_static(dst, sep, a, b) 44 * @def eina_str_join_static(dst, sep, a, b)
66 * @brief Join two static strings and store the result in a static buffer. 45 * @brief Join two static strings and store the result in a static buffer.
67 * 46 *