summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-03-09 08:30:35 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2015-03-09 08:30:35 +0100
commit55ab01c7ff16e5fcb2d91870d0ab84399512ee3f (patch)
tree62effecfbc202bf8954de3bbfab50ecb9c7992db /lib
parent5c8ced1a6dec754a757d730a0205d168728c7f96 (diff)
parent84fcb04367ccf9c89f442c8a5a716cceb34413e6 (diff)
downloadbarebox-55ab01c7ff16e5fcb2d91870d0ab84399512ee3f.tar.gz
barebox-55ab01c7ff16e5fcb2d91870d0ab84399512ee3f.tar.xz
Merge branch 'for-next/rockchip'
Conflicts: arch/arm/Kconfig
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile1
-rw-r--r--lib/gcd.c18
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/Makefile b/lib/Makefile
index b97e52dd27..f08ac5937d 100644
--- 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-y += gcd.o
diff --git a/lib/gcd.c b/lib/gcd.c
new file mode 100644
index 0000000000..86bdba9112
--- /dev/null
+++ b/lib/gcd.c
@@ -0,0 +1,18 @@
+#include <linux/gcd.h>
+
+/* Greatest common divisor */
+unsigned long gcd(unsigned long a, unsigned long b)
+{
+ unsigned long r;
+
+ if (a < b)
+ swap(a, b);
+
+ if (!b)
+ return a;
+ while ((r = a % b) != 0) {
+ a = b;
+ b = r;
+ }
+ return b;
+}