From: Eric Blake Date: Thu, 19 Nov 2009 05:14:39 +0000 (-0700) Subject: nanosleep: improve port to mingw X-Git-Tag: v0.1~5159 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=addbb8a80994c7133922f2904dfb929481a3ac17;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index 10f2c7453..f7a77a7a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2009-11-20 Eric Blake + 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 a9311f84d..2b5bf5a9c 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 211b367a0..2251e935e 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 53cc05965..d801c38f4 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 299d105b9..dbdaa723f 100644 --- a/modules/select +++ b/modules/select @@ -18,6 +18,9 @@ Makefile.am: Include: +Link: +$(LIBSOCKET) + License: LGPLv2+