Date: Sun, 29 May 2016 07:23:57 +0000 (UTC) From: Don Lewis <truckman@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r300949 - head/sys/netpfil/ipfw Message-ID: <201605290723.u4T7Nvvk027654@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: truckman Date: Sun May 29 07:23:56 2016 New Revision: 300949 URL: https://svnweb.freebsd.org/changeset/base/300949 Log: 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) Modified: head/sys/netpfil/ipfw/dn_aqm_pie.c head/sys/netpfil/ipfw/dn_sched_fq_pie.c Modified: head/sys/netpfil/ipfw/dn_aqm_pie.c ============================================================================== --- head/sys/netpfil/ipfw/dn_aqm_pie.c Sun May 29 07:14:51 2016 (r300948) +++ head/sys/netpfil/ipfw/dn_aqm_pie.c Sun May 29 07:23:56 2016 (r300949) @@ -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; Modified: head/sys/netpfil/ipfw/dn_sched_fq_pie.c ============================================================================== --- head/sys/netpfil/ipfw/dn_sched_fq_pie.c Sun May 29 07:14:51 2016 (r300948) +++ head/sys/netpfil/ipfw/dn_sched_fq_pie.c Sun May 29 07:23:56 2016 (r300949) @@ -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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605290723.u4T7Nvvk027654>