summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@profusion.mobi>2012-08-14 20:58:36 +0000
committerLucas De Marchi <lucas.demarchi@profusion.mobi>2012-08-14 20:58:36 +0000
commit4322cdb8f10f39bcf0fb7ca5010a820f325bd5c6 (patch)
tree58dea42ba0198acda2f3444b122d515c5106d731
parent72feaa1fb88073d2417071210253d413fed0b831 (diff)
downloadeina-4322cdb8f10f39bcf0fb7ca5010a820f325bd5c6.tar.gz
eina: add EINA_SENTINEL to help use of variadic functions
Certain types of variadic functions use NULL as the last argument instead of a string format (printf-like). Functions like these are: execl and execlp. We are in feature freeze, but I believe this is small and simple enough to slip in with no headaches. These functions are being used in the new edbus library and it would be good to have it supported in eina now. SVN revision: 75271
-rw-r--r--src/include/eina_types.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/include/eina_types.h b/src/include/eina_types.h
index d1e84dc..49eae1d 100644
--- a/src/include/eina_types.h
+++ b/src/include/eina_types.h
@@ -99,6 +99,9 @@
#ifdef EINA_LIKELY
# undef EINA_LIKELY
#endif
+#ifdef EINA_SENTINEL
+# undef EINA_SENTINEL
+#endif
#ifdef __GNUC__
# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
@@ -139,6 +142,7 @@
# define EINA_NOINSTRUMENT __attribute__((__no_instrument_function__))
# define EINA_UNLIKELY(exp) __builtin_expect((exp), 0)
# define EINA_LIKELY(exp) __builtin_expect((exp), 1)
+# define EINA_SENTINEL __attribute__((__sentinel__))
# else
# define EINA_PRINTF(fmt, arg)
# define EINA_SCANF(fmt, arg)
@@ -147,6 +151,7 @@
# define EINA_NOINSTRUMENT
# define EINA_UNLIKELY(exp) exp
# define EINA_LIKELY(exp) exp
+# define EINA_SENTINEL
# endif
#elif defined(_WIN32)
@@ -166,6 +171,7 @@
# define EINA_NOINSTRUMENT
# define EINA_UNLIKELY(exp) exp
# define EINA_LIKELY(exp) exp
+# define EINA_SENTINEL
#elif defined(__SUNPRO_C)
# define EINA_WARN_UNUSED_RESULT
@@ -189,6 +195,7 @@
# define EINA_NOINSTRUMENT
# define EINA_UNLIKELY(exp) exp
# define EINA_LIKELY(exp) exp
+# define EINA_SENTINEL
#else /* ! __GNUC__ && ! _WIN32 && ! __SUNPRO_C */
@@ -260,6 +267,13 @@
* @param exp The expression to be used.
*/
# define EINA_LIKELY(exp) exp
+/**
+ * @def EINA_SENTINEL
+ * @brief Attribute from gcc to prevent calls without the necessary NULL
+ * sentinel in certain variadic functions
+ * @since 1.7.0
+ */
+# define EINA_SENTINEL
#endif /* ! __GNUC__ && ! _WIN32 && ! __SUNPRO_C */
/**