[glib] Move version APIs out of gutils



commit e7b4319d61495d742915770a7b6f4fc14c29db02
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Oct 16 17:01:26 2011 -0400

    Move version APIs out of gutils
    
    Just another cleanup.

 glib/Makefile.am |    2 +
 glib/glib.h      |    1 +
 glib/gutils.c    |   93 ----------------------------------
 glib/gutils.h    |   42 ----------------
 glib/gversion.c  |  145 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 glib/gversion.h  |   78 +++++++++++++++++++++++++++++
 6 files changed, 226 insertions(+), 135 deletions(-)
---
diff --git a/glib/Makefile.am b/glib/Makefile.am
index 5381f02..9b806c6 100644
--- a/glib/Makefile.am
+++ b/glib/Makefile.am
@@ -212,6 +212,7 @@ libglib_2_0_la_SOURCES = 	\
 	gvarianttypeinfo.h	\
 	gvarianttypeinfo.c	\
 	gvarianttype.c		\
+	gversion.c		\
 	gwakeup.h		\
 	gwakeup.c		\
 	gprintf.c		\
@@ -315,6 +316,7 @@ glibsubinclude_HEADERS =   \
 	gutils.h	\
 	gvarianttype.h	\
 	gvariant.h	\
+	gversion.h	\
 	gwin32.h	\
 	gprintf.h
 
diff --git a/glib/glib.h b/glib/glib.h
index 58e4c05..a1bcb7d 100644
--- a/glib/glib.h
+++ b/glib/glib.h
@@ -91,6 +91,7 @@
 #include <glib/gutils.h>
 #include <glib/gvarianttype.h>
 #include <glib/gvariant.h>
+#include <glib/gversion.h>
 #ifdef G_PLATFORM_WIN32
 #include <glib/gwin32.h>
 #endif
diff --git a/glib/gutils.c b/glib/gutils.c
index 1a69973..98bd40b 100644
--- a/glib/gutils.c
+++ b/glib/gutils.c
@@ -28,46 +28,6 @@
  * MT safe for the unix part, FIXME: make the win32 part MT safe as well.
  */
 
-/**
- * SECTION:version
- * @Title: Version Information
- * @Short_description: Variables and functions to check the GLib version
- *
- * GLib provides version information, primarily useful in configure
- * checks for builds that have a configure script. Applications will
- * not typically use the features described here.
- */
-
-/**
- * GLIB_MAJOR_VERSION:
- *
- * The major version number of the GLib library.
- *
- * Like #glib_major_version, but from the headers used at
- * application compile time, rather than from the library
- * linked against at application run time.
- */
-
-/**
- * GLIB_MINOR_VERSION:
- *
- * The minor version number of the GLib library.
- *
- * Like #gtk_minor_version, but from the headers used at
- * application compile time, rather than from the library
- * linked against at application run time.
- */
-
-/**
- * GLIB_MICRO_VERSION:
- *
- * The micro version number of the GLib library.
- *
- * Like #gtk_micro_version, but from the headers used at
- * application compile time, rather than from the library
- * linked against at application run time.
- */
-
 #include "config.h"
 
 #ifdef HAVE_UNISTD_H
@@ -183,12 +143,6 @@
 #include <langinfo.h>
 #endif
 
-const guint glib_major_version = GLIB_MAJOR_VERSION;
-const guint glib_minor_version = GLIB_MINOR_VERSION;
-const guint glib_micro_version = GLIB_MICRO_VERSION;
-const guint glib_interface_age = GLIB_INTERFACE_AGE;
-const guint glib_binary_age = GLIB_BINARY_AGE;
-
 #ifdef G_PLATFORM_WIN32
 
 gchar *
@@ -230,53 +184,6 @@ _glib_get_dll_directory (void)
 
 #endif
 
-/**
- * glib_check_version:
- * @required_major: the required major version.
- * @required_minor: the required minor version.
- * @required_micro: the required micro version.
- *
- * Checks that the GLib library in use is compatible with the
- * given version. Generally you would pass in the constants
- * #GLIB_MAJOR_VERSION, #GLIB_MINOR_VERSION, #GLIB_MICRO_VERSION
- * as the three arguments to this function; that produces
- * a check that the library in use is compatible with
- * the version of GLib the application or module was compiled
- * against.
- *
- * Compatibility is defined by two things: first the version
- * of the running library is newer than the version
- * @required_major required_minor  required_micro  Second
- * the running library must be binary compatible with the
- * version @required_major required_minor  required_micro
- * (same major version.)
- *
- * Return value: %NULL if the GLib library is compatible with the
- *   given version, or a string describing the version mismatch.
- *   The returned string is owned by GLib and must not be modified
- *   or freed.
- *
- * Since: 2.6
- **/
-const gchar *
-glib_check_version (guint required_major,
-                    guint required_minor,
-                    guint required_micro)
-{
-  gint glib_effective_micro = 100 * GLIB_MINOR_VERSION + GLIB_MICRO_VERSION;
-  gint required_effective_micro = 100 * required_minor + required_micro;
-
-  if (required_major > GLIB_MAJOR_VERSION)
-    return "GLib version too old (major mismatch)";
-  if (required_major < GLIB_MAJOR_VERSION)
-    return "GLib version too new (major mismatch)";
-  if (required_effective_micro < glib_effective_micro - GLIB_BINARY_AGE)
-    return "GLib version too new (micro mismatch)";
-  if (required_effective_micro > glib_effective_micro)
-    return "GLib version too old (micro mismatch)";
-  return NULL;
-}
-
 #if !defined (HAVE_MEMMOVE) && !defined (HAVE_WORKING_BCOPY)
 /**
  * g_memmove: 
diff --git a/glib/gutils.h b/glib/gutils.h
index f4c038f..103584d 100644
--- a/glib/gutils.h
+++ b/glib/gutils.h
@@ -355,48 +355,6 @@ g_bit_storage (gulong number)
 }
 #endif  /* G_CAN_INLINE || __G_UTILS_C__ */
 
-/* Glib version.
- * we prefix variable declarations so they can
- * properly get exported in windows dlls.
- */
-GLIB_VAR const guint glib_major_version;
-GLIB_VAR const guint glib_minor_version;
-GLIB_VAR const guint glib_micro_version;
-GLIB_VAR const guint glib_interface_age;
-GLIB_VAR const guint glib_binary_age;
-
-const gchar * glib_check_version (guint required_major,
-                                  guint required_minor,
-                                  guint required_micro);
-
-/**
- * GLIB_CHECK_VERSION:
- * @major: the major version to check for
- * @minor: the minor version to check for
- * @micro: the micro version to check for
- *
- * Checks the version of the GLib library that is being compiled
- * against.
- *
- * <example>
- * <title>Checking the version of the GLib library</title>
- * <programlisting>
- *   if (!GLIB_CHECK_VERSION (1, 2, 0))
- *     g_error ("GLib version 1.2.0 or above is needed");
- * </programlisting>
- * </example>
- *
- * See glib_check_version() for a runtime check.
- *
- * Returns: %TRUE if the version of the GLib header files
- * is the same as or newer than the passed-in version.
- */
-#define GLIB_CHECK_VERSION(major,minor,micro)    \
-    (GLIB_MAJOR_VERSION > (major) || \
-     (GLIB_MAJOR_VERSION == (major) && GLIB_MINOR_VERSION > (minor)) || \
-     (GLIB_MAJOR_VERSION == (major) && GLIB_MINOR_VERSION == (minor) && \
-      GLIB_MICRO_VERSION >= (micro)))
-
 G_END_DECLS
 
 #ifndef G_DISABLE_DEPRECATED
diff --git a/glib/gversion.c b/glib/gversion.c
new file mode 100644
index 0000000..96d46ff
--- /dev/null
+++ b/glib/gversion.c
@@ -0,0 +1,145 @@
+/* GLIB - Library of useful routines for C programming
+ * Copyright (C) 1995-1998  Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
+ * file for a list of people on the GLib Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GLib at ftp://ftp.gtk.org/pub/gtk/. 
+ */
+
+#include "config.h"
+
+#include "gversion.h"
+
+/**
+ * SECTION:version
+ * @Title: Version Information
+ * @Short_description: Variables and functions to check the GLib version
+ *
+ * GLib provides version information, primarily useful in configure
+ * checks for builds that have a configure script. Applications will
+ * not typically use the features described here.
+ */
+
+/**
+ * GLIB_MAJOR_VERSION:
+ *
+ * The major version number of the GLib library.
+ *
+ * Like #glib_major_version, but from the headers used at
+ * application compile time, rather than from the library
+ * linked against at application run time.
+ */
+
+/**
+ * GLIB_MINOR_VERSION:
+ *
+ * The minor version number of the GLib library.
+ *
+ * Like #gtk_minor_version, but from the headers used at
+ * application compile time, rather than from the library
+ * linked against at application run time.
+ */
+
+/**
+ * GLIB_MICRO_VERSION:
+ *
+ * The micro version number of the GLib library.
+ *
+ * Like #gtk_micro_version, but from the headers used at
+ * application compile time, rather than from the library
+ * linked against at application run time.
+ */
+
+/**
+ * GLIB_CHECK_VERSION:
+ * @major: the major version to check for
+ * @minor: the minor version to check for
+ * @micro: the micro version to check for
+ *
+ * Checks the version of the GLib library that is being compiled
+ * against.
+ *
+ * <example>
+ * <title>Checking the version of the GLib library</title>
+ * <programlisting>
+ *   if (!GLIB_CHECK_VERSION (1, 2, 0))
+ *     g_error ("GLib version 1.2.0 or above is needed");
+ * </programlisting>
+ * </example>
+ *
+ * See glib_check_version() for a runtime check.
+ *
+ * Returns: %TRUE if the version of the GLib header files
+ * is the same as or newer than the passed-in version.
+ */
+
+const guint glib_major_version = GLIB_MAJOR_VERSION;
+const guint glib_minor_version = GLIB_MINOR_VERSION;
+const guint glib_micro_version = GLIB_MICRO_VERSION;
+const guint glib_interface_age = GLIB_INTERFACE_AGE;
+const guint glib_binary_age = GLIB_BINARY_AGE;
+
+/**
+ * glib_check_version:
+ * @required_major: the required major version.
+ * @required_minor: the required minor version.
+ * @required_micro: the required micro version.
+ *
+ * Checks that the GLib library in use is compatible with the
+ * given version. Generally you would pass in the constants
+ * #GLIB_MAJOR_VERSION, #GLIB_MINOR_VERSION, #GLIB_MICRO_VERSION
+ * as the three arguments to this function; that produces
+ * a check that the library in use is compatible with
+ * the version of GLib the application or module was compiled
+ * against.
+ *
+ * Compatibility is defined by two things: first the version
+ * of the running library is newer than the version
+ * @required_major required_minor  required_micro  Second
+ * the running library must be binary compatible with the
+ * version @required_major required_minor  required_micro
+ * (same major version.)
+ *
+ * Return value: %NULL if the GLib library is compatible with the
+ *   given version, or a string describing the version mismatch.
+ *   The returned string is owned by GLib and must not be modified
+ *   or freed.
+ *
+ * Since: 2.6
+ */
+const gchar *
+glib_check_version (guint required_major,
+                    guint required_minor,
+                    guint required_micro)
+{
+  gint glib_effective_micro = 100 * GLIB_MINOR_VERSION + GLIB_MICRO_VERSION;
+  gint required_effective_micro = 100 * required_minor + required_micro;
+
+  if (required_major > GLIB_MAJOR_VERSION)
+    return "GLib version too old (major mismatch)";
+  if (required_major < GLIB_MAJOR_VERSION)
+    return "GLib version too new (major mismatch)";
+  if (required_effective_micro < glib_effective_micro - GLIB_BINARY_AGE)
+    return "GLib version too new (micro mismatch)";
+  if (required_effective_micro > glib_effective_micro)
+    return "GLib version too old (micro mismatch)";
+  return NULL;
+}
diff --git a/glib/gversion.h b/glib/gversion.h
new file mode 100644
index 0000000..35a7d3e
--- /dev/null
+++ b/glib/gversion.h
@@ -0,0 +1,78 @@
+/* GLIB - Library of useful routines for C programming
+ * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
+ * file for a list of people on the GLib Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GLib at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
+#error "Only <glib.h> can be included directly."
+#endif
+
+#ifndef __G_VERSION_H__
+#define __G_VERSION_H__
+
+#include <glib/gtypes.h>
+
+G_BEGIN_DECLS
+
+GLIB_VAR const guint glib_major_version;
+GLIB_VAR const guint glib_minor_version;
+GLIB_VAR const guint glib_micro_version;
+GLIB_VAR const guint glib_interface_age;
+GLIB_VAR const guint glib_binary_age;
+
+const gchar * glib_check_version (guint required_major,
+                                  guint required_minor,
+                                  guint required_micro);
+
+/**
+ * GLIB_CHECK_VERSION:
+ * @major: the major version to check for
+ * @minor: the minor version to check for
+ * @micro: the micro version to check for
+ *
+ * Checks the version of the GLib library that is being compiled
+ * against.
+ *
+ * <example>
+ * <title>Checking the version of the GLib library</title>
+ * <programlisting>
+ *   if (!GLIB_CHECK_VERSION (1, 2, 0))
+ *     g_error ("GLib version 1.2.0 or above is needed");
+ * </programlisting>
+ * </example>
+ *
+ * See glib_check_version() for a runtime check.
+ *
+ * Returns: %TRUE if the version of the GLib header files
+ * is the same as or newer than the passed-in version.
+ */
+#define GLIB_CHECK_VERSION(major,minor,micro)    \
+    (GLIB_MAJOR_VERSION > (major) || \
+     (GLIB_MAJOR_VERSION == (major) && GLIB_MINOR_VERSION > (minor)) || \
+     (GLIB_MAJOR_VERSION == (major) && GLIB_MINOR_VERSION == (minor) && \
+      GLIB_MICRO_VERSION >= (micro)))
+
+G_END_DECLS
+
+#endif /*  __G_VERSION_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]