From ba5e91cf9659cb321539d30ac79fe422ead6af8b Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Sun, 27 Jun 2004 05:17:13 +0000 Subject: [PATCH] tweaks to make the doxygen docs build correctly git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@10111 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/Makefile.am | 1 + src/engine/qofmath128.c | 29 +++++++--------- src/engine/qofmath128.h | 76 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 17 deletions(-) create mode 100644 src/engine/qofmath128.h diff --git a/src/engine/Makefile.am b/src/engine/Makefile.am index a143e2568c..a7f080dbf1 100644 --- a/src/engine/Makefile.am +++ b/src/engine/Makefile.am @@ -105,6 +105,7 @@ gncinclude_HEADERS = \ qofid.h \ qofinstance.h \ qofmath128.c \ + qofmath128.h \ qofobject.h \ qofquery.h \ qofquerycore.h \ diff --git a/src/engine/qofmath128.c b/src/engine/qofmath128.c index 8991b9181b..5b409cee41 100644 --- a/src/engine/qofmath128.c +++ b/src/engine/qofmath128.c @@ -24,25 +24,20 @@ #define _GNU_SOURCE #include "config.h" +#include "qofmath128.h" #include /* =============================================================== */ -/* Quick-n-dirty 128-bit math lib. The mult128 routine should work - * great; I think that div128 works, but its not really tested. +/* + * Quick-n-dirty 128-bit integer math lib. Things seem to mostly + * work, and have been tested, but not comprehensively tested. */ -typedef struct { - guint64 hi; - guint64 lo; - short isneg; /* sign-bit -- T if number is negative */ - short isbig; /* sizeflag -- T if number won't fit in signed 64-bit */ -} qofint128; - /** Multiply a pair of signed 64-bit numbers, * returning a signed 128-bit number. */ -static inline qofint128 +inline qofint128 mult128 (gint64 a, gint64 b) { qofint128 prod; @@ -106,7 +101,7 @@ mult128 (gint64 a, gint64 b) /** Divide a signed 128-bit number by a signed 64-bit, * returning a signed 128-bit number. */ -static inline qofint128 +inline qofint128 div128 (qofint128 n, gint64 d) { qofint128 quotient; @@ -160,7 +155,7 @@ div128 (qofint128 n, gint64 d) * I beleive that ths algo is overflow-free, but should be * audited some more ... */ -static inline gint64 +inline gint64 rem128 (qofint128 n, gint64 d) { qofint128 quotient = div128 (n,d); @@ -173,7 +168,7 @@ rem128 (qofint128 n, gint64 d) } /** Return the ratio n/d reduced so that there are no common factors. */ -static inline gnc_numeric +inline gnc_numeric reduce128(qofint128 n, gint64 d) { gint64 t; @@ -206,7 +201,7 @@ reduce128(qofint128 n, gint64 d) } /** Return true of two numbers are equal */ -static inline gboolean +inline gboolean equal128 (qofint128 a, qofint128 b) { if (a.lo != b.lo) return 0; @@ -216,7 +211,7 @@ equal128 (qofint128 a, qofint128 b) } /** Return the greatest common factor of two 64-bit numbers */ -static inline guint64 +inline guint64 gcf64(guint64 num, guint64 denom) { guint64 t; @@ -237,7 +232,7 @@ gcf64(guint64 num, guint64 denom) } /** Return the least common multiple of two 64-bit numbers. */ -static inline qofint128 +inline qofint128 lcm128 (guint64 a, guint64 b) { guint64 gcf = gcf64 (a,b); @@ -246,7 +241,7 @@ lcm128 (guint64 a, guint64 b) } /** Add a pair of 128-bit numbers, returning a 128-bit number */ -static inline qofint128 +inline qofint128 add128 (qofint128 a, qofint128 b) { qofint128 sum; diff --git a/src/engine/qofmath128.h b/src/engine/qofmath128.h new file mode 100644 index 0000000000..a0b09c308c --- /dev/null +++ b/src/engine/qofmath128.h @@ -0,0 +1,76 @@ +/******************************************************************** + * qofmath128.h -- an 128-bit integer library * + * Copyright (C) 2004 Linas Vepstas * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation; either version 2 of * + * the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License* + * along with this program; if not, contact: * + * * + * Free Software Foundation Voice: +1-617-542-5942 * + * 59 Temple Place - Suite 330 Fax: +1-617-542-2652 * + * Boston, MA 02111-1307, USA gnu@gnu.org * + * * + *******************************************************************/ + +#ifndef QOF_MATH_128_H +#define QOF_MATH_128_H + +#include + +/** @addtogroup Math128 + * Quick-n-dirty 128-bit integer math lib. Things seem to mostly + * work, and have been tested, but not comprehensively tested. + * @{ + */ + +typedef struct { + guint64 hi; + guint64 lo; + short isneg; /**< sign-bit -- T if number is negative */ + short isbig; /**< sizeflag -- T if number won't fit in signed 64-bit */ +} qofint128; + +/** Multiply a pair of signed 64-bit numbers, + * returning a signed 128-bit number. + */ +inline qofint128 mult128 (gint64 a, gint64 b); + +/** Divide a signed 128-bit number by a signed 64-bit, + * returning a signed 128-bit number. + */ +inline qofint128 div128 (qofint128 n, gint64 d); + +/** Return the remainder of a signed 128-bit number modulo + * a signed 64-bit. That is, return n%d in 128-bit math. + * I beleive that ths algo is overflow-free, but should be + * audited some more ... + */ +inline gint64 rem128 (qofint128 n, gint64 d); + +/** Return the ratio n/d reduced so that there are no common factors. */ +inline gnc_numeric reduce128(qofint128 n, gint64 d); + +/** Return true of two numbers are equal */ +inline gboolean equal128 (qofint128 a, qofint128 b); + +/** Return the greatest common factor of two 64-bit numbers */ +inline guint64 gcf64(guint64 num, guint64 denom); + +/** Return the least common multiple of two 64-bit numbers. */ +inline qofint128 lcm128 (guint64 a, guint64 b); + +/** Add a pair of 128-bit numbers, returning a 128-bit number */ +inline qofint128 add128 (qofint128 a, qofint128 b); + +#endif + +/** @} */