linux-mips
[Top] [All Lists]

Re: [PATCH 1/8] add lib/gcd.c

To: Florian Fainelli <florian@openwrt.org>
Subject: Re: [PATCH 1/8] add lib/gcd.c
From: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Date: Thu, 04 Jun 2009 18:31:09 +0400
Cc: Linux-MIPS <linux-mips@linux-mips.org>, Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org, Takashi Iwai <tiwai@suse.de>, Ralf Baechle <ralf@linux-mips.org>
In-reply-to: <200906041615.10467.florian@openwrt.org>
Organization: MontaVista Software Inc.
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <200906041615.10467.florian@openwrt.org>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mozilla/5.0 (X11; U; Linux i686; rv:1.7.2) Gecko/20040803
Hello.

Florian Fainelli wrote:

This patch adds lib/gcd.c which contains a greatest
common divider implementation taken from
sound/core/pcm_timer.c

Signed-off-by: Florian Fainelli <florian@openwrt.org>

[...]

diff --git a/lib/gcd.c b/lib/gcd.c
new file mode 100644
index 0000000..fbf81a8
--- /dev/null
+++ b/lib/gcd.c
@@ -0,0 +1,20 @@
+#include <linux/gcd.h>
+#include <linux/module.h>
+
+/* Greatest common divisor */
+unsigned long gcd(unsigned long a, unsigned long b)
+{
+       unsigned long r;
+
+       if (a < b) {
+               r = a;
+               a = b;
+       b = r;

   Fix indentation please.

+       }
+       while ((r = a % b) != 0) {
+               a = b;
+               b = r;
+       }
+       return b;
+}
+EXPORT_SYMBOL(gcd);

WBR, Sergei


<Prev in Thread] Current Thread [Next in Thread>