-
+ 2FCC124504ADC576636A56BC387F7F6B73C60B263ED01A7DFFA2C2131F89AA6D337399EF9DB92C5423D25BA596A898AD1160AC1EAB5D49768AEAB14D08C29466
smg_comms/mpi/mpih-mul1.c
(0 . 0)(1 . 56)
7016 /* mpihelp-mul_1.c - MPI helper functions
7017 * Modified by No Such Labs. (C) 2015. See README.
7018 *
7019 * This file was originally part of Gnu Privacy Guard (GPG), ver. 1.4.10,
7020 * SHA256(gnupg-1.4.10.tar.gz):
7021 * 0bfd74660a2f6cedcf7d8256db4a63c996ffebbcdc2cf54397bfb72878c5a85a
7022 * (C) 1994-2005 Free Software Foundation, Inc.
7023 *
7024 * This program is free software: you can redistribute it and/or modify
7025 * it under the terms of the GNU General Public License as published by
7026 * the Free Software Foundation, either version 3 of the License, or
7027 * (at your option) any later version.
7028 *
7029 * This program is distributed in the hope that it will be useful,
7030 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7031 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7032 * GNU General Public License for more details.
7033 *
7034 * You should have received a copy of the GNU General Public License
7035 * along with this program. If not, see <http://www.gnu.org/licenses/>.
7036 */
7037
7038 #include <stdio.h>
7039 #include <stdlib.h>
7040
7041 #include "knobs.h"
7042 #include "mpi-internal.h"
7043 #include "longlong.h"
7044
7045 mpi_limb_t
7046 mpihelp_mul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
7047 mpi_limb_t s2_limb)
7048 {
7049 mpi_limb_t cy_limb;
7050 mpi_size_t j;
7051 mpi_limb_t prod_high, prod_low;
7052
7053 /* The loop counter and index J goes from -S1_SIZE to -1. This way
7054 * the loop becomes faster. */
7055 j = -s1_size;
7056
7057 /* Offset the base pointers to compensate for the negative indices. */
7058 s1_ptr -= j;
7059 res_ptr -= j;
7060
7061 cy_limb = 0;
7062 do {
7063 umul_ppmm( prod_high, prod_low, s1_ptr[j], s2_limb );
7064 prod_low += cy_limb;
7065 cy_limb = (prod_low < cy_limb?1:0) + prod_high;
7066 res_ptr[j] = prod_low;
7067 } while( ++j );
7068
7069 return cy_limb;
7070 }
7071