]> andersk Git - openssh.git/commitdiff
[configure.ac openbsd-compat/bsd-misc.c openbsd-compat/bsd-misc.h]
authortim <tim>
Tue, 18 Mar 2003 18:21:40 +0000 (18:21 +0000)
committertim <tim>
Tue, 18 Mar 2003 18:21:40 +0000 (18:21 +0000)
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 16d7a32e0eb11999fd70cd416d2801165ebd10df..b49e6022255f45522bb0a0af05c6013f3bdae23a 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>
index 85c898db6d097bb1d12432fe0f0c0068d00fc9a8..a3bb46088bc6751ded11fc56ea4c29c97659380f 100644 (file)
@@ -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 b52a6f52ee32bf650545005a9a8e5acdd81e2dae..6e2a488a136aea372d2fce6d1091280daf030447 100644 (file)
@@ -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 2d62ff6556a84940a8781c90d09035f451a9fa50..6eadf1597b210fca5deb4a56b32e2422ce1c0109 100644 (file)
@@ -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 */
This page took 0.05179 seconds and 5 git commands to generate.