bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: usleep


From: Eric Blake
Subject: Re: usleep
Date: Fri, 20 Nov 2009 06:59:53 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Eric Blake on 11/18/2009 10:16 PM:
> At any rate, here's what I'm now testing, it has passed on cygwin, 64-bit
> Linux, and Solaris.  The nanosleep code is a complete rewrite, and is
> actually lighter-weight (no need to use clock_gettime).  Unfortunately,
> cross-compiling to mingw is still failing two tests; so some more coding
> efforts are needed beyond this preliminary patch.
> 
> test-nanosleep.c:60: assertion failed
> FAIL: test-nanosleep.exe

Now fixed for mingw as follows, and pushed:

> [no message; often indicative of stack overflow]
> FAIL: test-select-out.sh

This failure is unrelated to this patch series.  It looks like select is
failing to detect pipes properly, but more output in test-select-out.sh
would be nice.

> rm -f t-select-out.tmp
> + rm -f t-select-out.tmp
> ( { sleep 1; echo abc; ./test-select-fd${EXEEXT} w 1 t-select-out.tmp; } | 
> cat) > /dev/null
> + sleep 1
> + cat
> + echo abc
> + ./test-select-fd w 1 t-select-out.tmp
> test `cat t-select-out.tmp` = "1" || exit 1
> cat t-select-out.tmp
> ++ cat t-select-out.tmp
> + test 0 = 1
> + exit 1

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksGoNkACgkQ84KuGfSFAYDTOQCeNuEDlOrL8DGr8LBgbVEIPUca
r1kAoJk8M3zyWONf/ZXYEyqtQvEnXHLx
=r72m
-----END PGP SIGNATURE-----
From d991d18346a1684dbad88f2cb0b426cd76964184 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Wed, 18 Nov 2009 22:14:39 -0700
Subject: [PATCH] nanosleep: improve port to mingw

test-nanosleep failed to link, and exposed a need for argument
validation when nanosleep is missing.

* lib/nanosleep.c (rpl_nanosleep): Reject invalid arguments.
* m4/nanosleep.m4 (gl_FUNC_NANOSLEEP): Incorporate LIBSOCKET into
LIB_NANOSLEEP, but only when needed.
* modules/select (Link): Document LIBSOCKET.
* m4/select.m4 (gl_FUNC_SELECT): Ensure LIBSOCKET is defined early
enough.
---
 ChangeLog       |    8 ++++++++
 lib/nanosleep.c |    6 ++++++
 m4/nanosleep.m4 |   10 +++++++++-
 m4/select.m4    |    3 ++-
 modules/select  |    3 +++
 5 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index eeacc58..9f2a621 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2009-11-20  Eric Blake  <address@hidden>

+       nanosleep: improve port to mingw
+       * lib/nanosleep.c (rpl_nanosleep): Reject invalid arguments.
+       * m4/nanosleep.m4 (gl_FUNC_NANOSLEEP): Incorporate LIBSOCKET into
+       LIB_NANOSLEEP, but only when needed.
+       * modules/select (Link): Document LIBSOCKET.
+       * m4/select.m4 (gl_FUNC_SELECT): Ensure LIBSOCKET is defined early
+       enough.
+
        nanosleep: work around cygwin bug
        * lib/nanosleep.c (rpl_nanosleep) [HAVE_BUG_BIG_NANOSLEEP]:
        Fix logic bug when nanosleep fails.  Work around cygwin 1.5.x
diff --git a/lib/nanosleep.c b/lib/nanosleep.c
index a9311f8..2b5bf5a 100644
--- a/lib/nanosleep.c
+++ b/lib/nanosleep.c
@@ -134,6 +134,12 @@ rpl_nanosleep (const struct timespec *requested_delay,
 {
   static bool initialized;

+  if (requested_delay->tv_nsec < 0 || BILLION <= requested_delay->tv_nsec)
+    {
+      errno = EINVAL;
+      return -1;
+    }
+
   /* set up sig handler */
   if (! initialized)
     {
diff --git a/m4/nanosleep.m4 b/m4/nanosleep.m4
index 211b367..2251e93 100644
--- a/m4/nanosleep.m4
+++ b/m4/nanosleep.m4
@@ -1,4 +1,4 @@
-# serial 29
+# serial 30

 dnl From Jim Meyering.
 dnl Check for the nanosleep function.
@@ -18,6 +18,7 @@ AC_DEFUN([gl_FUNC_NANOSLEEP],

  AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
  AC_CHECK_HEADERS_ONCE([sys/time.h])
+ AC_REQUIRE([gl_FUNC_SELECT])

  nanosleep_save_libs=$LIBS

@@ -102,6 +103,13 @@ AC_DEFUN([gl_FUNC_NANOSLEEP],
     if test "$gl_cv_func_nanosleep" = 'no (mishandles large arguments)'; then
       AC_DEFINE([HAVE_BUG_BIG_NANOSLEEP], [1],
        [Define to 1 if nanosleep mishandles large arguments.])
+    else
+      for ac_lib in $LIBSOCKET; do
+        case " $LIB_NANOSLEEP " in
+        *" $ac_lib "*) ;;
+        *) LIB_NANOSLEEP="$LIB_NANOSLEEP $ac_lib";;
+        esac
+      done
     fi
     AC_LIBOBJ([nanosleep])
     gl_PREREQ_NANOSLEEP
diff --git a/m4/select.m4 b/m4/select.m4
index 53cc059..d801c38 100644
--- a/m4/select.m4
+++ b/m4/select.m4
@@ -1,4 +1,4 @@
-# select.m4 serial 2
+# select.m4 serial 3
 dnl Copyright (C) 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -8,6 +8,7 @@ AC_DEFUN([gl_FUNC_SELECT],
 [
   AC_REQUIRE([gl_HEADER_SYS_SELECT])
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_REQUIRE([gl_SOCKETS])
   if test "$ac_cv_header_winsock2_h" = yes; then
     AC_LIBOBJ([select])
   else
diff --git a/modules/select b/modules/select
index 299d105..dbdaa72 100644
--- a/modules/select
+++ b/modules/select
@@ -18,6 +18,9 @@ Makefile.am:
 Include:
 <sys/select.h>

+Link:
+$(LIBSOCKET)
+
 License:
 LGPLv2+

-- 
1.6.5.rc1


reply via email to

[Prev in Thread] Current Thread [Next in Thread]