diff options
author | truckman <truckman@FreeBSD.org> | 2016-05-29 07:23:56 +0000 |
---|---|---|
committer | truckman <truckman@FreeBSD.org> | 2016-05-29 07:23:56 +0000 |
commit | ba1b6b7d8c746faa99de3fb0c2a0b4dc82c57022 (patch) | |
tree | ce7129bff1caa2a74f1e4537bd2c31a7da2df7fa /sys/netpfil | |
parent | 261014d97dc8b721b0600b36ca3061d770c61961 (diff) | |
download | FreeBSD-src-ba1b6b7d8c746faa99de3fb0c2a0b4dc82c57022.zip FreeBSD-src-ba1b6b7d8c746faa99de3fb0c2a0b4dc82c57022.tar.gz |
Cast some expressions that multiply a long long constant by a
floating point constant to int64_t. This avoids the runtime
conversion of the the other operand in a set of comparisons from
int64_t to floating point and doing the comparisions in floating
point.
Suggested by: lidl
Submitted by: Rasool Al-Saadi <ralsaadi@swin.edu.au>
MFC after: 2 weeks (with r300779)
Diffstat (limited to 'sys/netpfil')
-rw-r--r-- | sys/netpfil/ipfw/dn_aqm_pie.c | 12 | ||||
-rw-r--r-- | sys/netpfil/ipfw/dn_sched_fq_pie.c | 12 |
2 files changed, 12 insertions, 12 deletions
diff --git a/sys/netpfil/ipfw/dn_aqm_pie.c b/sys/netpfil/ipfw/dn_aqm_pie.c index d994986..eedbb51 100644 --- a/sys/netpfil/ipfw/dn_aqm_pie.c +++ b/sys/netpfil/ipfw/dn_aqm_pie.c @@ -244,17 +244,17 @@ calculate_drop_prob(void *x) p *= (PIE_MAX_PROB << 12) / AQM_TIME_1S; /* auto-tune drop probability */ - if (prob< PIE_MAX_PROB * 0.000001) + if (prob < (int64_t)(PIE_MAX_PROB * 0.000001)) p >>= 11 + PIE_FIX_POINT_BITS+12; - else if (prob < PIE_MAX_PROB * 0.00001) + else if (prob < (int64_t)(PIE_MAX_PROB * 0.00001)) p >>= 9 + PIE_FIX_POINT_BITS+12; - else if (prob < PIE_MAX_PROB * 0.0001) + else if (prob < (int64_t)(PIE_MAX_PROB * 0.0001)) p >>= 7 + PIE_FIX_POINT_BITS+12; - else if (prob < PIE_MAX_PROB * 0.001) + else if (prob < (int64_t)(PIE_MAX_PROB * 0.001)) p >>= 5 + PIE_FIX_POINT_BITS+12; - else if (prob < PIE_MAX_PROB * 0.01) + else if (prob < (int64_t)(PIE_MAX_PROB * 0.01)) p >>= 3 + PIE_FIX_POINT_BITS+12; - else if (prob < PIE_MAX_PROB * 0.1) + else if (prob < (int64_t)(PIE_MAX_PROB * 0.1)) p >>= 1 + PIE_FIX_POINT_BITS+12; else p >>= PIE_FIX_POINT_BITS+12; diff --git a/sys/netpfil/ipfw/dn_sched_fq_pie.c b/sys/netpfil/ipfw/dn_sched_fq_pie.c index 6b9628a..4d25db4 100644 --- a/sys/netpfil/ipfw/dn_sched_fq_pie.c +++ b/sys/netpfil/ipfw/dn_sched_fq_pie.c @@ -407,17 +407,17 @@ fq_calculate_drop_prob(void *x) p *= (PIE_MAX_PROB << 12) / AQM_TIME_1S; /* auto-tune drop probability */ - if (prob< PIE_MAX_PROB * 0.000001) + if (prob < (int64_t)(PIE_MAX_PROB * 0.000001)) p >>= 11 + PIE_FIX_POINT_BITS+12; - else if (prob < PIE_MAX_PROB * 0.00001) + else if (prob < (int64_t)(PIE_MAX_PROB * 0.00001)) p >>= 9 + PIE_FIX_POINT_BITS+12; - else if (prob < PIE_MAX_PROB * 0.0001) + else if (prob < (int64_t)(PIE_MAX_PROB * 0.0001)) p >>= 7 + PIE_FIX_POINT_BITS+12; - else if (prob < PIE_MAX_PROB * 0.001) + else if (prob < (int64_t)(PIE_MAX_PROB * 0.001)) p >>= 5 + PIE_FIX_POINT_BITS+12; - else if (prob < PIE_MAX_PROB * 0.01) + else if (prob < (int64_t)(PIE_MAX_PROB * 0.01)) p >>= 3 + PIE_FIX_POINT_BITS+12; - else if (prob < PIE_MAX_PROB * 0.1) + else if (prob < (int64_t)(PIE_MAX_PROB * 0.1)) p >>= 1 + PIE_FIX_POINT_BITS+12; else p >>= PIE_FIX_POINT_BITS+12; |