toplev.c and HZ (was: gcc-2.8.0 released)

John Carr jfc@mit.edu
Tue Jan 20 09:01:00 GMT 1998


I use this patch to fix the HZ problem.  It also is a slight
optimization on earlier versions of Solaris because it calls
sysconf only once (HZ is a macro which calls sysconf, so there
was one extra system call per call to get_run_time).

Tue Jan 20 09:28:11 1998  John Carr  <jfc@mit.edu>

	* toplev.c (get_run_time): Call sysconf(_SC_CLK_TCK), when available,
	to get clock rate.

*** toplev.c.egcs	Sun Jan 18 09:42:28 1998
--- toplev.c	Sun Jan 18 11:07:37 1998
***************
*** 1024,1029 ****
--- 1028,1042 ----
    else
      return (clock() * 1000);
  #else /* not _WIN32 */
+ #ifdef _SC_CLK_TCK
+   {
+     static int tick;
+     if (tick == 0)
+       tick = 1000000 / sysconf(_SC_CLK_TCK);
+     times (&tms);
+     return (tms.tms_utime + tms.tms_stime) * tick;
+   }
+ #else
  #ifdef USG
    times (&tms);
    return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
***************
*** 1037,1042 ****
--- 1050,1056 ----
    return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
  #endif	/* VMS */
  #endif	/* USG */
+ #endif  /* _SC_CLK_TCK */
  #endif	/* _WIN32 */
  #endif	/* __BEOS__ */
  }



More information about the Gcc mailing list