nanosleep() replacement Take 2

Wendy Palm wendyp at cray.com
Wed Mar 19 02:31:58 EST 2003


ok, i finally got it to compile.  i'm still having that limit variable problem with bwlimit() in
scp.c (unicos and unicos/mk machines have a function limit() defined in resources.h)

i'm currently testing the latest version tim sent me and all looks good so far.


Tim Rice wrote:

> After Darren noticed a couple of problems, I've made a few changes.
> 
> I'd like to hear from Wendy if this works on cray.
> 
> Thanks for all the input.
> 
> -------------< cut >----------------
> --- openssh/configure.ac.old	2003-03-09 17:16:43.000000000 -0800
> +++ openssh/configure.ac	2003-03-16 15:38:28.520560008 -0800
> @@ -1483,6 +1483,8 @@
>  	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 \
> --- openssh/openbsd-compat/bsd-misc.c.old	2003-01-19 19:21:01.000000000 -0800
> +++ openssh/openbsd-compat/bsd-misc.c	2003-03-17 14:02:20.905600005 -0800
> @@ -135,3 +135,38 @@
>  }
>  #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 tsave, ttmp, time2wait;
> +
> +	TIMESPEC_TO_TIMEVAL(&time2wait, req)
> +
> +	gettimeofday(&tsave, NULL);
> +	rc = select(0, NULL, NULL, NULL, &time2wait);    
> +	if (rc == -1) {
> +		saverrno = errno;
> +		gettimeofday (&ttmp, NULL);
> +		errno = saverrno;
> +		ttmp.tv_sec -= tsave.tv_sec;
> +		ttmp.tv_usec -= tsave.tv_usec;
> +		tsave.tv_sec = (time2wait.tv_sec - ttmp.tv_sec);
> +		tsave.tv_usec = (time2wait.tv_usec - ttmp.tv_usec);
> +		if(tsave.tv_sec < 0){
> +			tsave.tv_sec = 0;
> +			tsave.tv_usec += 1000000L;
> +		}
> +	}
> +	else {
> +		tsave.tv_sec = 0;
> +		tsave.tv_usec = 0;
> +	}
> +	TIMEVAL_TO_TIMESPEC(&tsave, rem)
> +
> +	return(rc);
> +}
> +
> +#endif
> +
> --- openssh/openbsd-compat/bsd-misc.h.old	2002-06-20 20:35:30.000000000 -0700
> +++ openssh/openbsd-compat/bsd-misc.h	2003-03-16 15:32:29.850560003 -0800
> @@ -80,5 +80,14 @@
>  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 */
> -------------< end cut >----------------
> 
> 


-- 
wendy palm
Cray OS Sustaining Engineering, Cray Inc.
wendyp at cray.com, 651-605-9154




More information about the openssh-unix-dev mailing list