lkml.org 
[lkml]   [2004]   [May]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: MSEC_TO_JIFFIES is messed up...
    Ingo Molnar <mingo@elte.hu> wrote:
    >
    >
    > * Davide Libenzi <davidel@xmailserver.org> wrote:
    >
    > > > why is it wrong?
    > >
    > > For HZ == 1000 it's fine, even if it'd better to explicitly make it HZ
    > > dependent and let the compiler to discard them.
    >
    > the compiler cannot discard the multiplication and the division from the
    > following:
    >
    > x * 1000 / 1000
    >
    > due to overflows. But we know that HZ is 1000 in the arch-dependent
    > param.h, and in sched.c we use the HZ dependent variant:
    >
    > #ifndef JIFFIES_TO_MSEC
    > # define JIFFIES_TO_MSEC(x) ((x) * 1000 / HZ)
    > #endif
    > #ifndef MSEC_TO_JIFFIES
    > # define MSEC_TO_JIFFIES(x) ((x) * HZ / 1000)
    > #endif
    >

    Yes, that's a correct optimisation. This is simply a namespace clash.

    How about we do:

    #if HZ=1000
    #define MSEC_TO_JIFFIES(msec) (msec)
    #define JIFFIES_TO_MESC(jiffies) (jiffies)
    #elif HZ=100
    #define MSEC_TO_JIFFIES(msec) (msec * 10)
    #define JIFFIES_TO_MESC(jiffies) (jiffies / 10)
    #else
    #define MSEC_TO_JIFFIES(msec) ((HZ * (msec) + 999) / 1000)
    #define JIFFIES_TO_MSEC(jiffies) ...
    #endif

    in some kernel-wide header then kill off all the private implementations?

    -
    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: 2005-03-22 14:03    [W:0.021 / U:59.312 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site