From owner-svn-src-head@freebsd.org Sun May 15 01:56:04 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AC0BAB392E6; Sun, 15 May 2016 01:56:04 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-oi0-f51.google.com (mail-oi0-f51.google.com [209.85.218.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7DCA31D28; Sun, 15 May 2016 01:56:04 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-oi0-f51.google.com with SMTP id x201so223890506oif.3; Sat, 14 May 2016 18:56:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :date:message-id:subject:from:to:cc; bh=R8t7+4KBfzGo6Aa00zQ0hS4pEK18cl7Nzo+yF8hm7Rc=; b=YLJ6UXbYvYR/TjRtBbFDER3fORZc0Kb2Myt83xRdxnqAg8bchocj7qDCEwoH/cEfjk JxttLaRbrydEvhpusMWoioMwlPHzAFOt+4FHiieKmH+lSQfTJylHk8CtpyMrpwZ/6rPb Hi43bve0H0V7H/X3BRV/rqqIKw9KelnAGm1CmIjOYWbyJsmDcueDaMT+BmDTr6PKw8A6 6dvld7+aW4cv/6CFLwqimRsnzdaNh97XVQxZl6XUv2uhlGkckhHja49OGyPuf2sOAzWp POdoPFrIB5CfTucPotVHx/Eld6oq9iCyUU2wr4v+rZWIXJcxEdrON5zeY0VEQGxpw6Vx XVng== X-Gm-Message-State: AOPr4FWpRsOriKRUGzlm074tI1OYysfcfhSE1bfa5YEyscmquciDv/1zb5it9ZzIYhBSLQ== X-Received: by 10.157.56.51 with SMTP id i48mr12623407otc.130.1463275989725; Sat, 14 May 2016 18:33:09 -0700 (PDT) Received: from mail-oi0-f44.google.com (mail-oi0-f44.google.com. [209.85.218.44]) by smtp.gmail.com with ESMTPSA id c9sm7517953oeq.5.2016.05.14.18.33.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 14 May 2016 18:33:09 -0700 (PDT) Received: by mail-oi0-f44.google.com with SMTP id v145so223080416oie.0; Sat, 14 May 2016 18:33:09 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.202.240.68 with SMTP id o65mr13326015oih.0.1463275989138; Sat, 14 May 2016 18:33:09 -0700 (PDT) Reply-To: cem@FreeBSD.org Received: by 10.157.19.20 with HTTP; Sat, 14 May 2016 18:33:09 -0700 (PDT) In-Reply-To: <201605141952.u4EJq4jP017501@repo.freebsd.org> References: <201605141952.u4EJq4jP017501@repo.freebsd.org> Date: Sat, 14 May 2016 18:33:09 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r299751 - head/sys/dev/bwn From: Conrad Meyer To: Adrian Chadd Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 May 2016 01:56:04 -0000 On Sat, May 14, 2016 at 12:52 PM, Adrian Chadd wrote: > Author: adrian > Date: Sat May 14 19:52:04 2016 > New Revision: 299751 > URL: https://svnweb.freebsd.org/changeset/base/299751 > > Log: > [bwn] migrate sqrt and add another couple of util routines. > > ... > > +unsigned int > +bwn_sqrt(struct bwn_mac *mac, unsigned int x) > +{ > + /* Table holding (10 * sqrt(x)) for x between 1 and 256. */ > + static uint8_t sqrt_table[256] = { > + 10, 14, 17, 20, 22, 24, 26, 28, > ... > + }; > + > + if (x == 0) > + return (0); > + if (x >= 256) { > + unsigned int tmp; > + > + for (tmp = 0; x >= (2 * tmp) + 1; x -= (2 * tmp++) + 1) > + /* do nothing */ ; > + return (tmp); Does this approximation method have a name? > + } > + return (sqrt_table[x - 1] / 10); Why do we store the table as 10*sqrt() if we're just going to divide every entry by ten? Best, Conrad