Mercurial > hg > octave-lojdl > gnulib-hg
changeset 12328:bf3fd58aaf19
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.
author | Eric Blake <ebb9@byu.net> |
---|---|
date | Wed, 18 Nov 2009 22:14:39 -0700 |
parents | 9e07d6d6ed00 |
children | 1d8d8b72ddd8 |
files | ChangeLog lib/nanosleep.c m4/nanosleep.m4 m4/select.m4 modules/select |
diffstat | 5 files changed, 28 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2009-11-20 Eric Blake <ebb9@byu.net> + 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
--- a/lib/nanosleep.c +++ b/lib/nanosleep.c @@ -134,6 +134,12 @@ { static bool initialized; + if (requested_delay->tv_nsec < 0 || BILLION <= requested_delay->tv_nsec) + { + errno = EINVAL; + return -1; + } + /* set up sig handler */ if (! initialized) {
--- 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_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 @@ 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
--- 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_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