Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S268968AbUIQQ04 (ORCPT ); Fri, 17 Sep 2004 12:26:56 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S269028AbUIQQYN (ORCPT ); Fri, 17 Sep 2004 12:24:13 -0400 Received: from bay-bridge.veritas.com ([143.127.3.10]:38886 "EHLO MTVMIME02.enterprise.veritas.com") by vger.kernel.org with ESMTP id S269008AbUIQQOU (ORCPT ); Fri, 17 Sep 2004 12:14:20 -0400 Date: Fri, 17 Sep 2004 17:14:06 +0100 (BST) From: Hugh Dickins X-X-Sender: hugh@localhost.localdomain To: Stelian Pop cc: James R Bruce , Andrew Morton , , Andrea Arcangeli Subject: Re: [RFC, 2.6] a simple FIFO implementation In-Reply-To: <20040917154834.GA3180@crusoe.alcove-fr> Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 654 Lines: 18 On Fri, 17 Sep 2004, Stelian Pop wrote: > + * The size will be rounded-up to a power of 2. > + l = min(len, fifo->size - (fifo->in % fifo->size)); > + memcpy(fifo->buffer + (fifo->in % fifo->size), buffer, l); > + l = min(len, fifo->size - (fifo->out % fifo->size)); > + memcpy(buffer, fifo->buffer + (fifo->out % fifo->size), l); The moduli can now be replaced by faster masks "& (fifo->size - 1)". Hugh - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/