Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/eglib
diff options
context:
space:
mode:
authorMiguel de Icaza <miguel@gnome.org>2008-10-17 09:34:16 +0400
committerMiguel de Icaza <miguel@gnome.org>2008-10-17 09:34:16 +0400
commit7a559618d0f5598605b0b1692cf9a20e829f519f (patch)
tree260b3d942c1334fc870c3ab45031da6c35169d65 /eglib
parentaaa6341aa65bc1c7d1ca23d5ce458f7599bafd76 (diff)
2008-10-17 Miguel de Icaza <miguel@novell.com>
* 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. svn path=/trunk/mono/; revision=116164
Diffstat (limited to 'eglib')
-rw-r--r--eglib/ChangeLog9
-rw-r--r--eglib/src/Makefile.am5
-rw-r--r--eglib/src/glib.h3
-rw-r--r--eglib/src/gtimer-unix.c (renamed from eglib/src/gtimer.c)38
-rw-r--r--eglib/src/gtimer-win32.c90
5 files changed, 104 insertions, 41 deletions
diff --git a/eglib/ChangeLog b/eglib/ChangeLog
index e861aa554cf..82eb1b685fe 100644
--- a/eglib/ChangeLog
+++ b/eglib/ChangeLog
@@ -1,3 +1,10 @@
+2008-10-17 Miguel de Icaza <miguel@novell.com>
+
+ * 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 <billholmes54@gmail.com>
* src/gdate-win32.c : Fix compiler errors for MSVC.
@@ -11,6 +18,8 @@
2008-10-11 Miguel de Icaza <miguel@novell.com>
+ * 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 f75ba695fb5..d78abc2510f 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 8b42940f9e1..2071113cecb 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
index c6a32962186..085e2c17c8b 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 <glib.h>
-#ifdef _MSC_VER
-#include <windows.h>
-#else
#include <sys/time.h>
-#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-win32.c b/eglib/src/gtimer-win32.c
new file mode 100644
index 00000000000..f9418efa4a7
--- /dev/null
+++ b/eglib/src/gtimer-win32.c
@@ -0,0 +1,90 @@
+/*
+ * Timer
+ *
+ * Author:
+ * Gonzalo Paniagua Javier (gonzalo@novell.com
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <glib.h>
+#include <windows.h>
+
+struct _GTimer {
+ guint64 start;
+ guint64 stop;
+};
+
+GTimer *g_timer_new (void)
+{
+ GTimer *timer;
+
+ timer = g_new0 (GTimer, 1);
+ g_timer_start (timer);
+ return timer;
+}
+
+void
+g_timer_destroy (GTimer *timer)
+{
+ g_return_if_fail (timer != NULL);
+ g_free (timer);
+}
+
+void
+g_timer_start (GTimer *timer)
+{
+ g_return_if_fail (timer != NULL);
+
+ QueryPerformanceCounter ((LARGE_INTEGER*)&timer->start);
+}
+
+void
+g_timer_stop (GTimer *timer)
+{
+ g_return_if_fail (timer != NULL);
+
+ QueryPerformanceCounter ((LARGE_INTEGER*)&timer->stop);
+}
+
+gdouble
+g_timer_elapsed (GTimer *timer, gulong *microseconds)
+{
+ 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;
+}
+
+