clock_t & return -1

Igor Pechtchanski pechtcha@cs.nyu.edu
Tue Oct 14 18:13:00 GMT 2003


On Tue, 14 Oct 2003, Alex Vinokur wrote:

> # ------ man clock (fragments) ------
> # RETURNS
> #        The amount of processor time used so far by your program, in units
> #        defined by the machine-dependent macro `CLOCKS_PER_SEC'.
> #        If no measurement is available, the result is `-1'.
>
> So, clock() is unsigned and never returns -1 (?!)
>
> If one must write
>   ----------------------------------
>   if (!(clock () == (clock_t)(-1)));
>   ----------------------------------
>   I think it is worth noting that in the manual.

The above is always good practice anyway.  Besides, it seems they do it
this way in a few other places as well:

<http://www.hmug.org/man/3/clock.html>
<http://www.rocketaware.com/man/man3/clock.3.htm>
<http://developer.apple.com/documentation/Darwin/Reference/ManPages/html/clock.3.html>
<http://www-sbras.nsc.ru/cgi-bin/www/unix_help/unix-man?clock+3>
<http://pluto.iis.nsk.su/cgi-bin/man-cgi?clock+3>

IOW, this is not Cygwin specific.  FWIW, you're welcome to submit a patch
to the cygwin-doc package.
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster."  -- Patrick Naughton

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list