From a4e3caca6ac48b6fa761b6733c02b13858662c2f Mon Sep 17 00:00:00 2001 From: miguel Date: Fri, 17 Oct 2008 05:34:16 +0000 Subject: [PATCH] 2008-10-17 Miguel de Icaza * Allow types to be defined on the eglib-config.h file, that could be a platform specific generated type file. * gtimer.c: split functionality in platforms. git-svn-id: svn+ssh://mono-cvs.ximian.com/source/trunk/mono@116164 e3ebcda4-bce8-0310-ba0a-eca2169e7518 --- eglib/ChangeLog | 9 +++++++ eglib/src/Makefile.am | 5 ++-- eglib/src/glib.h | 3 +++ eglib/src/{gtimer.c => gtimer-unix.c} | 38 --------------------------- eglib/src/{gtimer.c => gtimer-win32.c} | 48 ++-------------------------------- 5 files changed, 16 insertions(+), 87 deletions(-) copy eglib/src/{gtimer.c => gtimer-unix.c} (77%) rename eglib/src/{gtimer.c => gtimer-win32.c} (72%) diff --git a/eglib/ChangeLog b/eglib/ChangeLog index e861aa554..82eb1b685 100644 --- a/eglib/ChangeLog +++ b/eglib/ChangeLog @@ -1,3 +1,10 @@ +2008-10-17 Miguel de Icaza + + * Allow types to be defined on the eglib-config.h file, that could + be a platform specific generated type file. + + * gtimer.c: split functionality in platforms. + 2008-10-13 Bill Holmes * src/gdate-win32.c : Fix compiler errors for MSVC. @@ -11,6 +18,8 @@ 2008-10-11 Miguel de Icaza + * gtimer.c: Same process. + * src/glib.h: Move g_strdup here, to consolidate all allocations in this header, will help for merging the allocation work later. diff --git a/eglib/src/Makefile.am b/eglib/src/Makefile.am index f75ba695f..d78abc251 100644 --- a/eglib/src/Makefile.am +++ b/eglib/src/Makefile.am @@ -2,11 +2,11 @@ noinst_LTLIBRARIES = libeglib.la win_files = \ gdate-win32.c gdir-win32.c gfile-win32.c gmisc-win32.c \ - gmodule-win32.c + gmodule-win32.c gtimer-win32.c unix_files = \ gdate-unix.c gdir-unix.c gfile-unix.c gmisc-unix.c \ - gmodule-unix.c + gmodule-unix.c gtimer-unix.c if PLATFORM_WIN32 os_files = $(win_files) @@ -33,7 +33,6 @@ libeglib_la_SOURCES = \ gpath.c \ gshell.c \ gspawn.c \ - gtimer.c \ gfile.c \ gfile-posix.c \ gpattern.c \ diff --git a/eglib/src/glib.h b/eglib/src/glib.h index 8b42940f9..2071113ce 100644 --- a/eglib/src/glib.h +++ b/eglib/src/glib.h @@ -38,6 +38,7 @@ typedef const void * gconstpointer; typedef char gchar; typedef unsigned char guchar; +#if !G_TYPES_DEFINED #ifdef _MSC_VER typedef __int8 gint8; typedef unsigned __int8 guint8; @@ -64,6 +65,8 @@ typedef float gfloat; typedef double gdouble; typedef uint16_t gunichar2; #endif +#endif + /* * Macros diff --git a/eglib/src/gtimer.c b/eglib/src/gtimer-unix.c similarity index 77% copy from eglib/src/gtimer.c copy to eglib/src/gtimer-unix.c index c6a329621..085e2c17c 100644 --- a/eglib/src/gtimer.c +++ b/eglib/src/gtimer-unix.c @@ -26,20 +26,11 @@ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include -#ifdef _MSC_VER -#include -#else #include -#endif struct _GTimer { -#ifdef _MSC_VER - guint64 start; - guint64 stop; -#else struct timeval start; struct timeval stop; -#endif }; GTimer *g_timer_new (void) @@ -62,48 +53,20 @@ void g_timer_start (GTimer *timer) { g_return_if_fail (timer != NULL); -#ifdef _MSC_VER - QueryPerformanceCounter ((LARGE_INTEGER*)&timer->start); -#else gettimeofday (&timer->start, NULL); memset (&timer->stop, 0, sizeof (struct timeval)); -#endif - } void g_timer_stop (GTimer *timer) { g_return_if_fail (timer != NULL); -#ifdef _MSC_VER - QueryPerformanceCounter ((LARGE_INTEGER*)&timer->stop); -#else gettimeofday (&timer->stop, NULL); -#endif } gdouble g_timer_elapsed (GTimer *timer, gulong *microseconds) { -#ifdef _MSC_VER - guint64 stop; - guint64 freq; - gdouble seconds; - if (timer->stop == 0) { - QueryPerformanceCounter ((LARGE_INTEGER*)&stop); - } - else { - stop = timer->stop; - } - - QueryPerformanceFrequency ((LARGE_INTEGER*)&freq); - seconds = 1.0 * (stop - timer->start) / freq; - - if (microseconds) { - *microseconds = (gulong)(1000000.0 * (stop - timer->start) / freq); - } - return seconds; -#else struct timeval tv; gulong seconds; long usec; @@ -128,7 +91,6 @@ g_timer_elapsed (GTimer *timer, gulong *microseconds) } result = seconds * 1000000 + usec; return (result / 1000000); -#endif } diff --git a/eglib/src/gtimer.c b/eglib/src/gtimer-win32.c similarity index 72% rename from eglib/src/gtimer.c rename to eglib/src/gtimer-win32.c index c6a329621..f9418efa4 100644 --- a/eglib/src/gtimer.c +++ b/eglib/src/gtimer-win32.c @@ -26,20 +26,11 @@ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include -#ifdef _MSC_VER #include -#else -#include -#endif struct _GTimer { -#ifdef _MSC_VER guint64 start; guint64 stop; -#else - struct timeval start; - struct timeval stop; -#endif }; GTimer *g_timer_new (void) @@ -62,30 +53,21 @@ void g_timer_start (GTimer *timer) { g_return_if_fail (timer != NULL); -#ifdef _MSC_VER - QueryPerformanceCounter ((LARGE_INTEGER*)&timer->start); -#else - gettimeofday (&timer->start, NULL); - memset (&timer->stop, 0, sizeof (struct timeval)); -#endif + QueryPerformanceCounter ((LARGE_INTEGER*)&timer->start); } void g_timer_stop (GTimer *timer) { g_return_if_fail (timer != NULL); -#ifdef _MSC_VER + QueryPerformanceCounter ((LARGE_INTEGER*)&timer->stop); -#else - gettimeofday (&timer->stop, NULL); -#endif } gdouble g_timer_elapsed (GTimer *timer, gulong *microseconds) { -#ifdef _MSC_VER guint64 stop; guint64 freq; gdouble seconds; @@ -103,32 +85,6 @@ g_timer_elapsed (GTimer *timer, gulong *microseconds) *microseconds = (gulong)(1000000.0 * (stop - timer->start) / freq); } return seconds; -#else - struct timeval tv; - gulong seconds; - long usec; - gdouble result; - - g_return_val_if_fail (timer != NULL, 0.0); - - if (timer->stop.tv_sec == 0 && timer->stop.tv_usec == 0) { - gettimeofday (&tv, NULL); - } else { - tv = timer->stop; - } - - usec = (tv.tv_usec) - (timer->start.tv_usec); - seconds = tv.tv_sec - timer->start.tv_sec; - if (microseconds) { - if (usec < 0) { - usec += 1000000; - seconds--; - } - *microseconds = usec; - } - result = seconds * 1000000 + usec; - return (result / 1000000); -#endif } -- 2.11.4.GIT