lkml.org 
[lkml]   [2006]   [Feb]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [Patch 1/7] timespec diff utility
    From
    Date
    On Mon, 2006-02-27 at 03:34 -0500, Shailabh Nagar wrote:
    > Arjan van de Ven wrote:
    >
    > >>+/*
    > >>+ * timespec_diff_ns - Return difference of two timestamps in nanoseconds
    > >>+ * In the rare case of @end being earlier than @start, return zero
    > >>+ */
    > >>+static inline nsec_t timespec_diff_ns(struct timespec *start, struct timespec *end)
    > >>+{
    > >>+ nsec_t ret;
    > >>+
    > >>+ ret = (nsec_t)(end->tv_sec - start->tv_sec)*NSEC_PER_SEC;
    > >>+ ret += (nsec_t)(end->tv_nsec - start->tv_nsec);
    > >>+ if (ret < 0)
    > >>+ return 0;
    > >>+ return ret;
    > >>+}
    > >> #endif /* __KERNEL__ */
    > >>
    > >>
    > >>
    > >
    > >wouldn't it be more useful to have this return a timespec as well, and
    > >then it'd be generically useful (and it also probably should then be
    > >uninlined ;)
    > >
    > >
    > Return another timespec to store the difference of two input timespecs ?
    > Would that be useful ?
    > Didn't quite get it.

    the API is a bit crooked right now; you have 2 timespecs as a measure of
    time, and you return a long as diff, rather than another timespec.
    How do you know the nsec_t doesn't overflow ??? I suspect the answer is
    "you don't". timespec's are a way to deal with that nicely. And it makes
    the API more symmetric as well

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2006-02-27 09:39    [W:0.022 / U:3.220 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site