Avoid warning
[mono.git] / eglib / test / test.c
index f328eb64ca9b1916c9d6da6db36b7204600c95c7..6dd7bf47469a891c8ca708bf157b99f04936fd02 100644 (file)
  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
 #include <config.h>
 #include <stdlib.h>
 #include <stdio.h>
 
 extern gint global_passed, global_tests;
 
+#ifndef HAVE_VASPRINTF
+  /* systen does not provide a vasprintf function, use the one
+     provided within eglib itself */
+extern int vasprintf(char **ret, const char *format, va_list ap);
+#endif
+
 static gchar *last_result = NULL;
 
 gboolean 
@@ -167,6 +177,11 @@ FAILED(const gchar *format, ...)
        va_list args;
        gint n;
 
+#if !defined(HAVE_VASPRINTF) && !defined(_EGLIB_MAJOR)
+       /* We are linked against the real glib, no vasprintf */
+       g_assert_not_reached ();
+       return NULL;
+#else
        va_start(args, format);
        n = vasprintf(&ret, format, args);
        va_end(args);
@@ -178,20 +193,16 @@ FAILED(const gchar *format, ...)
 
        last_result = ret;
        return ret;
+#endif
 }
 
 gdouble
 get_timestamp()
 {
        /* FIXME: We should use g_get_current_time here */
-#ifdef G_OS_WIN32
-       long int l = GetTickCount();
-       return (gdouble)(l / 1000) + (1.e-6) * ((l % 1000) * 1000);
-#else
-       struct timeval tp;
-       gettimeofday(&tp, NULL);
-       return (gdouble)tp.tv_sec + (1.e-6) * tp.tv_usec;
-#endif
+       GTimeVal res;
+       g_get_current_time (&res);
+       return res.tv_sec + (1.e-6) * res.tv_usec;
 }
 
 /*