summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Rice <tim@multitalents.net>2003-03-18 10:21:40 -0800
committerTim Rice <tim@multitalents.net>2003-03-18 10:21:40 -0800
commit4e4dc561ae948a410fb82fd8b0960ec2cf8e2e70 (patch)
tree0b6421755509120a24fb6881d71b0b540a7ff839
parentcafbcc73349f4e14afed5207b81a1205afc2cee2 (diff)
[configure.ac openbsd-compat/bsd-misc.c openbsd-compat/bsd-misc.h]
add nanosleep(). testing/corrections by Darren Tucker <dtucker@zip.com.au>
-rw-r--r--ChangeLog6
-rw-r--r--configure.ac4
-rw-r--r--openbsd-compat/bsd-misc.c33
-rw-r--r--openbsd-compat/bsd-misc.h11
4 files changed, 50 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 9346f1351..b53c81590 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
120030318
2 - (tim) [configure.ac openbsd-compat/bsd-misc.c openbsd-compat/bsd-misc.h]
3 add nanosleep(). testing/corrections by Darren Tucker <dtucker@zip.com.au>
4
120030317 520030317
2 - (djm) Fix return value checks for RAND_bytes. Report from 6 - (djm) Fix return value checks for RAND_bytes. Report from
3 Steve G <linux_4ever@yahoo.com> 7 Steve G <linux_4ever@yahoo.com>
@@ -1218,4 +1222,4 @@
1218 save auth method before monitor_reset_key_state(); bugzilla bug #284; 1222 save auth method before monitor_reset_key_state(); bugzilla bug #284;
1219 ok provos@ 1223 ok provos@
1220 1224
1221$Id: ChangeLog,v 1.2630 2003/03/17 05:13:53 djm Exp $ 1225$Id: ChangeLog,v 1.2631 2003/03/18 18:21:40 tim Exp $
diff --git a/configure.ac b/configure.ac
index 3469af2f4..83575758f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
1# $Id: configure.ac,v 1.110 2003/03/10 00:38:10 djm Exp $ 1# $Id: configure.ac,v 1.111 2003/03/18 18:21:41 tim Exp $
2 2
3AC_INIT 3AC_INIT
4AC_CONFIG_SRCDIR([ssh.c]) 4AC_CONFIG_SRCDIR([ssh.c])
@@ -1483,6 +1483,8 @@ if test "x$ac_cv_have_struct_timeval" = "xyes" ; then
1483 have_struct_timeval=1 1483 have_struct_timeval=1
1484fi 1484fi
1485 1485
1486AC_CHECK_TYPES(struct timespec)
1487
1486# If we don't have int64_t then we can't compile sftp-server. So don't 1488# If we don't have int64_t then we can't compile sftp-server. So don't
1487# even attempt to do it. 1489# even attempt to do it.
1488if test "x$ac_cv_have_int64_t" = "xno" -a \ 1490if test "x$ac_cv_have_int64_t" = "xno" -a \
diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c
index d7180d424..b8e9996d5 100644
--- a/openbsd-compat/bsd-misc.c
+++ b/openbsd-compat/bsd-misc.c
@@ -25,7 +25,7 @@
25#include "includes.h" 25#include "includes.h"
26#include "xmalloc.h" 26#include "xmalloc.h"
27 27
28RCSID("$Id: bsd-misc.c,v 1.11 2003/01/09 22:53:13 djm Exp $"); 28RCSID("$Id: bsd-misc.c,v 1.12 2003/03/18 18:21:41 tim Exp $");
29 29
30/* 30/*
31 * NB. duplicate __progname in case it is an alias for argv[0] 31 * NB. duplicate __progname in case it is an alias for argv[0]
@@ -135,3 +135,34 @@ setgroups(size_t size, const gid_t *list)
135} 135}
136#endif 136#endif
137 137
138#if !defined(HAVE_NANOSLEEP) && !defined(HAVE_NSLEEP)
139int nanosleep(const struct timespec *req, struct timespec *rem)
140{
141 int rc, saverrno;
142 extern int errno;
143 struct timeval tstart, tstop, tremain, time2wait;
144
145 TIMESPEC_TO_TIMEVAL(&time2wait, req)
146 (void) gettimeofday(&tstart, NULL);
147 rc = select(0, NULL, NULL, NULL, &time2wait);
148 if (rc == -1) {
149 saverrno = errno;
150 (void) gettimeofday (&tstop, NULL);
151 errno = saverrno;
152 tremain.tv_sec = time2wait.tv_sec -
153 (tstop.tv_sec - tstart.tv_sec);
154 tremain.tv_usec = time2wait.tv_usec -
155 (tstop.tv_usec - tstart.tv_usec);
156 tremain.tv_sec += tremain.tv_usec / 1000000L;
157 tremain.tv_usec %= 1000000L;
158 } else {
159 tremain.tv_sec = 0;
160 tremain.tv_usec = 0;
161 }
162 TIMEVAL_TO_TIMESPEC(&tremain, rem)
163
164 return(rc);
165}
166
167#endif
168
diff --git a/openbsd-compat/bsd-misc.h b/openbsd-compat/bsd-misc.h
index 981196044..78d9ccdd4 100644
--- a/openbsd-compat/bsd-misc.h
+++ b/openbsd-compat/bsd-misc.h
@@ -22,7 +22,7 @@
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */ 23 */
24 24
25/* $Id: bsd-misc.h,v 1.6 2002/06/13 21:34:58 mouring Exp $ */ 25/* $Id: bsd-misc.h,v 1.7 2003/03/18 18:21:41 tim Exp $ */
26 26
27#ifndef _BSD_MISC_H 27#ifndef _BSD_MISC_H
28#define _BSD_MISC_H 28#define _BSD_MISC_H
@@ -80,5 +80,14 @@ int truncate (const char *path, off_t length);
80int setgroups(size_t size, const gid_t *list); 80int setgroups(size_t size, const gid_t *list);
81#endif 81#endif
82 82
83#if !defined(HAVE_NANOSLEEP) && !defined(HAVE_NSLEEP)
84#ifndef HAVE_STRUCT_TIMESPEC
85struct timespec {
86 time_t tv_sec;
87 long tv_nsec;
88};
89#endif
90int nanosleep(const struct timespec *req, struct timespec *rem);
91#endif
83 92
84#endif /* _BSD_MISC_H */ 93#endif /* _BSD_MISC_H */