3 * $Id: mpx-kmac.h,v 1.1 2000/06/17 11:42:11 mdw Exp $
5 * Macros for Karatsuba functions
7 * (c) 2000 Straylight/Edgeware
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of Catacomb.
14 * Catacomb is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Library General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
19 * Catacomb is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Library General Public License for more details.
24 * You should have received a copy of the GNU Library General Public
25 * License along with Catacomb; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
30 /*----- Revision history --------------------------------------------------*
32 * $Log: mpx-kmac.h,v $
33 * Revision 1.1 2000/06/17 11:42:11 mdw
34 * Moved the Karatsuba macros into a separate file for better sharing.
35 * Fixed some comments.
39 #ifndef CATACOMB_MPX_KMAC_H
40 #define CATACOMB_MPX_KMAC_H
46 /*----- Header files ------------------------------------------------------*/
48 #ifndef CATACOMB_MPW_H
52 /*----- Macros provided ---------------------------------------------------*/
54 #define UADD(dv, av, avl) do { \
56 const mpw *_av = (av), *_avl = (avl); \
59 while (_av < _avl) { \
64 _x = (mpd)_a + (mpd)_b + _c; \
66 _c = _x >> MPW_BITS; \
69 mpd _x = (mpd)*_dv + (mpd)_c; \
71 _c = _x >> MPW_BITS; \
75 #define UADD2(dv, dvl, av, avl, bv, bvl) do { \
76 mpw *_dv = (dv), *_dvl = (dvl); \
77 const mpw *_av = (av), *_avl = (avl); \
78 const mpw *_bv = (bv), *_bvl = (bvl); \
81 while (_av < _avl || _bv < _bvl) { \
84 _a = (_av < _avl) ? *_av++ : 0; \
85 _b = (_bv < _bvl) ? *_bv++ : 0; \
86 _x = (mpd)_a + (mpd)_b + _c; \
88 _c = _x >> MPW_BITS; \
95 #define USUB(dv, av, avl) do { \
97 const mpw *_av = (av), *_avl = (avl); \
100 while (_av < _avl) { \
105 _x = (mpd)_b - (mpd)_a - _c; \
107 if (_x >> MPW_BITS) \
113 mpd _x = (mpd)*_dv - (mpd)_c; \
115 if (_x >> MPW_BITS) \
122 /*----- That's all, folks -------------------------------------------------*/