Use nsleep to implement g_usleep on AIX. (#321974, Andrew Paprocki)
authorMatthias Clasen <mclasen@redhat.com>
Sun, 1 Oct 2006 05:53:49 +0000 (05:53 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Sun, 1 Oct 2006 05:53:49 +0000 (05:53 +0000)
2006-10-01  Matthias Clasen  <mclasen@redhat.com>

* glib/gtimer.c (g_usleep): Use nsleep to implement
g_usleep on AIX.  (#321974, Andrew Paprocki)

* configure.in: Check for nsleep

ChangeLog
configure.in
glib/gtimer.c

index 680f836b6424bac5e0eb0a0843961d0326a95214..4d0d73fa122c31cba4abe75731446d7506fe749b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2006-10-01  Matthias Clasen  <mclasen@redhat.com>
 
+       * 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)
 
index 8d6f307e769036095c264b61842e57d271e8957b..bada706f35485d971a40ad76515b192f0c349da4 100644 (file)
@@ -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)
index c58b9b9f9506cf7d1223cbbb341cf6f145c39b22..4d62a7697d23ff6438ed2baacecd9c02308ad89b 100644 (file)
@@ -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 */
 }