]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Update gcd module from gnulib.
authorBruno Haible <bruno@clisp.org>
Sat, 22 Jul 2006 15:00:46 +0000 (15:00 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:13:39 +0000 (12:13 +0200)
gettext-tools/lib/ChangeLog
gettext-tools/lib/gcd.c

index 1224069cb339f929aa90f3388fb7fe3e20a9237e..9ac59443e9ea696881d1cf6e6d38c396f96939c4 100644 (file)
@@ -1,5 +1,7 @@
 2006-07-22  Bruno Haible  <bruno@clisp.org>
 
+       * gcd.c: Update from gnulib.
+
        * fwriteerror.c: Update from gnulib.
 
        * fnmatch_.h: Update from gnulib.
index 9c46985545d119fa86b10e2908696b560279acba..96f556bb22b487f8851dcbbd590de13f7e543dc9 100644 (file)
@@ -1,5 +1,5 @@
 /* Arithmetic.
-   Copyright (C) 2001-2002 Free Software Foundation, Inc.
+   Copyright (C) 2001-2002, 2006 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2001.
 
    This program is free software; you can redistribute it and/or modify
    along with this program; if not, write to the Free Software Foundation,
    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
+/* This file can also be used to define gcd functions for other unsigned
+   types, such as 'unsigned long long' or 'uintmax_t'.  */
+#ifndef WORD_T
 /* Specification.  */
-#include "gcd.h"
+# include "gcd.h"
+# define WORD_T unsigned long
+# define GCD gcd
+#endif
 
 #include <stdlib.h>
 
 /* Return the greatest common divisor of a > 0 and b > 0.  */
-unsigned long
-gcd (unsigned long a, unsigned long b)
+WORD_T
+GCD (WORD_T a, WORD_T b)
 {
   /* Why no division, as in Euclid's algorithm? Because in Euclid's algorithm
      the division result floor(a/b) or floor(b/a) is very often = 1 or = 2,
@@ -33,7 +39,7 @@ gcd (unsigned long a, unsigned long b)
      bit in a single instruction, and the algorithm uses fewer variables than
      Euclid's algorithm.  */
 
-  unsigned long c = a | b;
+  WORD_T c = a | b;
   c = c ^ (c - 1);
   /* c = largest power of 2 that divides a and b.  */