From: Takashi Iwai Subject: Re: Boundary calculation Date: Tue, 17 Jul 2018 09:41:52 +0200 Message-ID: References: <20180716192507.GA7151@localhost.localdomain> <834aaf57-b1d0-1a00-48f8-796add3027e0@ladisch.de> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id D9DE626739D for ; Tue, 17 Jul 2018 09:41:53 +0200 (CEST) In-Reply-To: <834aaf57-b1d0-1a00-48f8-796add3027e0@ladisch.de> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Clemens Ladisch Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org On Tue, 17 Jul 2018 08:43:27 +0200, Clemens Ladisch wrote: > > Ricardo Biehl Pasquali wrote: > > The current calculation for boundary is: > > > > boundary = buffer_size; > > while (boundary * 2 <= LONG_MAX - buffer_size) > > boundary *= 2; > > > > Why isn't a simpler calculation used instead? e.g.: > > > > /* closest multiple of buffer size less or equal LONG_MAX */ > > boundary = LONG_MAX - LONG_MAX % buffer_size; > > To ensure that the factor is a power of two. > > Originally, that was not really necessary, but the algorithm is > now part of the kernel/userspace interface. Right. I don't think we have strictly ABI issue even if relaxing this, but I also don't think it would give so much benefit, either. thanks, Takashi