From: Ryan Lortie Date: Mon, 1 Nov 2010 20:35:10 +0000 (-0400) Subject: Clean up g_usleep() X-Git-Tag: 2.27.3~35 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=38e7aa9855a3e18d5350733ee4177ab00cee15df;p=platform%2Fupstream%2Fglib.git Clean up g_usleep() Remove some code that was written in 2000 to support OSes that do not have nanosleep(). nanosleep() has been specified (in POSIX-1.2001) for almost a decade now, so assume we have it (except on Windows). Remove the checks for nanosleep and nsleep from configure.ac. We're removing this code because we honestly believe that nobody will be affected. If this change negatively impacts you, please file a bug. --- diff --git a/configure.ac b/configure.ac index a79575a..cd797d7 100644 --- a/configure.ac +++ b/configure.ac @@ -955,7 +955,6 @@ AC_CHECK_FUNCS(lstat strerror strsignal memmove vsnprintf stpcpy strcasecmp strn AC_CHECK_FUNCS(chown lchmod lchown fchmod fchown link statvfs statfs utimes getgrgid getpwuid) AC_CHECK_FUNCS(getmntent_r setmntent endmntent hasmntopt getmntinfo) # Check for high-resolution sleep functions -AC_CHECK_FUNCS(nanosleep nsleep) AC_CHECK_FUNCS(splice) AC_CHECK_HEADERS(crt_externs.h) diff --git a/glib/gtimer.c b/glib/gtimer.c index 18acc3f..92e3e3c 100644 --- a/glib/gtimer.c +++ b/glib/gtimer.c @@ -244,57 +244,13 @@ g_usleep (gulong microseconds) { #ifdef G_OS_WIN32 Sleep (microseconds / 1000); -#else /* !G_OS_WIN32 */ -# ifdef HAVE_NANOSLEEP +#else struct timespec request, remaining; request.tv_sec = microseconds / G_USEC_PER_SEC; request.tv_nsec = 1000 * (microseconds % G_USEC_PER_SEC); while (nanosleep (&request, &remaining) == -1 && errno == EINTR) request = remaining; -# else /* !HAVE_NANOSLEEP */ -# ifdef HAVE_NSLEEP - /* on AIX, nsleep is analogous to nanosleep */ - struct timespec request, remaining; - request.tv_sec = microseconds / G_USEC_PER_SEC; - request.tv_nsec = 1000 * (microseconds % G_USEC_PER_SEC); - while (nsleep (&request, &remaining) == -1 && errno == EINTR) - request = remaining; -# else /* !HAVE_NSLEEP */ - if (g_thread_supported ()) - { - static GStaticMutex mutex = G_STATIC_MUTEX_INIT; - static GCond* cond = NULL; - GTimeVal end_time; - - g_get_current_time (&end_time); - if (microseconds > G_MAXLONG) - { - microseconds -= G_MAXLONG; - g_time_val_add (&end_time, G_MAXLONG); - } - g_time_val_add (&end_time, microseconds); - - g_static_mutex_lock (&mutex); - - if (!cond) - cond = g_cond_new (); - - while (g_cond_timed_wait (cond, g_static_mutex_get_mutex (&mutex), - &end_time)) - /* do nothing */; - - g_static_mutex_unlock (&mutex); - } - else - { - struct timeval tv; - tv.tv_sec = microseconds / G_USEC_PER_SEC; - tv.tv_usec = microseconds % G_USEC_PER_SEC; - select(0, NULL, NULL, NULL, &tv); - } -# endif /* !HAVE_NSLEEP */ -# endif /* !HAVE_NANOSLEEP */ -#endif /* !G_OS_WIN32 */ +#endif } /**