Re: Portable use of timers
- From: "Rob Thorpe" <robert.thorpe@xxxxxxxxxxxx>
- Date: 26 Oct 2006 09:01:04 -0700
bytebro wrote:
Hi,
I am writing some code which is intended to be built using gcc on 'nix
boxes, (and potentially using DJGPP on Windoze machines). Can someone
suggest what might be useful defines to look for to determine whether
or not a particular system offers the gethrtime() function?
At the moment I've got something like this (not massively generic!):
#if defined(__DJGPP__)
// do stuff to read the Pentium time stamp counter
#elif defined(__sparc) || defined(sparc) || defined(__hppa)
#include <sys/time.h>
// do stuff using gethrtime()
#else
// make do with a lo-res counter/timer
#endif
Any advice appreciated.
This is hard. I've tried to do this sort of thing with include files
before, it's difficult to do and difficult to find out the symbols to
search for. Sometimes there is a feature that no-one has defined a
symbol for, so it is impossible to sense in this way.
It might be a better idea to use a configure script generated by
autoconf or something similar rather than using preprocessor symbols.
If you do search on preprocessor symbols then try to avoid naming
machine architectures on *nix. Don't assume that just because you're
on sparc you will have sys/time.h. Its better to depend on systems so
look for __sun__, __sysv__, __hpux and friends.
.
- Follow-Ups:
- Re: Portable use of timers
- From: bytebro
- Re: Portable use of timers
- From: Aki Tuomi
- Re: Portable use of timers
- References:
- Portable use of timers
- From: bytebro
- Portable use of timers
- Prev by Date: Re: Depth First Search in Binary Search Tree?
- Next by Date: Re: Depth First Search in Binary Search Tree?
- Previous by thread: Portable use of timers
- Next by thread: Re: Portable use of timers
- Index(es):
Relevant Pages
|
|