12aa0ea94SEmmanuel Vadot /*-
22aa0ea94SEmmanuel Vadot * Copyright (c) 2000 The NetBSD Foundation, Inc.
32aa0ea94SEmmanuel Vadot * All rights reserved.
42aa0ea94SEmmanuel Vadot *
52aa0ea94SEmmanuel Vadot * This code is derived from software contributed to The NetBSD Foundation
62aa0ea94SEmmanuel Vadot * by Dieter Baron and Thomas Klausner.
72aa0ea94SEmmanuel Vadot *
82aa0ea94SEmmanuel Vadot * Redistribution and use in source and binary forms, with or without
92aa0ea94SEmmanuel Vadot * modification, are permitted provided that the following conditions
102aa0ea94SEmmanuel Vadot * are met:
112aa0ea94SEmmanuel Vadot * 1. Redistributions of source code must retain the above copyright
122aa0ea94SEmmanuel Vadot * notice, this list of conditions and the following disclaimer.
132aa0ea94SEmmanuel Vadot * 2. Redistributions in binary form must reproduce the above copyright
142aa0ea94SEmmanuel Vadot * notice, this list of conditions and the following disclaimer in the
152aa0ea94SEmmanuel Vadot * documentation and/or other materials provided with the distribution.
162aa0ea94SEmmanuel Vadot *
172aa0ea94SEmmanuel Vadot * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
182aa0ea94SEmmanuel Vadot * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
192aa0ea94SEmmanuel Vadot * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
202aa0ea94SEmmanuel Vadot * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
212aa0ea94SEmmanuel Vadot * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
222aa0ea94SEmmanuel Vadot * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
232aa0ea94SEmmanuel Vadot * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
242aa0ea94SEmmanuel Vadot * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
252aa0ea94SEmmanuel Vadot * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
262aa0ea94SEmmanuel Vadot * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
272aa0ea94SEmmanuel Vadot * POSSIBILITY OF SUCH DAMAGE.
282aa0ea94SEmmanuel Vadot */
292aa0ea94SEmmanuel Vadot
30*307f78f3SVladimir Kondratyev #ifndef _LINUXKPI_LINUX_GCD_H_
31*307f78f3SVladimir Kondratyev #define _LINUXKPI_LINUX_GCD_H_
322aa0ea94SEmmanuel Vadot
332aa0ea94SEmmanuel Vadot static inline unsigned long
gcd(unsigned long a,unsigned long b)342aa0ea94SEmmanuel Vadot gcd(unsigned long a, unsigned long b)
352aa0ea94SEmmanuel Vadot {
362aa0ea94SEmmanuel Vadot unsigned long c;
372aa0ea94SEmmanuel Vadot
382aa0ea94SEmmanuel Vadot c = a % b;
392aa0ea94SEmmanuel Vadot while (c != 0) {
402aa0ea94SEmmanuel Vadot a = b;
412aa0ea94SEmmanuel Vadot b = c;
422aa0ea94SEmmanuel Vadot c = a % b;
432aa0ea94SEmmanuel Vadot }
442aa0ea94SEmmanuel Vadot
452aa0ea94SEmmanuel Vadot return (b);
462aa0ea94SEmmanuel Vadot }
472aa0ea94SEmmanuel Vadot
482aa0ea94SEmmanuel Vadot #endif
49