This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
Re: [PATCH] CPU-time clocks
Hi Yaakov,
On May 15 14:31, Yaakov (Cygwin/X) wrote:
> On Sun, 2011-05-15 at 21:11 +0200, Corinna Vinschen wrote:
> > I just applied a patch to implement pthread_attr_setstack etc.
>
> Yes, I just saw that, thank you.
>
> > This affects your patch in that it won't apply cleanly anymore.
> > Would you mind to regenerate your patches relative to CVS HEAD?
>
> Attached.
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.
> Index: winsup.h
> ===================================================================
> RCS file: /cvs/src/src/winsup/cygwin/winsup.h,v
> retrieving revision 1.235
> diff -u -r1.235 winsup.h
> --- 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.
As for the newlib thingy, I follow up on the newlib list.
Thanks,
Corinna