[gmime] work started on gmime-2.5.x



commit 544ad0b7bac246a8a891574af081e9db754a2cab
Author: Jeffrey Stedfast <fejj gnome org>
Date:   Fri Apr 24 08:42:47 2009 -0400

    work started on gmime-2.5.x
    
    2009-04-24  Jeffrey Stedfast  <fejj novell com>
    
    	* build/vs2008/config-win32.h.in: New template to replace
    	config.h.win32 so that the version info gets autogenerated when I
    	make a new release. Makes it easier for me to keep it in sync.
    
    	* build/vs2008/gmime.vcproj: No longer defines the gmime version
    	variables on the command-line (as these are now part of config.h).
    
    2009-04-23  Jeffrey Stedfast  <fejj novell com>
    
    	* branched: now begins 2.5.x development
    
    	* configure.in: Updated.
    
    	* zentimer.h: Updated to hopefully build on Windows.
    
    	* gmime/Makefile.am: Rename lib name to gmime-2.6.
    
    	* gmime.pc.in: Renamed from gmime-2.4.pc.in.
    
    	* mono/gmime-sharp.pc.in: Renamed from gmime-sharp-2.4.pc.in.
    
    	* gmime/gmime-stream*.[c,h] (stream_length): Fixed to return a gint64
---
 .gitignore                                         |    3 +-
 ChangeLog                                          |   25 +++
 Makefile.am                                        |    7 +-
 build/vs2008/.gitignore                            |    3 +
 build/vs2008/Makefile.am                           |    3 +-
 build/vs2008/{config.h.win32 => config-win32.h.in} |   37 +++--
 build/vs2008/gmime.vcproj                          |    6 +-
 configure.in                                       |  173 ++++++++++++++------
 docs/reference/.gitignore                          |    1 +
 docs/reference/Makefile.am                         |    2 +-
 docs/reference/gmime.hierarchy                     |   45 -----
 examples/Makefile.am                               |    4 +-
 gmime.spec.in                                      |   14 +-
 gmime/Makefile.am                                  |   22 +--
 gmime/gmime-stream-buffer.c                        |    4 +-
 gmime/gmime-stream-cat.c                           |    8 +-
 gmime/gmime-stream-file.c                          |    4 +-
 gmime/gmime-stream-filter.c                        |    4 +-
 gmime/gmime-stream-fs.c                            |    4 +-
 gmime/gmime-stream-mem.c                           |    4 +-
 gmime/gmime-stream-mmap.c                          |    4 +-
 gmime/gmime-stream-null.c                          |    4 +-
 gmime/gmime-stream.c                               |    6 +-
 gmime/gmime-stream.h                               |    9 +-
 mono/.gitignore                                    |    4 +-
 mono/Makefile.am                                   |    5 +-
 src/Makefile.am                                    |    4 +-
 src/uudecode.c                                     |    2 +-
 src/uuencode.c                                     |    2 +-
 tests/Makefile.am                                  |   10 +-
 zentimer.h                                         |   54 +++++--
 31 files changed, 283 insertions(+), 194 deletions(-)

diff --git a/.gitignore b/.gitignore
index cee1965..97c0cc2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,14 +6,15 @@ config.guess
 config.h.in
 config.h
 config.log
+config.lt
 config.status
 config.sub
 configure
 depcomp
 doltcompile
 doltlibtool
-gmime-2.4.pc
 gmime.spec
+gmime*.pc
 iconv-detect.h
 install-sh
 libtool
diff --git a/ChangeLog b/ChangeLog
index 9b51304..e64b31e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2009-04-24  Jeffrey Stedfast  <fejj novell com>
+
+	* build/vs2008/config-win32.h.in: New template to replace
+	config.h.win32 so that the version info gets autogenerated when I
+	make a new release. Makes it easier for me to keep it in sync.
+
+	* build/vs2008/gmime.vcproj: No longer defines the gmime version
+	variables on the command-line (as these are now part of config.h).
+
+2009-04-23  Jeffrey Stedfast  <fejj novell com>
+
+	* branched: now begins 2.5.x development
+
+	* configure.in: Updated.
+
+	* zentimer.h: Updated to hopefully build on Windows.
+
+	* gmime/Makefile.am: Rename lib name to gmime-2.6.
+
+	* gmime.pc.in: Renamed from gmime-2.4.pc.in.
+
+	* mono/gmime-sharp.pc.in: Renamed from gmime-sharp-2.4.pc.in.
+
+	* gmime/gmime-stream*.[c,h] (stream_length): Fixed to return a gint64
+
 2009-04-09  Jeffrey Stedfast  <fejj novell com>
 
 	* README: Bumped version
diff --git a/Makefile.am b/Makefile.am
index 81bc847..3166476 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -23,7 +23,7 @@ DISTCLEANFILES = iconv-detect.h
 
 EXTRA_DIST = 				\
 	PORTING				\
-	gmime-$(GMIME_API_VERSION).pc.in\
+	gmime.pc.in			\
 	gmime.spec.in 			\
 	iconv-detect.c			\
 	zentimer.h 			\
@@ -38,14 +38,15 @@ pkgconfig_DATA = gmime-$(GMIME_API_VERSION).pc
 
 $(pkgconfig_DATA): config.status
 
-$(libgmime_2_4_la_SOURCES): $(srcdir)/gmime
-
 dist-hook: $(BUILD_EXTRA_DIST)
 	files='$(BUILD_EXTRA_DIST)'; \
 	for f in $$files; do \
 	  if test -f $$f; then d=.; else d=$(srcdir); fi; \
 	  rm -f $(distdir)/$$f && cp $$d/$$f $(distdir) || exit 1; done
 
+gmime-$(GMIME_API_VERSION).pc: gmime.pc
+	-cp gmime.pc gmime-$(GMIME_API_VERSION).pc
+
 # This is a version of the automake-1.7 distcheck rule modified to
 # pass --enable-gtk-doc to ./configure and to not chmod distdir to
 # 0444 so that the gtk-docs can actually build.
diff --git a/build/vs2008/.gitignore b/build/vs2008/.gitignore
new file mode 100644
index 0000000..ee7f0e5
--- /dev/null
+++ b/build/vs2008/.gitignore
@@ -0,0 +1,3 @@
+Makefile.in
+Makefile
+config-win32.h
diff --git a/build/vs2008/Makefile.am b/build/vs2008/Makefile.am
index 80d2ee8..5d1ce6a 100644
--- a/build/vs2008/Makefile.am
+++ b/build/vs2008/Makefile.am
@@ -1,7 +1,8 @@
 ## Process this file with automake to produce Makefile.in
 
 EXTRA_DIST = \
-	config.h.win32		\
+	config-win32.h.in	\
+	config-win32.h		\
 	gmime.vcproj		\
 	uuencode.vcproj		\
 	uudecode.vcproj		\
diff --git a/build/vs2008/config.h.win32 b/build/vs2008/config-win32.h.in
similarity index 86%
rename from build/vs2008/config.h.win32
rename to build/vs2008/config-win32.h.in
index ed0b4b4..423fbdb 100644
--- a/build/vs2008/config.h.win32
+++ b/build/vs2008/config-win32.h.in
@@ -4,6 +4,24 @@
 /* Define if GMime should enable warning output. */
 /* #undef ENABLE_WARNINGS */
 
+/* Define to the GMime binary age */
+#define GMIME_BINARY_AGE @GMIME_BINARY_AGE@
+
+/* Define to the GMime interface age */
+#define GMIME_INTERFACE_AGE @GMIME_INTERFACE_AGE@
+
+/* Define to the GMime major version */
+#define GMIME_MAJOR_VERSION @GMIME_MAJOR_VERSION@
+
+/* Define to the GMime micro version */
+#define GMIME_MICRO_VERSION @GMIME_MICRO_VERSION@
+
+/* Define to the GMime minor version */
+#define GMIME_MINOR_VERSION @GMIME_MINOR_VERSION@
+
+/* Define to the GMime version */
+#define GMIME_VERSION "@GMIME_VERSION@"
+
 /* Define if libc defines an altzone variable */
 /* #undef HAVE_ALTZONE */
 
@@ -116,6 +134,9 @@
 /* Define if struct utsname has a domainname member */
 /* #undef HAVE_UTSNAME_DOMAINNAME */
 
+/* Define to 1 if you have the <winsock2.h> header file. */
+#define HAVE_WINSOCK2_H 1
+
 /* Define to 1 if you have the <zlib.h> header file. */
 #define HAVE_ZLIB_H 1
 
@@ -135,23 +156,20 @@
 /* Define to 0 if your system does not have the O_LARGEFILE flag */
 /* #undef O_LARGEFILE */
 
-/* Name of package */
-#define PACKAGE "gmime"
-
 /* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT ""
+#define PACKAGE_BUGREPORT "http://bugzilla.gnome.org/enter_bug.cgi?product=gmime";
 
 /* Define to the full name of this package. */
-#define PACKAGE_NAME ""
+#define PACKAGE_NAME "gmime"
 
 /* Define to the full name and version of this package. */
-#define PACKAGE_STRING ""
+#define PACKAGE_STRING "gmime @GMIME_VERSION@"
 
 /* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME ""
+#define PACKAGE_TARNAME "gmime"
 
 /* Define to the version of this package. */
-#define PACKAGE_VERSION ""
+#define PACKAGE_VERSION "@GMIME_VERSION@"
 
 /* The size of `off_t', as computed by sizeof. */
 #define SIZEOF_OFF_T 4
@@ -165,9 +183,6 @@
 /* Define to 1 if you have the ANSI C header files. */
 #define STDC_HEADERS 1
 
-/* Version number of package */
-#define VERSION "2.4.5"
-
 /* Number of bits in a file offset, on hosts where this is settable. */
 /* #undef _FILE_OFFSET_BITS */
 
diff --git a/build/vs2008/gmime.vcproj b/build/vs2008/gmime.vcproj
index deb08ac..4d87f84 100644
--- a/build/vs2008/gmime.vcproj
+++ b/build/vs2008/gmime.vcproj
@@ -25,7 +25,7 @@
 			<Tool
 				Name="VCPreBuildEventTool"
 				Description="Generating config.h ..."
-				CommandLine="if exist ..\..\config.h goto DONE_CONFIG_H&#x0D;&#x0A;copy config.h.win32 ..\..\config.h&#x0D;&#x0A;:DONE_CONFIG_H&#x0D;&#x0A;"
+				CommandLine="if exist ..\..\config.h goto DONE_CONFIG_H&#x0D;&#x0A;copy config-win32.h ..\..\config.h&#x0D;&#x0A;:DONE_CONFIG_H&#x0D;&#x0A;"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -41,7 +41,6 @@
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				AdditionalOptions="/D &quot;GMIME_MAJOR_VERSION&quot;=&quot;2&quot; /D &quot;GMIME_MINOR_VERSION&quot;=&quot;4&quot; /D &quot;GMIME_MICRO_VERSION&quot;=&quot;6&quot;"
 				Optimization="0"
 				AdditionalIncludeDirectories="&quot;..\..\&quot;; &quot;..\..\util&quot;"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;GMIME_EXPORTS;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
@@ -90,7 +89,7 @@
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="if exist ..\..\config.h goto DONE_CONFIG_H&#x0D;&#x0A;copy config.h.win32 ..\..\config.h&#x0D;&#x0A;:DONE_CONFIG_H&#x0D;&#x0A;"
+				CommandLine="if exist ..\..\config.h goto DONE_CONFIG_H&#x0D;&#x0A;copy config-win32.h ..\..\config.h&#x0D;&#x0A;:DONE_CONFIG_H&#x0D;&#x0A;"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -106,7 +105,6 @@
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				AdditionalOptions="/D &quot;GMIME_MAJOR_VERSION&quot;=&quot;2&quot; /D &quot;GMIME_MINOR_VERSION&quot;=&quot;4&quot; /D &quot;GMIME_MICRO_VERSION&quot;=&quot;6&quot;"
 				AdditionalIncludeDirectories="&quot;..\..\&quot;; &quot;..\..\util&quot;"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;GMIME_EXPORTS;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
 				RuntimeLibrary="2"
diff --git a/configure.in b/configure.in
index 03b559a..0b9701e 100644
--- a/configure.in
+++ b/configure.in
@@ -1,67 +1,146 @@
-dnl Process this file with autoconf to produce a configure script.
-AC_INIT(configure.in)
-AM_CONFIG_HEADER(config.h)
-
-# In the following, there are a the following variants
-# of GLib cflags and libs variables
+# Process this file with autoconf to produce a configure script.
+# require autoconf 2.54
+AC_PREREQ(2.54)
+
+# Making releases:
+#   gmime_micro_version += 1;
+#   gmime_interface_age += 1;
+#   gmime_binary_age += 1;
+# if any functions have been added, set gmime_interface_age to 0.
+# if backwards compatibility has been broken,
+# set gmime_binary_age _and_ gmime_interface_age to 0.
 #
-# GLIB_CFLAGS:  cflags for compiling libraries and example progs
-# GLIB_LIBS:    libraries for linking example programs
-# glib_cflags:  cflags to store in gmime-config
-# glib_libs:    libs to store in gmime-config
-
-GMIME_MAJOR_VERSION=2
-GMIME_MINOR_VERSION=4
-GMIME_MICRO_VERSION=6
-GMIME_VERSION=$GMIME_MAJOR_VERSION.$GMIME_MINOR_VERSION.$GMIME_MICRO_VERSION
-GMIME_VERSION_INFO=`expr $GMIME_MAJOR_VERSION + $GMIME_MINOR_VERSION`:$GMIME_MICRO_VERSION:$GMIME_MINOR_VERSION
+m4_define([gmime_major_version], [2])
+m4_define([gmime_minor_version], [5])
+m4_define([gmime_micro_version], [0])
+m4_define([gmime_interface_age], [0])
+m4_define([gmime_binary_age],
+          [m4_eval(100 * gmime_minor_version + gmime_micro_version)])
+m4_define([gmime_version],
+          [gmime_major_version.gmime_minor_version.gmime_micro_version])
+
+# libtool version related macros
+m4_define([gmime_lt_release], [gmime_major_version.gmime_minor_version])
+m4_define([gmime_lt_current],
+          [m4_eval(100 * gmime_minor_version + gmime_micro_version - gmime_interface_age)])
+m4_define([gmime_lt_revision], [gmime_interface_age])
+m4_define([gmime_lt_age], [m4_eval(gmime_binary_age - gmime_interface_age)])
+m4_define([gmime_lt_current_minus_age],
+          [m4_eval(gmime_lt_current - gmime_lt_age)])
+
+# if the minor version number is odd, then we want debugging.  Otherwise
+# we only want minimal debugging support.
+m4_define([gmime_debug_default],
+          [m4_if(m4_eval(gmime_minor_version % 2), [1], [yes], [minimum])])
+
+# the API version is the major.minor where minor is always even
+m4_define([gmime_api_stable], [m4_eval(10 * gmime_major_version + gmime_minor_version + m4_eval(gmime_minor_version % 2))])
+m4_define([gmime_api_major], [m4_eval(gmime_api_stable / 10)])
+m4_define([gmime_api_minor], [m4_eval(gmime_api_stable % 10)])
+m4_define([gmime_api_version], [gmime_api_major.gmime_api_minor])
+
+
+AC_INIT(gmime, [gmime_version],
+        [http://bugzilla.gnome.org/enter_bug.cgi?product=gmime])
+
+AC_CONFIG_SRCDIR([gmime/gmime.h])
+
+# Save this value here, since automake will set cflags later
+cflags_set=${CFLAGS+set}
+
+AM_INIT_AUTOMAKE([no-define])
+
+# Specify a configuration file
+AM_CONFIG_HEADER([config.h])
+
+
+GMIME_MAJOR_VERSION=gmime_major_version
+GMIME_MINOR_VERSION=gmime_minor_version
+GMIME_MICRO_VERSION=gmime_micro_version
+GMIME_INTERFACE_AGE=gmime_interface_age
+GMIME_BINARY_AGE=gmime_binary_age
+GMIME_API_VERSION=gmime_api_version
+GMIME_VERSION=gmime_version
 
 AC_SUBST(GMIME_MAJOR_VERSION)
 AC_SUBST(GMIME_MINOR_VERSION)
 AC_SUBST(GMIME_MICRO_VERSION)
-AC_SUBST(GMIME_VERSION)
-AC_SUBST(GMIME_VERSION_INFO)
-
-dnl GMIME_API_VERSION does not necessarily reflect GMime's major.minor version
-GMIME_API_VERSION=2.4
 AC_SUBST(GMIME_API_VERSION)
-
-VERSION=$GMIME_VERSION
-
-AM_INIT_AUTOMAKE(gmime, $VERSION)
+AC_SUBST(GMIME_VERSION)
+AC_SUBST(GMIME_INTERFACE_AGE)
+AC_SUBST(GMIME_BINARY_AGE)
+
+AC_DEFINE(GMIME_MAJOR_VERSION, [gmime_major_version],
+	  [Define to the GMime major version])
+AC_DEFINE(GMIME_MINOR_VERSION, [gmime_minor_version],
+	  [Define to the GMime minor version])
+AC_DEFINE(GMIME_MICRO_VERSION, [gmime_micro_version],
+	  [Define to the GMime micro version])
+AC_DEFINE(GMIME_INTERFACE_AGE, [gmime_interface_age],
+	  [Define to the GMime interface age])
+AC_DEFINE(GMIME_BINARY_AGE, [gmime_binary_age],
+	  [Define to the GMime binary age])
+AC_DEFINE(GMIME_VERSION, ["gmime_version"],
+	  [Define to the GMime version])
+
+# libtool versioning
+LT_RELEASE=gmime_lt_release
+LT_CURRENT=gmime_lt_current
+LT_REVISION=gmime_lt_revision
+LT_AGE=gmime_lt_age
+LT_CURRENT_MINUS_AGE=gmime_lt_current_minus_age
+AC_SUBST(LT_RELEASE)
+AC_SUBST(LT_CURRENT)
+AC_SUBST(LT_REVISION)
+AC_SUBST(LT_AGE)
+AC_SUBST(LT_CURRENT_MINUS_AGE)
+
+
+dnl Initialize maintainer mode
+AM_MAINTAINER_MODE
 
 AC_CANONICAL_HOST
 
 dnl Check for win32 platforms
 AC_MSG_CHECKING([if building for Win32])
+LIB_EXE_MACHINE_FLAG=X86
 case "$host" in
   *-*-mingw*)
     platform_win32="yes"
     native_win32="yes"
-    ;;
-  *-*-cygwin*)
-    platform_win32="yes"
-    native_win32="no"
+    case "$host" in
+    x86_64-*-*)
+      LIB_EXE_MACHINE_FLAG=X64
+      ;;
+    esac
     ;;
   *)
     platform_win32="no"
     native_win32="no"
     ;;
 esac
-AC_MSG_RESULT($platform_win32)
-AM_CONDITIONAL(PLATFORM_WIN32, test "x$platform_win32" = "xyes")
-AM_CONDITIONAL(OS_WIN32, test "$native_win32" = "xyes")
+
+AC_MSG_RESULT([$platform_win32])
+
+AC_SUBST(LIB_EXE_MACHINE_FLAG)
+
+AM_CONDITIONAL(PLATFORM_WIN32, [test "x$platform_win32" = "xyes"])
+AM_CONDITIONAL(OS_WIN32, test ["$native_win32" = "xyes"])
+AM_CONDITIONAL(OS_WIN32_X64, [test "$LIB_EXE_MACHINE_FLAG" = "X64"])
 
 if test "$glib_native_win32" = "yes"; then
-  if test "X$enable_static" = "xyes" -o "x$enable_static" = "x"; then
-    AC_MSG_WARN([Disabling static library build, must build as DLL on Windows])
-    enable_static="no"
+  AC_CHECK_TOOL(WINDRES, windres, no)
+  if test "$WINDRES" = no; then
+    AC_MSG_ERROR([*** Could not find an implementation of windres in your PATH.])
   fi
-  if test "x$enable_shared" = "xno"; then
-    AC_MSG_WARN([Enabling shared library build, must build as DLL on Windows])
-    enable_shared="yes"
+  AC_CHECK_TOOL(NM, nm, no)
+  if test "$NM" = no; then
+    AC_MSG_ERROR([*** Could not find an implementation of nm in your PATH.])
   fi
+  AC_CHECK_TOOL(RANLIB, ranlib, :)
+  AC_CHECK_PROG(ms_librarian, [lib.exe], [yes], [no])
 fi
+AM_CONDITIONAL(MS_LIB_AVAILABLE, [test x$ms_librarian = xyes])
 
 dnl Checks for programs.
 AC_ISC_POSIX
@@ -80,10 +159,10 @@ AC_PATH_PROG(TAR, tar, /bin/tar)
 
 AC_EXEEXT
 AC_PROG_LIBTOOL
+dnl when using libtool 2.x create libtool early, because it's used in configure
+m4_ifdef([LT_OUTPUT], [LT_OUTPUT])
 DOLT
 
-AM_MAINTAINER_MODE
-
 dnl Checks for header files.
 AC_CHECK_HEADERS(sys/mman.h)
 AC_CHECK_HEADERS(sys/param.h)
@@ -162,11 +241,6 @@ AM_PATH_GLIB_2_0(2.12.0, ,
 		 AC_MSG_ERROR(Cannot find GLIB: Is pkg-config in your path?),
 		 gobject gmodule gthread)
 
-glib_cflags="$GLIB_CFLAGS"
-glib_libs="$GLIB_LIBS"
-AC_SUBST(glib_cflags)
-AC_SUBST(glib_libs)
-
 dnl *****************************
 dnl *** Checks for zlib       ***
 dnl *****************************
@@ -489,8 +563,8 @@ LIBS="$LIBS $EXTRA_LIBS"
 AC_SUBST(LIBS)
 
 GMIME_LIBDIR="-L${libdir}"
-GMIME_INCLUDEDIR="-I${includedir}/gmime-2.4"
-GMIME_LIBS="-lgmime-2.4 $EXTRA_LIBS"
+GMIME_INCLUDEDIR="-I${includedir}/gmime-2.6"
+GMIME_LIBS="-lgmime-2.6 $EXTRA_LIBS"
 
 AC_SUBST(GMIME_LIBS)
 AC_SUBST(GMIME_LIBDIR)
@@ -502,6 +576,7 @@ AC_OUTPUT(
 Makefile
 build/Makefile
 build/vs2008/Makefile
+build/vs2008/config-win32.h
 docs/Makefile
 docs/reference/Makefile
 docs/tutorial/Makefile
@@ -511,12 +586,12 @@ gmime/Makefile
 mono/Makefile
 mono/AssemblyInfo.cs
 mono/gmime-sharp.dll.config
-mono/gmime-sharp-2.4.pc
+mono/gmime-sharp.pc
 src/Makefile
 tests/Makefile
 tools/Makefile
-gmime-2.4.pc
 gmime.spec
+gmime.pc
 )
 
 echo "
diff --git a/docs/reference/.gitignore b/docs/reference/.gitignore
index c3d2162..4876d26 100644
--- a/docs/reference/.gitignore
+++ b/docs/reference/.gitignore
@@ -16,3 +16,4 @@ gmime.interfaces
 gmime.prerequisites
 gmime.signals
 *.stamp
+*.bak
diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am
index f6396cd..5628403 100644
--- a/docs/reference/Makefile.am
+++ b/docs/reference/Makefile.am
@@ -34,7 +34,7 @@ INCLUDES = \
 
 GTKDOC_LIBS = 					\
 	$(top_builddir)/util/libutil.la		\
-	$(top_builddir)/gmime/libgmime-2.4.la 	\
+	$(top_builddir)/gmime/libgmime-$(GMIME_API_VERSION).la 	\
 	$(GLIB_LIBS)
 
 # Extra SGML files that are included by $(DOC_MAIN_SGML_FILE)
diff --git a/docs/reference/gmime.hierarchy b/docs/reference/gmime.hierarchy
deleted file mode 100644
index 6b97aeb..0000000
--- a/docs/reference/gmime.hierarchy
+++ /dev/null
@@ -1,45 +0,0 @@
-GObject
-  GMimeObject
-    GMimeMessage
-    GMimePart
-      GMimeMessagePartial
-    GMimeMultipart
-      GMimeMultipartEncrypted
-      GMimeMultipartSigned
-    GMimeMessagePart
-  GMimeContentType
-  GMimeContentDisposition
-  InternetAddress
-    InternetAddressGroup
-    InternetAddressMailbox
-  InternetAddressList
-  GMimeCipherContext
-    GMimeGpgContext
-  GMimeDataWrapper
-  GMimeFilter
-    GMimeFilterBasic
-    GMimeFilterBest
-    GMimeFilterCharset
-    GMimeFilterCRLF
-    GMimeFilterEnriched
-    GMimeFilterFrom
-    GMimeFilterGZip
-    GMimeFilterHTML
-    GMimeFilterMd5
-    GMimeFilterStrip
-    GMimeFilterWindows
-    GMimeFilterYenc
-  GMimeParser
-  GMimeSession
-    GMimeSessionSimple
-  GMimeStream
-    GMimeStreamBuffer
-    GMimeStreamCat
-    GMimeStreamFile
-    GMimeStreamFilter
-    GMimeStreamFs
-    GMimeStreamMem
-    GMimeStreamMmap
-    GMimeStreamNull
-GInterface
-  GTypePlugin
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 79f93df..bc067a6 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -10,11 +10,11 @@ noinst_PROGRAMS = basic-example imap-example
 
 DEPS = 						\
 	$(top_builddir)/util/libutil.la		\
-	$(top_builddir)/gmime/libgmime-2.4.la
+	$(top_builddir)/gmime/libgmime-$(GMIME_API_VERSION).la
 
 LDADDS = 					\
 	$(top_builddir)/util/libutil.la		\
-	$(top_builddir)/gmime/libgmime-2.4.la 	\
+	$(top_builddir)/gmime/libgmime-$(GMIME_API_VERSION).la 	\
 	$(GLIB_LIBS)
 
 basic_example_SOURCES = basic-example.c
diff --git a/gmime.spec.in b/gmime.spec.in
index f731077..8f2bb69 100644
--- a/gmime.spec.in
+++ b/gmime.spec.in
@@ -27,8 +27,8 @@ URL: http://spruce.sourceforge.net/gmime/
 Source: ftp://ftp.gnome.org/pub/GNOME/sources/gmime/2.4/gmime-%{version}.tar.bz2
 BuildRoot: /var/tmp/%{name}-%{version}-%{release}-root
 
-Requires: glib2 >= 2.0.0
-BuildRequires: glib2-devel >= 2.0.0
+Requires: glib2 >= 2.12.0
+BuildRequires: glib2-devel >= 2.12.0
 
 %description
 GMime is a set of utilities for parsing and creating messages using
@@ -40,10 +40,10 @@ the Multipurpose Internet Mail Extension (MIME)
 Summary: .NET bindings for GMime
 Group: Development/Libraries
 Requires: %{name} = %{version}-%{release}
-BuildRequires: mono-core >= 1.0.0
-BuildRequires: gtk-sharp >= 0.9.1
-Requires: mono-core >= 1.0.0
-Requires: gtk-sharp >= 0.9.1
+BuildRequires: mono-core >= 2.0.0
+BuildRequires: gtk-sharp >= 2.4.0
+Requires: mono-core >= 2.0.0
+Requires: gtk-sharp >= 2.4.0
 
 %description sharp
 .NET Bindings for GMime
@@ -80,7 +80,7 @@ rm -rf $RPM_BUILD_ROOT
 %{prefix}/lib/*.sh
 %{prefix}/lib/libgmime*
 %{prefix}/lib/pkgconfig/*
-%{prefix}/include/gmime-2.4/gmime/*.h
+%{prefix}/include/gmime-2.6/gmime/*.h
 %if %{enable_gtk_doc}
 %{_datadir}/gtk-doc/html/*/*
 %endif
diff --git a/gmime/Makefile.am b/gmime/Makefile.am
index f3bed5b..9c4295e 100644
--- a/gmime/Makefile.am
+++ b/gmime/Makefile.am
@@ -2,27 +2,21 @@
 
 SUBDIRS = .
 
-gmimeincludedir = $(includedir)/gmime-2.4/gmime
+gmimeincludedir = $(includedir)/gmime-$(GMIME_API_VERSION)/gmime
 
 INCLUDES = 				\
 	-I$(top_srcdir) 		\
 	-I$(top_srcdir)/util		\
-	$(VERSION_FLAGS) 		\
 	-DG_LOG_DOMAIN=\"gmime\"	\
 	-DG_DISABLE_DEPRECATED		\
 	$(GMIME_CFLAGS)			\
 	$(GLIB_CFLAGS)
 
-VERSION_FLAGS = -DGMIME_VERSION=\"$(GMIME_VERSION)\" 		\
-		-DGMIME_MAJOR_VERSION=$(GMIME_MAJOR_VERSION)	\
-		-DGMIME_MINOR_VERSION=$(GMIME_MINOR_VERSION)	\
-		-DGMIME_MICRO_VERSION=$(GMIME_MICRO_VERSION)
-
 noinst_PROGRAMS = gen-table charset-map
 
-lib_LTLIBRARIES = libgmime-2.4.la
+lib_LTLIBRARIES = libgmime-2.6.la
 
-libgmime_2_4_la_SOURCES = 		\
+libgmime_2_6_la_SOURCES = 		\
 	gmime.c				\
 	gmime-charset.c			\
 	gmime-cipher-context.c		\
@@ -139,18 +133,18 @@ endif
 
 if OS_WIN32
 install-libtool-import-lib:
-	$(INSTALL) .libs/libgmime-2.4.dll.a $(DESTDIR)$(libdir)
+	$(INSTALL) .libs/libgmime-$(GMIME_API_VERSION).dll.a $(DESTDIR)$(libdir)
 
 uninstall-libtool-import-lib:
-	-rm $(DESTDIR)$(libdir)/libgmime-2.4.dll.a
+	-rm $(DESTDIR)$(libdir)/libgmime-$(GMIME_API_VERSION).dll.a
 else
 install-libtool-import-lib:
 uninstall-libtool-import-lib:
 endif
 
-libgmime_2_4_la_LIBADD = $(top_builddir)/util/libutil.la $(GLIB_LIBS)
-libgmime_2_4_la_LDFLAGS = \
-	-version-info $(GMIME_VERSION_INFO) \
+libgmime_2_6_la_LIBADD = $(top_builddir)/util/libutil.la $(GLIB_LIBS)
+libgmime_2_6_la_LDFLAGS = \
+	-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
 	-export-dynamic $(no_undefined)
 
 gen_table_SOURCES = gen-table.c
diff --git a/gmime/gmime-stream-buffer.c b/gmime/gmime-stream-buffer.c
index 1027165..753661b 100644
--- a/gmime/gmime-stream-buffer.c
+++ b/gmime/gmime-stream-buffer.c
@@ -59,7 +59,7 @@ static gboolean stream_eos (GMimeStream *stream);
 static int stream_reset (GMimeStream *stream);
 static gint64 stream_seek (GMimeStream *stream, gint64 offset, GMimeSeekWhence whence);
 static gint64 stream_tell (GMimeStream *stream);
-static ssize_t stream_length (GMimeStream *stream);
+static gint64 stream_length (GMimeStream *stream);
 static GMimeStream *stream_substream (GMimeStream *stream, gint64 start, gint64 end);
 
 
@@ -620,7 +620,7 @@ stream_tell (GMimeStream *stream)
 	return stream->position;
 }
 
-static ssize_t
+static gint64
 stream_length (GMimeStream *stream)
 {
 	GMimeStreamBuffer *buffer = (GMimeStreamBuffer *) stream;
diff --git a/gmime/gmime-stream-cat.c b/gmime/gmime-stream-cat.c
index 130c1df..e626194 100644
--- a/gmime/gmime-stream-cat.c
+++ b/gmime/gmime-stream-cat.c
@@ -52,7 +52,7 @@ static gboolean stream_eos (GMimeStream *stream);
 static int stream_reset (GMimeStream *stream);
 static gint64 stream_seek (GMimeStream *stream, gint64 offset, GMimeSeekWhence whence);
 static gint64 stream_tell (GMimeStream *stream);
-static ssize_t stream_length (GMimeStream *stream);
+static gint64 stream_length (GMimeStream *stream);
 static GMimeStream *stream_substream (GMimeStream *stream, gint64 start, gint64 end);
 
 
@@ -527,11 +527,11 @@ stream_tell (GMimeStream *stream)
 	return stream->position;
 }
 
-static ssize_t
+static gint64
 stream_length (GMimeStream *stream)
 {
 	GMimeStreamCat *cat = GMIME_STREAM_CAT (stream);
-	ssize_t len, total = 0;
+	gint64 len, total = 0;
 	struct _cat_node *n;
 	
 	if (stream->bound_end != -1)
@@ -563,7 +563,7 @@ stream_substream (GMimeStream *stream, gint64 start, gint64 end)
 	gint64 offset = 0, subend = 0;
 	GMimeStream *substream;
 	struct _cat_node *n;
-	ssize_t len;
+	gint64 len;
 	
 	d(fprintf (stderr, "GMimeStreamCat::substream (%p, %ld, %ld)\n", stream, start, end));
 	
diff --git a/gmime/gmime-stream-file.c b/gmime/gmime-stream-file.c
index 5a9e29c..8af083a 100644
--- a/gmime/gmime-stream-file.c
+++ b/gmime/gmime-stream-file.c
@@ -54,7 +54,7 @@ static gboolean stream_eos (GMimeStream *stream);
 static int stream_reset (GMimeStream *stream);
 static gint64 stream_seek (GMimeStream *stream, gint64 offset, GMimeSeekWhence whence);
 static gint64 stream_tell (GMimeStream *stream);
-static ssize_t stream_length (GMimeStream *stream);
+static gint64 stream_length (GMimeStream *stream);
 static GMimeStream *stream_substream (GMimeStream *stream, gint64 start, gint64 end);
 
 
@@ -331,7 +331,7 @@ stream_tell (GMimeStream *stream)
 	return stream->position;
 }
 
-static ssize_t
+static gint64
 stream_length (GMimeStream *stream)
 {
 	GMimeStreamFile *fstream = (GMimeStreamFile *) stream;
diff --git a/gmime/gmime-stream-filter.c b/gmime/gmime-stream-filter.c
index 12342b9..9c23dd0 100644
--- a/gmime/gmime-stream-filter.c
+++ b/gmime/gmime-stream-filter.c
@@ -81,7 +81,7 @@ static gboolean stream_eos (GMimeStream *stream);
 static int stream_reset (GMimeStream *stream);
 static gint64 stream_seek (GMimeStream *stream, gint64 offset, GMimeSeekWhence whence);
 static gint64 stream_tell (GMimeStream *stream);
-static ssize_t stream_length (GMimeStream *stream);
+static gint64 stream_length (GMimeStream *stream);
 static GMimeStream *stream_substream (GMimeStream *stream, gint64 start, gint64 end);
 
 
@@ -352,7 +352,7 @@ stream_tell (GMimeStream *stream)
 	return -1;
 }
 
-static ssize_t
+static gint64
 stream_length (GMimeStream *stream)
 {
 	return stream->bound_end - stream->bound_start;
diff --git a/gmime/gmime-stream-fs.c b/gmime/gmime-stream-fs.c
index d868cad..75d0d4f 100644
--- a/gmime/gmime-stream-fs.c
+++ b/gmime/gmime-stream-fs.c
@@ -72,7 +72,7 @@ static gboolean stream_eos (GMimeStream *stream);
 static int stream_reset (GMimeStream *stream);
 static gint64 stream_seek (GMimeStream *stream, gint64 offset, GMimeSeekWhence whence);
 static gint64 stream_tell (GMimeStream *stream);
-static ssize_t stream_length (GMimeStream *stream);
+static gint64 stream_length (GMimeStream *stream);
 static GMimeStream *stream_substream (GMimeStream *stream, gint64 start, gint64 end);
 
 
@@ -389,7 +389,7 @@ stream_tell (GMimeStream *stream)
 	return stream->position;
 }
 
-static ssize_t
+static gint64
 stream_length (GMimeStream *stream)
 {
 	GMimeStreamFs *fs = (GMimeStreamFs *) stream;
diff --git a/gmime/gmime-stream-mem.c b/gmime/gmime-stream-mem.c
index d94850d..33d1991 100644
--- a/gmime/gmime-stream-mem.c
+++ b/gmime/gmime-stream-mem.c
@@ -52,7 +52,7 @@ static gboolean stream_eos (GMimeStream *stream);
 static int stream_reset (GMimeStream *stream);
 static gint64 stream_seek (GMimeStream *stream, gint64 offset, GMimeSeekWhence whence);
 static gint64 stream_tell (GMimeStream *stream);
-static ssize_t stream_length (GMimeStream *stream);
+static gint64 stream_length (GMimeStream *stream);
 static GMimeStream *stream_substream (GMimeStream *stream, gint64 start, gint64 end);
 
 
@@ -296,7 +296,7 @@ stream_tell (GMimeStream *stream)
 	return stream->position;
 }
 
-static ssize_t
+static gint64
 stream_length (GMimeStream *stream)
 {
 	GMimeStreamMem *mem = GMIME_STREAM_MEM (stream);
diff --git a/gmime/gmime-stream-mmap.c b/gmime/gmime-stream-mmap.c
index a9478a8..49d8e3c 100644
--- a/gmime/gmime-stream-mmap.c
+++ b/gmime/gmime-stream-mmap.c
@@ -61,7 +61,7 @@ static gboolean stream_eos (GMimeStream *stream);
 static int stream_reset (GMimeStream *stream);
 static gint64 stream_seek (GMimeStream *stream, gint64 offset, GMimeSeekWhence whence);
 static gint64 stream_tell (GMimeStream *stream);
-static ssize_t stream_length (GMimeStream *stream);
+static gint64 stream_length (GMimeStream *stream);
 static GMimeStream *stream_substream (GMimeStream *stream, gint64 start, gint64 end);
 
 
@@ -342,7 +342,7 @@ stream_tell (GMimeStream *stream)
 	return stream->position;
 }
 
-static ssize_t
+static gint64
 stream_length (GMimeStream *stream)
 {
 	GMimeStreamMmap *mstream = (GMimeStreamMmap *) stream;
diff --git a/gmime/gmime-stream-null.c b/gmime/gmime-stream-null.c
index d470d31..d1fc16f 100644
--- a/gmime/gmime-stream-null.c
+++ b/gmime/gmime-stream-null.c
@@ -54,7 +54,7 @@ static gboolean stream_eos (GMimeStream *stream);
 static int stream_reset (GMimeStream *stream);
 static gint64 stream_seek (GMimeStream *stream, gint64 offset, GMimeSeekWhence whence);
 static gint64 stream_tell (GMimeStream *stream);
-static ssize_t stream_length (GMimeStream *stream);
+static gint64 stream_length (GMimeStream *stream);
 static GMimeStream *stream_substream (GMimeStream *stream, gint64 start, gint64 end);
 
 
@@ -212,7 +212,7 @@ stream_tell (GMimeStream *stream)
 	return stream->position;
 }
 
-static ssize_t
+static gint64
 stream_length (GMimeStream *stream)
 {
 	GMimeStreamNull *null = (GMimeStreamNull *) stream;
diff --git a/gmime/gmime-stream.c b/gmime/gmime-stream.c
index 61f32d8..152eaa8 100644
--- a/gmime/gmime-stream.c
+++ b/gmime/gmime-stream.c
@@ -55,7 +55,7 @@ static gboolean stream_eos (GMimeStream *stream);
 static int stream_reset (GMimeStream *stream);
 static gint64 stream_seek (GMimeStream *stream, gint64 offset, GMimeSeekWhence whence);
 static gint64 stream_tell (GMimeStream *stream);
-static ssize_t stream_length (GMimeStream *stream);
+static gint64 stream_length (GMimeStream *stream);
 static GMimeStream *stream_substream (GMimeStream *stream, gint64 start, gint64 end);
 
 
@@ -381,7 +381,7 @@ g_mime_stream_tell (GMimeStream *stream)
 }
 
 
-static ssize_t
+static gint64
 stream_length (GMimeStream *stream)
 {
 	gint64 position = stream->position;
@@ -408,7 +408,7 @@ stream_length (GMimeStream *stream)
  *
  * Returns: the length of the stream or %-1 if unknown.
  **/
-ssize_t
+gint64
 g_mime_stream_length (GMimeStream *stream)
 {
 	g_return_val_if_fail (GMIME_IS_STREAM (stream), -1);
diff --git a/gmime/gmime-stream.h b/gmime/gmime-stream.h
index 7931201..3076af4 100644
--- a/gmime/gmime-stream.h
+++ b/gmime/gmime-stream.h
@@ -102,7 +102,7 @@ struct _GMimeStreamClass {
 	int      (* reset)  (GMimeStream *stream);
 	gint64   (* seek)   (GMimeStream *stream, gint64 offset, GMimeSeekWhence whence);
 	gint64   (* tell)   (GMimeStream *stream);
-	ssize_t  (* length) (GMimeStream *stream);
+	gint64   (* length) (GMimeStream *stream);
 	GMimeStream * (* substream) (GMimeStream *stream, gint64 start, gint64 end);
 };
 
@@ -119,9 +119,9 @@ int       g_mime_stream_flush   (GMimeStream *stream);
 int       g_mime_stream_close   (GMimeStream *stream);
 gboolean  g_mime_stream_eos     (GMimeStream *stream);
 int       g_mime_stream_reset   (GMimeStream *stream);
-gint64     g_mime_stream_seek    (GMimeStream *stream, gint64 offset, GMimeSeekWhence whence);
-gint64     g_mime_stream_tell    (GMimeStream *stream);
-ssize_t   g_mime_stream_length  (GMimeStream *stream);
+gint64    g_mime_stream_seek    (GMimeStream *stream, gint64 offset, GMimeSeekWhence whence);
+gint64    g_mime_stream_tell    (GMimeStream *stream);
+gint64    g_mime_stream_length  (GMimeStream *stream);
 
 GMimeStream *g_mime_stream_substream (GMimeStream *stream, gint64 start, gint64 end);
 
@@ -132,7 +132,6 @@ ssize_t   g_mime_stream_printf       (GMimeStream *stream, const char *fmt, ...)
 
 ssize_t   g_mime_stream_write_to_stream (GMimeStream *src, GMimeStream *dest);
 
-
 ssize_t    g_mime_stream_writev (GMimeStream *stream, GMimeStreamIOVector *vector, size_t count);
 
 G_END_DECLS
diff --git a/mono/.gitignore b/mono/.gitignore
index a788e85..958bd1d 100644
--- a/mono/.gitignore
+++ b/mono/.gitignore
@@ -4,6 +4,6 @@ generated-stamp
 generated/
 AssemblyInfo.cs
 gmime-api.xml
-gmime-sharp-2.4.pc
+gmime-sharp*.pc
 gmime-sharp.dll.config
-gmime-sharp.dll
+gmime-sharp.dll
\ No newline at end of file
diff --git a/mono/Makefile.am b/mono/Makefile.am
index 65af0c0..93fb3d3 100644
--- a/mono/Makefile.am
+++ b/mono/Makefile.am
@@ -53,7 +53,10 @@ EXTRA_DIST =			\
 	$(customs)		\
 	$(sources)		\
 	$(SOURCES_XML)		\
-	$(PACKAGE_SHARP).pc.in
+	gmime-sharp.pc.in
+
+$(PACKAGE_SHARP).pc: gmime-sharp.pc
+	-cp gmime-sharp.pc $(PACKAGE_SHARP).pc
 
 $(API): $(srcdir)/$(RAW_API) $(srcdir)/$(METADATA)
 	cp $(srcdir)/$(RAW_API) $(API)
diff --git a/src/Makefile.am b/src/Makefile.am
index 43edbc5..4725b96 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -8,11 +8,11 @@ bin_PROGRAMS = uuencode uudecode
 
 DEPS = 						\
 	$(top_builddir)/util/libutil.la		\
-	$(top_builddir)/gmime/libgmime-2.4.la
+	$(top_builddir)/gmime/libgmime-$(GMIME_API_VERSION).la
 
 LDADDS = 					\
 	$(top_builddir)/util/libutil.la		\
-	$(top_builddir)/gmime/libgmime-2.4.la 	\
+	$(top_builddir)/gmime/libgmime-$(GMIME_API_VERSION).la 	\
 	$(GLIB_LIBS)
 
 if SYSTEM_GETOPT
diff --git a/src/uudecode.c b/src/uudecode.c
index 64a07f4..6068fd1 100644
--- a/src/uudecode.c
+++ b/src/uudecode.c
@@ -70,7 +70,7 @@ usage (const char *progname)
 static void
 version (const char *progname)
 {
-	printf ("%s - GMime %s\n", progname, VERSION);
+	printf ("%s - GMime %s\n", progname, GMIME_VERSION);
 }
 
 static FILE *
diff --git a/src/uuencode.c b/src/uuencode.c
index 5252fd6..bcfa3f2 100644
--- a/src/uuencode.c
+++ b/src/uuencode.c
@@ -97,7 +97,7 @@ usage (const char *progname)
 static void
 version (const char *progname)
 {
-	printf ("%s - GMime %s\n", progname, VERSION);
+	printf ("%s - GMime %s\n", progname, GMIME_VERSION);
 }
 
 static int
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9a3566c..ec9704a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -5,17 +5,11 @@ SUBDIRS = .
 INCLUDES = 				\
 	-I$(top_srcdir) 		\
 	-I$(top_srcdir)/util		\
-	$(VERSION_FLAGS) 		\
 	-DG_LOG_DOMAIN=\"gmime-tests\"	\
 	-DG_DISABLE_DEPRECATED		\
 	$(GMIME_CFLAGS)			\
 	$(GLIB_CFLAGS)
 
-VERSION_FLAGS = -DGMIME_VERSION=\"$(GMIME_VERSION)\" 		\
-		-DGMIME_MAJOR_VERSION=$(GMIME_MAJOR_VERSION)	\
-		-DGMIME_MINOR_VERSION=$(GMIME_MINOR_VERSION)	\
-		-DGMIME_MICRO_VERSION=$(GMIME_MICRO_VERSION)
-
 AUTOMATED_TESTS =	\
 	test-iconv	\
 	test-streams	\
@@ -34,8 +28,8 @@ MANUAL_TESTS =		\
 
 noinst_PROGRAMS = $(AUTOMATED_TESTS) $(MANUAL_TESTS)
 
-DEPS = $(top_builddir)/gmime/libgmime-2.4.la
-LDADDS = $(top_builddir)/gmime/libgmime-2.4.la $(GLIB_LIBS)
+DEPS = $(top_builddir)/gmime/libgmime-$(GMIME_API_VERSION).la
+LDADDS = $(top_builddir)/gmime/libgmime-$(GMIME_API_VERSION).la $(GLIB_LIBS)
 
 test_best_SOURCES = test-best.c
 test_best_LDFLAGS = 
diff --git a/zentimer.h b/zentimer.h
index 34fa06b..06711cd 100644
--- a/zentimer.h
+++ b/zentimer.h
@@ -25,7 +25,11 @@
 #ifdef ENABLE_ZENTIMER
 
 #include <stdio.h>
+#ifdef WINDOWS
+#include <windows.h>
+#else
 #include <sys/time.h>
+#endif
 #ifdef HAVE_STDINT_H
 #include <stdint.h>
 #elif HAVE_INTTYPES_H
@@ -46,14 +50,22 @@ extern "C" {
 /* ztime_t represents usec */
 typedef uint64_t ztime_t;
 
+#ifdef WINDOWS
+static uint64_t ztimer_freq = 0;
+#endif
+
 static void
 ztime (ztime_t *ztimep)
 {
+#ifdef WINDOWS
+	QueryPerformanceCounter ((LARGE_INTEGER *) ztimep);
+#else
 	struct timeval tv;
 	
 	gettimeofday (&tv, NULL);
 	
 	*ztimep = ((uint64_t) tv.tv_sec * ZTIME_USEC_PER_SEC) + tv.tv_usec;
+#endif
 }
 
 enum {
@@ -121,28 +133,39 @@ ZenTimerResume (ztimer_t *ztimer)
 	ztimer->start += delta;
 }
 
-static void
-ZenTimerReport (ztimer_t *ztimer, const char *oper)
+static double
+ZenTimerElapsed (ztimer_t *ztimer, uint64_t *usec)
 {
-	ztime_t delta;
-	int paused;
+#ifdef WINDOWS
+	static uint64_t freq = 0;
+	ztime_t delta, stop;
+	
+	if (freq == 0)
+		QueryPerformanceFrequency ((LARGE_INTEGER *) &freq);
+#else
+#define freq ZTIME_USEC_PER_SEC
+	ztime_t delta, stop;
+#endif
 	
 	ztimer = ztimer ? ztimer : &__ztimer;
 	
-	if (ztimer->state == ZTIMER_ACTIVE) {
-		ZenTimerPause (ztimer);
-		paused = 1;
-	} else {
-		paused = 0;
-	}
+	if (ztimer->state != ZTIMER_ACTIVE)
+		stop = ztimer->stop;
+	else
+		ztime (&stop);
 	
-	delta = ztimer->stop - ztimer->start;
+	delta = stop - ztimer->start;
 	
-	fprintf (stderr, "ZenTimer: %s took %.6f seconds\n", oper,
-		 (double) delta / (double) ZTIME_USEC_PER_SEC);
+	if (usec != NULL)
+		*usec = (uint64_t) (delta * ((double) ZTIME_USEC_PER_SEC / (double) freq));
 	
-	if (paused)
-		ZenTimerResume (ztimer);
+	return (double) delta / (double) freq;
+}
+
+static void
+ZenTimerReport (ztimer_t *ztimer, const char *oper)
+{
+	fprintf (stderr, "ZenTimer: %s took %.6f seconds\n", oper, ZenTimerElapsed (ztimer, NULL));
 }
 
 #ifdef __cplusplus
@@ -155,6 +178,7 @@ ZenTimerReport (ztimer_t *ztimer, const char *oper)
 #define ZenTimerStop(ztimerp)
 #define ZenTimerPause(ztimerp)
 #define ZenTimerResume(ztimerp)
+#define ZenTimerElapsed(ztimerp, usec)
 #define ZenTimerReport(ztimerp, oper)
 
 #endif /* ENABLE_ZENTIMER */



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