This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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


When using 'static int tick', please initialize tick = 0.

On Tue, 20 Jan 1998, John Carr wrote:

> 
> 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;
The above should be:
        static int tick = 0; /* this will initialize tick only once */
> +     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__ */
>   }
> 


Eric Dana
BGS Systems Inc.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]