-
+ 3B4CC6335137AE38D7A62B34E1D2319C33371D77B6169AB101B4DF8CE83EE7E10FF859F24626B13AE42AFF8CFFC805FFAA433D53FAF56C5924837AC1FAC0A6F9
smg_comms/mpi/mpih-mul2.c
(0 . 0)(1 . 61)
7076 /* mpihelp-mul_2.c - MPI helper functions
7077 * Modified by No Such Labs. (C) 2015. See README.
7078 *
7079 * This file was originally part of Gnu Privacy Guard (GPG), ver. 1.4.10,
7080 * SHA256(gnupg-1.4.10.tar.gz):
7081 * 0bfd74660a2f6cedcf7d8256db4a63c996ffebbcdc2cf54397bfb72878c5a85a
7082 * (C) 1994-2005 Free Software Foundation, Inc.
7083 *
7084 * This program is free software: you can redistribute it and/or modify
7085 * it under the terms of the GNU General Public License as published by
7086 * the Free Software Foundation, either version 3 of the License, or
7087 * (at your option) any later version.
7088 *
7089 * This program is distributed in the hope that it will be useful,
7090 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7091 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7092 * GNU General Public License for more details.
7093 *
7094 * You should have received a copy of the GNU General Public License
7095 * along with this program. If not, see <http://www.gnu.org/licenses/>.
7096 */
7097
7098 #include <stdio.h>
7099 #include <stdlib.h>
7100
7101 #include "knobs.h"
7102 #include "mpi-internal.h"
7103 #include "longlong.h"
7104
7105
7106 mpi_limb_t
7107 mpihelp_addmul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
7108 mpi_size_t s1_size, mpi_limb_t s2_limb)
7109 {
7110 mpi_limb_t cy_limb;
7111 mpi_size_t j;
7112 mpi_limb_t prod_high, prod_low;
7113 mpi_limb_t x;
7114
7115 /* The loop counter and index J goes from -SIZE to -1. This way
7116 * the loop becomes faster. */
7117 j = -s1_size;
7118 res_ptr -= j;
7119 s1_ptr -= j;
7120
7121 cy_limb = 0;
7122 do {
7123 umul_ppmm( prod_high, prod_low, s1_ptr[j], s2_limb );
7124
7125 prod_low += cy_limb;
7126 cy_limb = (prod_low < cy_limb?1:0) + prod_high;
7127
7128 x = res_ptr[j];
7129 prod_low = x + prod_low;
7130 cy_limb += prod_low < x?1:0;
7131 res_ptr[j] = prod_low;
7132 } while ( ++j );
7133 return cy_limb;
7134 }
7135
7136