提交 2b9d1496 编写于 作者: I Ingo Molnar

time: ntp: make 64-bit constants more robust

Impact: cleanup, no functionality changed

 - make PPM_SCALE an explicit s64 constant, to
   remove (s64) casts from usage sites.

kernel/time/ntp.o:

   text	   data	    bss	    dec	    hex	filename
   2536	    114	    136	   2786	    ae2	ntp.o.before
   2536	    114	    136	   2786	    ae2	ntp.o.after

md5:
   40a7728d1188aa18e83e21a81fa7b150  ntp.o.before.asm
   40a7728d1188aa18e83e21a81fa7b150  ntp.o.after.asm
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 e9629165
...@@ -190,7 +190,7 @@ struct timex { ...@@ -190,7 +190,7 @@ struct timex {
* offset and maximum frequency tolerance. * offset and maximum frequency tolerance.
*/ */
#define SHIFT_USEC 16 /* frequency offset scale (shift) */ #define SHIFT_USEC 16 /* frequency offset scale (shift) */
#define PPM_SCALE (NSEC_PER_USEC << (NTP_SCALE_SHIFT - SHIFT_USEC)) #define PPM_SCALE ((s64)NSEC_PER_USEC << (NTP_SCALE_SHIFT - SHIFT_USEC))
#define PPM_SCALE_INV_SHIFT 19 #define PPM_SCALE_INV_SHIFT 19
#define PPM_SCALE_INV ((1ll << (PPM_SCALE_INV_SHIFT + NTP_SCALE_SHIFT)) / \ #define PPM_SCALE_INV ((1ll << (PPM_SCALE_INV_SHIFT + NTP_SCALE_SHIFT)) / \
PPM_SCALE + 1) PPM_SCALE + 1)
......
...@@ -408,7 +408,7 @@ static inline void process_adjtimex_modes(struct timex *txc, struct timespec *ts ...@@ -408,7 +408,7 @@ static inline void process_adjtimex_modes(struct timex *txc, struct timespec *ts
time_status &= ~STA_NANO; time_status &= ~STA_NANO;
if (txc->modes & ADJ_FREQUENCY) { if (txc->modes & ADJ_FREQUENCY) {
time_freq = (s64)txc->freq * PPM_SCALE; time_freq = txc->freq * PPM_SCALE;
time_freq = min(time_freq, MAXFREQ_SCALED); time_freq = min(time_freq, MAXFREQ_SCALED);
time_freq = max(time_freq, -MAXFREQ_SCALED); time_freq = max(time_freq, -MAXFREQ_SCALED);
} }
...@@ -505,7 +505,7 @@ int do_adjtimex(struct timex *txc) ...@@ -505,7 +505,7 @@ int do_adjtimex(struct timex *txc)
result = TIME_ERROR; result = TIME_ERROR;
txc->freq = shift_right((time_freq >> PPM_SCALE_INV_SHIFT) * txc->freq = shift_right((time_freq >> PPM_SCALE_INV_SHIFT) *
(s64)PPM_SCALE_INV, NTP_SCALE_SHIFT); PPM_SCALE_INV, NTP_SCALE_SHIFT);
txc->maxerror = time_maxerror; txc->maxerror = time_maxerror;
txc->esterror = time_esterror; txc->esterror = time_esterror;
txc->status = time_status; txc->status = time_status;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册