delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/06/04/21:06:23

From: dps AT micro-mono DOT com ("Daniel P. Siu")
Subject: time functions
4 Jun 1997 21:06:23 -0700 :
Sender: mail AT cygnus DOT com
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <3395F505.39B9.cygnus.gnu-win32@micro-mono.com>
Reply-To: dps AT micro-mono DOT com
X-Mailer: Mozilla 3.01Gold (Win95; U)
MIME-Version: 1.0
Original-To: gnu-win32 AT cygnus DOT com
Original-Sender: owner-gnu-win32 AT cygnus DOT com

I just got started with gnu-win32 (w95).  I encountered strange results
with the 'times' library function (I know, this is obsolete but I also
encountered strange though different results with the 'getrusage' system
call).  'times' calls return should return number of 'CLK_TCK' since
invocation of the current process.  Instead it returns very big numbers
(millions).

The following routine is taken from an old Berkeley f77 distribution:

#include <sys/types.h>
#include <sys/times.h>
#include <time.h>

struct tb { float usrtime; float systime; };

float
etime_(et) struct tb *et;
{	struct tms clock;

	times(&clock);
	et->usrtime = (float) clock.tms_utime / (float)CLK_TCK;
	et->systime = (float) clock.tms_stime / (float)CLK_TCK;
	return(et->usrtime + et->systime);
}

This works fine under f2c or g77 and many Unix systems including Linux
and Solaris but gives strange under g77 and gnu-win32.

Thanks in advance.

-- 
Daniel P. Siu
Microwave Monolithics Incorporated
465 E. Easy Street, Simi Valley, CA 93065, USA
VOICE:805-584-6642 FAX:805-584-9594 EMAIL:dps AT micro-mono DOT com
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019