[PATCH] CPU-time clocks

Yaakov (Cygwin/X) yselkowitz@users.sourceforge.net
Mon May 16 23:11:00 GMT 2011


On Mon, 2011-05-16 at 12:43 +0200, Corinna Vinschen wrote:
> Thanks for this patch.  It looks good to me with two exceptions:
> 
> >  extern "C" int
> >  clock_gettime (clockid_t clk_id, struct timespec *tp)
> >  {
> > [...]
> > +      hProcess = OpenProcess (PROCESS_QUERY_INFORMATION, 0, p->dwProcessId);
> > +      GetProcessTimes (hProcess, &creation_time, &exit_time, &kernel_time, &user_time);
> > +
> > +      x = ((long long) kernel_time.dwHighDateTime << 32) + ((unsigned) kernel_time.dwLowDateTime)
> > +          + ((long long) user_time.dwHighDateTime << 32) + ((unsigned) user_time.dwLowDateTime);
> 
> Can you please collapse these lines into 80 columns?
> 
> > [...]
> > +      GetThreadTimes (hThread, &creation_time, &exit_time, &kernel_time, &user_time);
> > +      x = ((long long) kernel_time.dwHighDateTime << 32) + ((unsigned) kernel_time.dwLowDateTime)
> > +          + ((long long) user_time.dwHighDateTime << 32) + ((unsigned) user_time.dwLowDateTime);
> 
> Ditto.
> 
> > --- winsup.h	19 Apr 2011 10:02:06 -0000	1.235
> > +++ winsup.h	15 May 2011 19:24:12 -0000
> > @@ -220,6 +220,13 @@
> >  void *hook_or_detect_cygwin (const char *, const void *, WORD&) __attribute__ ((regparm (3)));
> >  
> >  /* Time related */
> > +#define PID_TO_CLOCKID(pid) (pid * 8 + CLOCK_PROCESS_CPUTIME_ID)
> > +#define CLOCKID_TO_PID(cid) ((cid - CLOCK_PROCESS_CPUTIME_ID) / 8)
> > +#define CLOCKID_IS_PROCESS(cid) ((cid % 8) == CLOCK_PROCESS_CPUTIME_ID)
> > +#define THREADID_TO_CLOCKID(tid) (tid * 8 + CLOCK_THREAD_CPUTIME_ID)
> > +#define CLOCKID_TO_THREADID(cid) ((cid - CLOCK_THREAD_CPUTIME_ID) / 8)
> > +#define CLOCKID_IS_THREAD(cid) ((cid % 8) == CLOCK_THREAD_CPUTIME_ID)
> 
> I think these definitions should go into hires.h.  That's the nearest
> thing to a time-specific header file we have.

Revised patch attached.

> As for the newlib thingy, I follow up on the newlib list.

Already committed per your approval there.


Yaakov

-------------- next part --------------
A non-text attachment was scrubbed...
Name: cpuclockid.patch
Type: text/x-patch
Size: 12491 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20110516/4a1fc5c0/attachment.bin>


More information about the Cygwin-patches mailing list