[m-rev.] diff: partial implementation of c_times on win32
Peter Wang
novalazy at gmail.com
Wed Oct 8 16:05:50 AEDT 2008
On 2008-10-08, Peter Ross <pro at missioncriticalit.com> wrote:
> @@ -329,6 +331,16 @@
> Result = Ret
> ).
>
> +:- pragma foreign_decl(c, "
> +#ifdef _WIN32
> + #include <windows.h>
> + typedef union
> + {
> + FILETIME ft;
> + __int64 i64;
> + } timeKernel;
> +#endif
> +").
It would be better to make this decl local to the module:
:- pragma foreign_decl("C", local, "...").
Then mark the following foreign_proc as `may_not_duplicate'.
> :- pred time.c_times(int::out, int::out, int::out, int::out, int::out,
> io::di, io::uo) is det.
>
> @@ -347,7 +359,30 @@
> CUt = (MR_Integer) t.tms_cutime;
> CSt = (MR_Integer) t.tms_cstime;
> #else
> + #ifdef _WIN32
> + HANDLE hProcess;
> + FILETIME ftCreation, ftExit, ftKernel, ftUser;
> + timeKernel user, kernel;
> +
> + int factor;
> +
> + hProcess = GetCurrentProcess();
> + GetProcessTimes(hProcess, &ftCreation, &ftExit, &ftKernel, &ftUser);
> +
> + factor = 10000000U / MR_CLOCK_TICKS_PER_SECOND;
> +
> + user.ft = ftUser;
> + kernel.ft = ftKernel;
> +
> + Ut = (MR_Integer) (user.i64 / factor);
> + St = (MR_Integer) (kernel.i64 / factor);
> +
> + /* XXX Not sure how to return children times */
> + CUt = 0;
> + CSt = 0;
> + #else
> Ret = -1;
> + #endif
> #endif
> MR_update_io(IO0, IO);
> }").
Peter
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list