From 088c08a2a5a87d84e966ba2b637b4614abd35f0a Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 1 Oct 2006 05:53:49 +0000 Subject: [PATCH] Use nsleep to implement g_usleep on AIX. (#321974, Andrew Paprocki) 2006-10-01 Matthias Clasen * glib/gtimer.c (g_usleep): Use nsleep to implement g_usleep on AIX. (#321974, Andrew Paprocki) * configure.in: Check for nsleep --- ChangeLog | 5 +++++ configure.in | 5 ++++- glib/gtimer.c | 9 +++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 680f836..4d0d73f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2006-10-01 Matthias Clasen + * glib/gtimer.c (g_usleep): Use nsleep to implement + g_usleep on AIX. (#321974, Andrew Paprocki) + + * configure.in: Check for nsleep + * glib/gmain.c: Fix typos in doc comments. (#358421, Tom Tromey) diff --git a/configure.in b/configure.in index 8d6f307..bada706 100644 --- a/configure.in +++ b/configure.in @@ -855,7 +855,10 @@ fi AC_MSG_RESULT(unsigned $glib_size_type) # Check for some functions -AC_CHECK_FUNCS(lstat strerror strsignal memmove vsnprintf stpcpy strcasecmp strncasecmp poll getcwd nanosleep vasprintf setenv unsetenv getc_unlocked readlink symlink) +AC_CHECK_FUNCS(lstat strerror strsignal memmove vsnprintf stpcpy strcasecmp strncasecmp poll getcwd vasprintf setenv unsetenv getc_unlocked readlink symlink) +# Check for high-resolution sleep functions +AC_CHECK_FUNCS(nanosleep nsleep) + AC_CHECK_FUNCS(clock_gettime, [], [ AC_CHECK_LIB(rt, clock_gettime, [ AC_DEFINE(HAVE_CLOCK_GETTIME, 1) diff --git a/glib/gtimer.c b/glib/gtimer.c index c58b9b9..4d62a76 100644 --- a/glib/gtimer.c +++ b/glib/gtimer.c @@ -323,6 +323,14 @@ g_usleep (gulong microseconds) 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; @@ -355,6 +363,7 @@ g_usleep (gulong microseconds) tv.tv_usec = microseconds % G_USEC_PER_SEC; select(0, NULL, NULL, NULL, &tv); } +# endif /* !HAVE_NSLEEP */ # endif /* !HAVE_NANOSLEEP */ #endif /* !G_OS_WIN32 */ } -- 2.7.4