bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "getTicks() in ms" to add for WIN32 and Linux to commonc++?


From: David Sugar
Subject: Re: "getTicks() in ms" to add for WIN32 and Linux to commonc++?
Date: Sat, 3 Jan 2004 09:59:24 -0500
User-agent: KMail/1.5.3

Done.  We probably should also add a snprintf implementation into missing for 
targets that lack that...

On Friday 02 January 2004 02:57 pm, Federico Montesino Pouzols wrote:
>       Yes, I think both should end up in missing.h. Also, as Marc
> Boris has pointed out, there are some classes in CC++ that use
> GetTickCount on Win32, particularly TimerPort (thread.h).
>
> On Fri, Jan 02, 2004 at 10:35:01AM -0500, David Sugar wrote:
> > I recall in reviewing recent changes in ccrtp, that Federico had to add a
> > simulated gettimeofday function for supporting w32 builds.  So perhaps
> > both of these functions, if needed for different things, should end up
> > with a representation in the Common C++ 1.1 reorganized "missing" module
> > for library functions missing from some platforms (missing.h/missing.cpp)
> > ...
> >
> > On Friday 02 January 2004 07:49 am, Wolfgang wrote:
> > > Would it make sense to add a getTicks() type function to the CommonC++
> > > framework? Or do you think it is so trivial that it does not need to be
> > > there? I run into this recently when porting a project from linux to
> > > win32 using commonc++.
> > > Here a draft for for win32 and linux.
> > >
> > >
> > >
> > > #ifndef WIN32
> > > #include <sys/time.h>
> > > #else
> > > #include <time.h>
> > > #include <windows.h>
> > > #endif //win32
> > >
> > >
> > > //return number of ticks in ms
> > > long getTicks();
> > >
> > >
> > > ifdef WIN32
> > > long getTicks() {
> > >   return GetTickCount();
> > > };
> > > #else
> > > long getTicks() {
> > >   long ticks;
> > >   struct timeval now;
> > >   gettimeofday(&now, NULL);
> > >   ticks = now.tv_sec * 1000l;
> > >   ticks += now.tv_usec / 1000l;
> > >   return ticks;
> > > };
> > > #endif
> > >
> > >
> > >
> > > _______________________________________________
> > > Bug-commoncpp mailing list
> > > address@hidden
> > > http://mail.gnu.org/mailman/listinfo/bug-commoncpp
>
> _______________________________________________
> Bug-commoncpp mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/bug-commoncpp





reply via email to

[Prev in Thread] Current Thread [Next in Thread]