-#ifdef HAVE_CLOCK_GETTIME
- /* librt clock_gettime() is our first choice */
- struct timespec ts;
-
-#ifdef CLOCK_MONOTONIC
- clock_gettime (CLOCK_MONOTONIC, &ts);
-#else
- clock_gettime (CLOCK_REALTIME, &ts);
-#endif
-
- /* In theory monotonic time can have any epoch.
- *
- * glib presently assumes the following:
- *
- * 1) The epoch comes some time after the birth of Jesus of Nazareth, but
- * not more than 10000 years later.
- *
- * 2) The current time also falls sometime within this range.
- *
- * These two reasonable assumptions leave us with a maximum deviation from
- * the epoch of 10000 years, or 315569520000000000 seconds.
- *
- * If we restrict ourselves to this range then the number of microseconds
- * will always fit well inside the constraints of a int64 (by a factor of
- * about 29).
- *
- * If you actually hit the following assertion, probably you should file a
- * bug against your operating system for being excessively silly.
- **/
- g_assert (G_GINT64_CONSTANT (-315569520000000000) < ts.tv_sec &&
- ts.tv_sec < G_GINT64_CONSTANT (315569520000000000));
-
- return (((gint64) ts.tv_sec) * 1000000) + (ts.tv_nsec / 1000);
-
-#elif defined (G_OS_WIN32)