]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
[configure.ac openbsd-compat/bsd-misc.c openbsd-compat/bsd-misc.h]
authorTim Rice <tim@multitalents.net>
Tue, 18 Mar 2003 18:21:40 +0000 (10:21 -0800)
committerTim Rice <tim@multitalents.net>
Tue, 18 Mar 2003 18:21:40 +0000 (10:21 -0800)
add nanosleep(). testing/corrections by Darren Tucker <dtucker@zip.com.au>

ChangeLog
configure.ac
openbsd-compat/bsd-misc.c
openbsd-compat/bsd-misc.h

index 9346f13519cf9f7a69a04171036ead1c6f2bedca..b53c81590a7622e70ac842fa7592a3f38012204f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+20030318
+ - (tim) [configure.ac openbsd-compat/bsd-misc.c openbsd-compat/bsd-misc.h]
+   add nanosleep(). testing/corrections by Darren Tucker <dtucker@zip.com.au>
+
 20030317
  - (djm) Fix return value checks for RAND_bytes. Report from 
    Steve G <linux_4ever@yahoo.com>
      save auth method before monitor_reset_key_state(); bugzilla bug #284;
      ok provos@
 
-$Id: ChangeLog,v 1.2630 2003/03/17 05:13:53 djm Exp $
+$Id: ChangeLog,v 1.2631 2003/03/18 18:21:40 tim Exp $
index 3469af2f4cce70afe27bf4b9e89999005a6d4714..83575758f6c285677debcbf7c2f2094c11bd194f 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: configure.ac,v 1.110 2003/03/10 00:38:10 djm Exp $
+# $Id: configure.ac,v 1.111 2003/03/18 18:21:41 tim Exp $
 
 AC_INIT
 AC_CONFIG_SRCDIR([ssh.c])
@@ -1483,6 +1483,8 @@ if test "x$ac_cv_have_struct_timeval" = "xyes" ; then
        have_struct_timeval=1
 fi
 
+AC_CHECK_TYPES(struct timespec)
+
 # If we don't have int64_t then we can't compile sftp-server.  So don't
 # even attempt to do it. 
 if test "x$ac_cv_have_int64_t" = "xno" -a \
index d7180d4249345f5821c8793d2b6fa48877eea005..b8e9996d585eda7cabefc212ace01acdad0c7225 100644 (file)
@@ -25,7 +25,7 @@
 #include "includes.h"
 #include "xmalloc.h"
 
-RCSID("$Id: bsd-misc.c,v 1.11 2003/01/09 22:53:13 djm Exp $");
+RCSID("$Id: bsd-misc.c,v 1.12 2003/03/18 18:21:41 tim Exp $");
 
 /*
  * NB. duplicate __progname in case it is an alias for argv[0]
@@ -135,3 +135,34 @@ setgroups(size_t size, const gid_t *list)
 }
 #endif 
 
+#if !defined(HAVE_NANOSLEEP) && !defined(HAVE_NSLEEP)
+int nanosleep(const struct timespec *req, struct timespec *rem)
+{
+       int rc, saverrno;
+       extern int errno;
+       struct timeval tstart, tstop, tremain, time2wait;
+
+       TIMESPEC_TO_TIMEVAL(&time2wait, req)
+       (void) gettimeofday(&tstart, NULL);
+       rc = select(0, NULL, NULL, NULL, &time2wait);
+       if (rc == -1) {
+               saverrno = errno;
+               (void) gettimeofday (&tstop, NULL);
+               errno = saverrno;
+               tremain.tv_sec = time2wait.tv_sec - 
+                       (tstop.tv_sec - tstart.tv_sec);
+               tremain.tv_usec = time2wait.tv_usec - 
+                       (tstop.tv_usec - tstart.tv_usec);
+               tremain.tv_sec += tremain.tv_usec / 1000000L;
+               tremain.tv_usec %= 1000000L;
+       } else {
+               tremain.tv_sec = 0;
+               tremain.tv_usec = 0;
+       }
+       TIMEVAL_TO_TIMESPEC(&tremain, rem)
+
+       return(rc);
+}
+
+#endif
+
index 981196044bd3d548f170fe1c528faa0d98791e3d..78d9ccdd4d2a192f5f7d3597809943980b663d4f 100644 (file)
@@ -22,7 +22,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-/* $Id: bsd-misc.h,v 1.6 2002/06/13 21:34:58 mouring Exp $ */
+/* $Id: bsd-misc.h,v 1.7 2003/03/18 18:21:41 tim Exp $ */
 
 #ifndef _BSD_MISC_H
 #define _BSD_MISC_H
@@ -80,5 +80,14 @@ int truncate (const char *path, off_t length);
 int setgroups(size_t size, const gid_t *list);
 #endif
 
+#if !defined(HAVE_NANOSLEEP) && !defined(HAVE_NSLEEP)
+#ifndef HAVE_STRUCT_TIMESPEC
+struct timespec {
+       time_t  tv_sec;
+       long    tv_nsec;
+};
+#endif
+int nanosleep(const struct timespec *req, struct timespec *rem);
+#endif
 
 #endif /* _BSD_MISC_H */