static guint32
get_time_msecs (void)
{
- return g_thread_gettime() / (1000 * 1000);
+ return g_get_monotonic_time () / G_TIME_SPAN_MILLISECOND;
}
static guint32
#include "gthread.h"
#include "gthreadprivate.h"
+#include "gmain.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
static guint64
gettime (void)
{
-#ifdef G_OS_WIN32
- guint64 v;
-
- /* Returns 100s of nanoseconds since start of 1601 */
- GetSystemTimeAsFileTime ((FILETIME *)&v);
-
- /* Offset to Unix epoch */
- v -= G_GINT64_CONSTANT (116444736000000000);
- /* Convert to nanoseconds */
- v *= 100;
-
- return v;
-#else
- struct timeval tv;
-
- gettimeofday (&tv, NULL);
-
- return (guint64) tv.tv_sec * G_NSEC_PER_SEC + tv.tv_usec * (G_NSEC_PER_SEC / G_USEC_PER_SEC);
-#endif
+ return g_get_monotonic_time () * 1000;
}
static gpointer
GLIB_VAR gboolean g_thread_use_default_impl;
GLIB_VAR gboolean g_threads_got_initialized;
+#ifndef G_DISABLE_DEPRECATED
GLIB_VAR guint64 (*g_thread_gettime) (void);
+#endif
/* initializes the mutex/cond/private implementation for glib, might
* only be called once, and must not be called directly or indirectly
g_thread_use_default_impl = FALSE;
g_thread_functions_for_glib_use = *init;
- if (g_thread_gettime_impl)
- g_thread_gettime = g_thread_gettime_impl;
supported = (init->mutex_new &&
init->mutex_lock &&
static GThreadFunctions
g_thread_functions_for_glib_use_default; /* is NULLified */
-static guint64 (*g_thread_gettime_impl) (void) = NULL;
-
#define G_MUTEX_SIZE 0
#define G_MUTEX_SIZE (sizeof (pthread_mutex_t))
-#if defined(HAVE_CLOCK_GETTIME) && defined(HAVE_MONOTONIC_CLOCK)
-#define USE_CLOCK_GETTIME 1
-static gint posix_clock = 0;
-#endif
-
-#if defined(_SC_THREAD_STACK_MIN) || defined (HAVE_PRIORITIES) || defined (USE_CLOCK_GETTIME)
+#if defined(_SC_THREAD_STACK_MIN) || defined (HAVE_PRIORITIES)
#define HAVE_G_THREAD_IMPL_INIT
static void
g_thread_impl_init(void)
g_thread_priority_map [priority]));
# endif
#endif /* HAVE_PRIORITIES */
-
-#ifdef USE_CLOCK_GETTIME
- if (sysconf (_SC_MONOTONIC_CLOCK) >= 0)
- posix_clock = CLOCK_MONOTONIC;
- else
- posix_clock = CLOCK_REALTIME;
-#endif
}
#endif /* _SC_THREAD_STACK_MIN || HAVE_PRIORITIES */
return (pthread_equal (*(pthread_t*)thread1, *(pthread_t*)thread2) != 0);
}
-#ifdef USE_CLOCK_GETTIME
-static guint64
-gettime (void)
-{
- struct timespec tv;
-
- clock_gettime (posix_clock, &tv);
-
- return (guint64) tv.tv_sec * G_NSEC_PER_SEC + tv.tv_nsec;
-}
-static guint64 (*g_thread_gettime_impl)(void) = gettime;
-#else
-static guint64 (*g_thread_gettime_impl)(void) = 0;
-#endif
-
static GThreadFunctions g_thread_functions_for_glib_use_default =
{
g_mutex_new_posix_impl,
g_free (target);
}
-static guint64
-g_thread_gettime_impl (void)
-{
- guint64 v;
-
- /* Returns 100s of nanoseconds since start of 1601 */
- GetSystemTimeAsFileTime ((FILETIME *)&v);
-
- /* Offset to Unix epoch */
- v -= G_GINT64_CONSTANT (116444736000000000);
- /* Convert to nanoseconds */
- v *= 100;
-
- return v;
-}
-
static GThreadFunctions g_thread_functions_for_glib_use_default =
{
g_mutex_new_win32_impl, /* mutex */