summary refs log tree commit diff
path: root/include
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2015-11-24 00:06:32 +0100
committerMichael Biebl <biebl@debian.org>2015-11-24 00:06:32 +0100
commita6ece1a2aa19a6268335c87d4fdef20123dd04a5 (patch)
tree87f1961faacdfafb1c4fee5f2feb6bcb5c06813b /include
parent81836c2d44802b4cca833d7775dd627e0797a7e2 (diff)
Imported Upstream version 1.0.8 upstream/1.0.8
Diffstat (limited to 'include')
-rw-r--r--include/Makefile.am3
-rw-r--r--include/Makefile.in11
-rw-r--r--include/nm-macros-internal.h41
-rw-r--r--include/nm-version-macros.h79
-rw-r--r--include/nm-version-macros.h.in79
5 files changed, 201 insertions, 12 deletions
diff --git a/include/Makefile.am b/include/Makefile.am
index ff7eac8c..d8085056 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -4,6 +4,7 @@ EXTRA_DIST = \
      nm-glib-compat.h \
      nm-gvaluearray-compat.h \
      nm-test-utils.h \
-     nm-macros-internal.h
+     nm-macros-internal.h \
+     nm-version-macros.h.in
 
 CLEANFILES=nm-version.h
diff --git a/include/Makefile.in b/include/Makefile.in
index 3dbcc338..6c5fff87 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -107,7 +107,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
-CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_FILES = nm-version-macros.h
 CONFIG_CLEAN_VPATH_FILES =
 AM_V_P = $(am__v_P_@AM_V@)
 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
@@ -129,7 +129,8 @@ am__can_run_installinfo = \
     *) (install-info --version) >/dev/null 2>&1;; \
   esac
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
-am__DIST_COMMON = $(srcdir)/Makefile.in
+am__DIST_COMMON = $(srcdir)/Makefile.in \
+	$(srcdir)/nm-version-macros.h.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ALL_LINGUAS = @ALL_LINGUAS@
@@ -253,6 +254,7 @@ LOG_DRIVER = @LOG_DRIVER@
 LTLIBICONV = @LTLIBICONV@
 LTLIBINTL = @LTLIBINTL@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
@@ -399,7 +401,8 @@ EXTRA_DIST = \
      nm-glib-compat.h \
      nm-gvaluearray-compat.h \
      nm-test-utils.h \
-     nm-macros-internal.h
+     nm-macros-internal.h \
+     nm-version-macros.h.in
 
 CLEANFILES = nm-version.h
 all: all-am
@@ -434,6 +437,8 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(am__aclocal_m4_deps):
+nm-version-macros.h: $(top_builddir)/config.status $(srcdir)/nm-version-macros.h.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
 
 mostlyclean-libtool:
 	-rm -f *.lo
diff --git a/include/nm-macros-internal.h b/include/nm-macros-internal.h
index 170fb46c..a2f2da5a 100644
--- a/include/nm-macros-internal.h
+++ b/include/nm-macros-internal.h
@@ -24,6 +24,7 @@
 
 
 #include <glib.h>
+#include <glib-object.h>
 
 /********************************************************/
 
@@ -83,7 +84,7 @@
  * It's not that bad however, because gcc and clang often have the
  * same name for the same warning. */
 
-#if defined (__GNUC__)
+#if defined (__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
 #define NM_PRAGMA_WARNING_DISABLE(warning) \
         _Pragma("GCC diagnostic push"); \
         _Pragma(_NM_PRAGMA_WARNING_DO(warning))
@@ -95,7 +96,7 @@
 #define NM_PRAGMA_WARNING_DISABLE(warning)
 #endif
 
-#if defined (__GNUC__)
+#if defined (__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
 #define NM_PRAGMA_WARNING_REENABLE \
     _Pragma("GCC diagnostic pop")
 #elif defined (__clang__)
@@ -256,6 +257,17 @@ nm_clear_g_source (guint *id)
 	return FALSE;
 }
 
+static inline gboolean
+nm_clear_g_signal_handler (gpointer self, guint *id)
+{
+	if (id && *id) {
+		g_signal_handler_disconnect (self, *id);
+		*id = 0;
+		return TRUE;
+	}
+	return FALSE;
+}
+
 /*****************************************************************************/
 
 /* Determine whether @x is a power of two (@x being an integer type).
@@ -265,12 +277,12 @@ nm_clear_g_source (guint *id)
 #define nm_utils_is_power_of_two(x) ({ \
 		const typeof(x) __x = (x); \
 		\
-		((__x & (__x - 1)) == 0) && \
-			/* Check if the value is negative. In that case, return FALSE.
-			 * The first expression is a compile time constant, depending on whether
-			 * the type is signed. The second expression is a clumsy way for (__x >= 0),
-			 * which causes a compiler warning for unsigned types. */ \
-			( ( ((typeof(__x)) -1) > ((typeof(__x)) 0) ) || (__x > 0) || (__x == 0) ); \
+		/* Check if the value is negative. In that case, return FALSE.
+		 * The first expression is a compile time constant, depending on whether
+		 * the type is signed. The second expression is a clumsy way for (__x >= 0),
+		 * which causes a compiler warning for unsigned types. */ \
+		    ( ( ((typeof(__x)) -1) > ((typeof(__x)) 0) ) || (__x > 0) || (__x == 0) ) \
+		 && ((__x & (__x - 1)) == 0); \
 	})
 
 /*****************************************************************************/
@@ -317,4 +329,17 @@ nm_strstrip (char *str)
 
 /*****************************************************************************/
 
+#define nm_sprintf_buf(buf, format, ...) ({ \
+		char * _buf = (buf); \
+		\
+		/* some static assert trying to ensure that the buffer is statically allocated.
+		 * It disallows a buffer size of sizeof(gpointer) to catch that. */ \
+		G_STATIC_ASSERT (G_N_ELEMENTS (buf) == sizeof (buf) && sizeof (buf) != sizeof (char *)); \
+		g_snprintf (_buf, sizeof (buf), \
+		            ""format"", __VA_ARGS__); \
+		_buf; \
+	})
+
+/*****************************************************************************/
+
 #endif /* __NM_MACROS_INTERNAL_H__ */
diff --git a/include/nm-version-macros.h b/include/nm-version-macros.h
new file mode 100644
index 00000000..a3c5dc9b
--- /dev/null
+++ b/include/nm-version-macros.h
@@ -0,0 +1,79 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/*
+ * 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 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, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ *
+ * Copyright 2011, 2015 Red Hat, Inc.
+ */
+
+#ifndef __NM_VERSION_MACROS_H__
+#define __NM_VERSION_MACROS_H__
+
+/* This header must not include glib or libnm. */
+
+/**
+ * NM_MAJOR_VERSION:
+ *
+ * Evaluates to the major version number of NetworkManager which this source
+ * is compiled against.
+ */
+#define NM_MAJOR_VERSION (1)
+
+/**
+ * NM_MINOR_VERSION:
+ *
+ * Evaluates to the minor version number of NetworkManager which this source
+ * is compiled against.
+ */
+#define NM_MINOR_VERSION (0)
+
+/**
+ * NM_MICRO_VERSION:
+ *
+ * Evaluates to the micro version number of NetworkManager which this source
+ * compiled against.
+ */
+#define NM_MICRO_VERSION (8)
+
+/**
+ * NM_CHECK_VERSION:
+ * @major: major version (e.g. 1 for version 1.2.5)
+ * @minor: minor version (e.g. 2 for version 1.2.5)
+ * @micro: micro version (e.g. 5 for version 1.2.5)
+ *
+ * Returns: %TRUE if the version of the NetworkManager header files
+ * is the same as or newer than the passed-in version.
+ */
+#define NM_CHECK_VERSION(major,minor,micro)                         \
+    (NM_MAJOR_VERSION > (major) ||                                  \
+     (NM_MAJOR_VERSION == (major) && NM_MINOR_VERSION > (minor)) || \
+     (NM_MAJOR_VERSION == (major) && NM_MINOR_VERSION == (minor) && NM_MICRO_VERSION >= (micro)))
+
+
+#define NM_ENCODE_VERSION(major,minor,micro) ((major) << 16 | (minor) << 8 | (micro))
+
+#define NM_VERSION_0_9_8  (NM_ENCODE_VERSION (0, 9, 8))
+#define NM_VERSION_0_9_10 (NM_ENCODE_VERSION (0, 9, 10))
+#define NM_VERSION_1_0    (NM_ENCODE_VERSION (1, 0, 0))
+#define NM_VERSION_1_0_2  (NM_ENCODE_VERSION (1, 0, 2))
+#define NM_VERSION_1_0_4  (NM_ENCODE_VERSION (1, 0, 4))
+#define NM_VERSION_1_0_6  (NM_ENCODE_VERSION (1, 0, 6))
+#define NM_VERSION_1_0_8  (NM_ENCODE_VERSION (1, 0, 8))
+#define NM_VERSION_1_0_10  (NM_ENCODE_VERSION (1, 0, 10))
+
+#define NM_VERSION_CUR_STABLE  NM_VERSION_1_0_8
+#define NM_VERSION_NEXT_STABLE NM_VERSION_1_0_10
+
+#endif  /* __NM_VERSION_MACROS_H__ */
diff --git a/include/nm-version-macros.h.in b/include/nm-version-macros.h.in
new file mode 100644
index 00000000..92df50ba
--- /dev/null
+++ b/include/nm-version-macros.h.in
@@ -0,0 +1,79 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/*
+ * 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 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, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ *
+ * Copyright 2011, 2015 Red Hat, Inc.
+ */
+
+#ifndef __NM_VERSION_MACROS_H__
+#define __NM_VERSION_MACROS_H__
+
+/* This header must not include glib or libnm. */
+
+/**
+ * NM_MAJOR_VERSION:
+ *
+ * Evaluates to the major version number of NetworkManager which this source
+ * is compiled against.
+ */
+#define NM_MAJOR_VERSION (@NM_MAJOR_VERSION@)
+
+/**
+ * NM_MINOR_VERSION:
+ *
+ * Evaluates to the minor version number of NetworkManager which this source
+ * is compiled against.
+ */
+#define NM_MINOR_VERSION (@NM_MINOR_VERSION@)
+
+/**
+ * NM_MICRO_VERSION:
+ *
+ * Evaluates to the micro version number of NetworkManager which this source
+ * compiled against.
+ */
+#define NM_MICRO_VERSION (@NM_MICRO_VERSION@)
+
+/**
+ * NM_CHECK_VERSION:
+ * @major: major version (e.g. 1 for version 1.2.5)
+ * @minor: minor version (e.g. 2 for version 1.2.5)
+ * @micro: micro version (e.g. 5 for version 1.2.5)
+ *
+ * Returns: %TRUE if the version of the NetworkManager header files
+ * is the same as or newer than the passed-in version.
+ */
+#define NM_CHECK_VERSION(major,minor,micro)                         \
+    (NM_MAJOR_VERSION > (major) ||                                  \
+     (NM_MAJOR_VERSION == (major) && NM_MINOR_VERSION > (minor)) || \
+     (NM_MAJOR_VERSION == (major) && NM_MINOR_VERSION == (minor) && NM_MICRO_VERSION >= (micro)))
+
+
+#define NM_ENCODE_VERSION(major,minor,micro) ((major) << 16 | (minor) << 8 | (micro))
+
+#define NM_VERSION_0_9_8  (NM_ENCODE_VERSION (0, 9, 8))
+#define NM_VERSION_0_9_10 (NM_ENCODE_VERSION (0, 9, 10))
+#define NM_VERSION_1_0    (NM_ENCODE_VERSION (1, 0, 0))
+#define NM_VERSION_1_0_2  (NM_ENCODE_VERSION (1, 0, 2))
+#define NM_VERSION_1_0_4  (NM_ENCODE_VERSION (1, 0, 4))
+#define NM_VERSION_1_0_6  (NM_ENCODE_VERSION (1, 0, 6))
+#define NM_VERSION_1_0_8  (NM_ENCODE_VERSION (1, 0, 8))
+#define NM_VERSION_1_0_10  (NM_ENCODE_VERSION (1, 0, 10))
+
+#define NM_VERSION_CUR_STABLE  NM_VERSION_1_0_8
+#define NM_VERSION_NEXT_STABLE NM_VERSION_1_0_10
+
+#endif  /* __NM_VERSION_MACROS_H__ */