Re: utime() vs. utimes()



Daniel Rock wrote:
Henry Townsend <henry.townsend@xxxxxxxx> wrote:
My code is "portable" in the sense that it's been ported to a number of platforms. I get nanosecond mtime resolution on Solaris, for instance, by peeking into the stat struct. This is clearly not portable but it's protected by ifdef.

No, with UFS you will only get usec resolution.

You're being deliberately argumentative - did you get up on the wrong side of bed today? The Solaris stat structure stores nanosecond resolution; it doesn't matter what the underlying FS can do as long as it's not finer-grained than nanosecond. This just means all the timestamps read out of the stat structure for UFS files will end with three zeroes.

In other words _Solaris_ can handle nanoseconds - it's _UFS_ that provides the usec limitation. I did say that the point was to get the best data available, which is unaffected by the UFS sidetrack.

The best example of a program which "must have" the same info as the filesystem is 'make'. My program is not make but behaves similarly in this way.

Make is quite happy with only seconds resolution. For any granularity there
will be a time interval which will compare as equal. The standard defined
a second should be sufficient.

Make may be happy but it can happily do the wrong thing, thus making the developer unhappy. This stuff is old and has been hashed out before. Don't believe me? Check out GNU make's .LOW_RESOLUTION_TIME feature and rationale.

If you cannot live with that, then program unportable.

Oh, I'm sorry, I must have stumbled into comp.lang.portable-only by mistake! I meant to be in comp.unix.programmer where portability issues are discussed as a fact of life.

HT
.



Relevant Pages

  • Re: alternative to gettickcount
    ... And how does your VB code know what the CPU clock frequency is on the machine on which it is running, so that it knows how to interpret the result? ... Let's face it, Ulrich, ther is NO WAY that you are going to get a nanosecond resolution out of timing anything on a pc! ...
    (microsoft.public.vb.general.discussion)
  • Re: alternative to gettickcount
    ... VB code timing results in the "sub nanosecond" order, ... Ulrich has claimed he is able to do. ... "The resolution is below one nanosecond. ...
    (microsoft.public.vb.general.discussion)
  • Re: alternative to gettickcount
    ... give you one nanosecond resolution in any meaningful way. ... You need to couple QueryPerformanceCounter with QueryPerformanceFrequency for it to have any real meaning. ... But when QPC was polled in a tight loop, ... involves at least one "travel across the bridge" and which therefore cannot possibly produce a result anywhere near the one nanosecond that you have postulated. ...
    (microsoft.public.vb.general.discussion)
  • Re: why I cannot stop this loop at 50 points? (code)
    ... (The system time-of-day clock has subsecond resolution, ... you get less and less than nanosecond ... but you are not forced to divide by 1e9. ... You could use a wider floating type, ...
    (comp.lang.c)
  • Re: Accurate File Timestamps
    ... nanosecond) file timestamps (as shown by "ls -E", for example, on ... Solaris 10)? ... Ideally I need this to work across UNIX platforms. ...
    (comp.unix.programmer)