[PATCH 01/18] lib: Add gcd() function.
Sascha Hauer
s.hauer at pengutronix.de
Mon Mar 2 23:45:25 PST 2015
On Mon, Mar 02, 2015 at 11:21:45PM +0300, Andrey Panov wrote:
> It calculates greatest common divisor and is
> compiled in only if CONFIG_GCD is selected.
>
> Signed-off-by: Andrey Panov <rockford at yandex.ru>
> ---
> include/linux/gcd.h | 12 ++++++++++++
> lib/Kconfig | 3 +++
> lib/Makefile | 1 +
> lib/gcd.c | 19 +++++++++++++++++++
> 4 files changed, 35 insertions(+)
> create mode 100644 include/linux/gcd.h
> create mode 100644 lib/gcd.c
>
> diff --git a/include/linux/gcd.h b/include/linux/gcd.h
> new file mode 100644
> index 0000000..6405b27
> --- /dev/null
> +++ b/include/linux/gcd.h
> @@ -0,0 +1,12 @@
> +#ifndef _GCD_H
> +#define _GCD_H
> +
> +#include <linux/compiler.h>
> +
> +#if !defined(swap)
> +#define swap(x, y) do { typeof(x) z = x; x = y; y = z; } while (0)
> +#endiif
Please add this to a location where others can use it, maybe
include/linux/kernel.h.
> --- a/lib/Makefile
> +++ b/lib/Makefile
> @@ -52,3 +52,4 @@ obj-$(CONFIG_STMP_DEVICE) += stmp-device.o
> obj-y += wchar.o
> obj-y += libfile.o
> obj-y += bitmap.o
> +obj-$(CONFIG_GCD) += gcd.o
You can safely always compile it without adding an extra option. The
linker will throw it away when it's unused.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list