summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-06-05 13:00:02 +0200
committerThomas Haller <thaller@redhat.com>2016-06-06 14:52:22 +0200
commitae30b0915b8b619f0c864af5fdf8b23e0db5dc60 (patch)
tree995127cff0a9d5d9d84223474b42e3c1e961835c
parent81ee610888a3c62b8fa1b460616fcc5e7e94276d (diff)
downloadnetwork-manager-applet-ae30b0915b8b619f0c864af5fdf8b23e0db5dc60.tar.gz
shared: update "shared/nm-macros-internal.h"
-rw-r--r--shared/nm-macros-internal.h35
1 files changed, 34 insertions, 1 deletions
diff --git a/shared/nm-macros-internal.h b/shared/nm-macros-internal.h
index 1f638bab..04e6a1ab 100644
--- a/shared/nm-macros-internal.h
+++ b/shared/nm-macros-internal.h
@@ -22,9 +22,17 @@
#ifndef __NM_MACROS_INTERNAL_H__
#define __NM_MACROS_INTERNAL_H__
+#include <stdlib.h>
+
/********************************************************/
-#define nm_auto(fcn) __attribute ((cleanup(fcn)))
+#define _nm_packed __attribute__ ((packed))
+#define _nm_unused __attribute__ ((unused))
+#define _nm_pure __attribute__ ((pure))
+#define _nm_const __attribute__ ((const))
+#define _nm_printf(a,b) __attribute__ ((__format__ (__printf__, a, b)))
+
+#define nm_auto(fcn) __attribute__ ((cleanup(fcn)))
/**
* nm_auto_free:
@@ -34,6 +42,13 @@
#define nm_auto_free nm_auto(_nm_auto_free_impl)
GS_DEFINE_CLEANUP_FUNCTION(void*, _nm_auto_free_impl, free)
+static inline void
+_nm_auto_unset_gvalue_impl (GValue *v)
+{
+ g_value_unset (v);
+}
+#define nm_auto_unset_gvalue nm_auto(_nm_auto_unset_gvalue_impl)
+
/********************************************************/
/* http://stackoverflow.com/a/11172679 */
@@ -285,10 +300,28 @@ _NM_IN_STRSET_streq (const char *x, const char *s)
/*****************************************************************************/
+/* glib/C provides the following kind of assertions:
+ * - assert() -- disable with NDEBUG
+ * - g_return_if_fail() -- disable with G_DISABLE_CHECKS
+ * - g_assert() -- disable with G_DISABLE_ASSERT
+ * but they are all enabled by default and usually even production builds have
+ * these kind of assertions enabled. It also means, that disabling assertions
+ * is an untested configuration, and might have bugs.
+ *
+ * Add our own assertion macro nm_assert(), which is disabled by default and must
+ * be explicitly enabled. They are useful for more expensive checks or checks that
+ * depend less on runtime conditions (that is, are generally expected to be true). */
+
+#ifndef NM_MORE_ASSERTS
+#define NM_MORE_ASSERTS 0
+#endif
+
#if NM_MORE_ASSERTS
#define nm_assert(cond) G_STMT_START { g_assert (cond); } G_STMT_END
+#define nm_assert_not_reached() G_STMT_START { g_assert_not_reached (); } G_STMT_END
#else
#define nm_assert(cond) G_STMT_START { if (FALSE) { if (cond) { } } } G_STMT_END
+#define nm_assert_not_reached() G_STMT_START { ; } G_STMT_END
#endif
/*****************************************************************************/