github.com/aergoio/aergo@v1.3.1/libtool/src/gmp-6.1.2/mpn/generic/sec_sqr.c (about)

     1  /* mpn_sec_sqr.
     2  
     3     Contributed to the GNU project by Torbjörn Granlund.
     4  
     5  Copyright 2013, 2014 Free Software Foundation, Inc.
     6  
     7  This file is part of the GNU MP Library.
     8  
     9  The GNU MP Library is free software; you can redistribute it and/or modify
    10  it under the terms of either:
    11  
    12    * the GNU Lesser General Public License as published by the Free
    13      Software Foundation; either version 3 of the License, or (at your
    14      option) any later version.
    15  
    16  or
    17  
    18    * the GNU General Public License as published by the Free Software
    19      Foundation; either version 2 of the License, or (at your option) any
    20      later version.
    21  
    22  or both in parallel, as here.
    23  
    24  The GNU MP Library is distributed in the hope that it will be useful, but
    25  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    26  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    27  for more details.
    28  
    29  You should have received copies of the GNU General Public License and the
    30  GNU Lesser General Public License along with the GNU MP Library.  If not,
    31  see https://www.gnu.org/licenses/.  */
    32  
    33  #include "gmp.h"
    34  #include "gmp-impl.h"
    35  
    36  #if ! HAVE_NATIVE_mpn_sqr_basecase
    37  /* The limit of the generic code is SQR_TOOM2_THRESHOLD.  */
    38  #define SQR_BASECASE_LIM  SQR_TOOM2_THRESHOLD
    39  #endif
    40  
    41  #if HAVE_NATIVE_mpn_sqr_basecase
    42  #ifdef TUNE_SQR_TOOM2_MAX
    43  /* We slightly abuse TUNE_SQR_TOOM2_MAX here.  If it is set for an assembly
    44     mpn_sqr_basecase, it comes from SQR_TOOM2_THRESHOLD_MAX in the assembly
    45     file.  An assembly mpn_sqr_basecase that does not define it should allow
    46     any size.  */
    47  #define SQR_BASECASE_LIM  SQR_TOOM2_THRESHOLD
    48  #endif
    49  #endif
    50  
    51  #ifdef WANT_FAT_BINARY
    52  /* For fat builds, we use SQR_TOOM2_THRESHOLD which will expand to a read from
    53     __gmpn_cpuvec.  Perhaps any possible sqr_basecase.asm allow any size, and we
    54     limit the use unnecessarily.  We cannot tell, so play it safe.  FIXME.  */
    55  #define SQR_BASECASE_LIM  SQR_TOOM2_THRESHOLD
    56  #endif
    57  
    58  void
    59  mpn_sec_sqr (mp_ptr rp,
    60  	     mp_srcptr ap, mp_size_t an,
    61  	     mp_ptr tp)
    62  {
    63  #ifndef SQR_BASECASE_LIM
    64  /* If SQR_BASECASE_LIM is now not defined, use mpn_sqr_basecase for any operand
    65     size.  */
    66    mpn_sqr_basecase (rp, ap, an);
    67  #else
    68  /* Else use mpn_sqr_basecase for its allowed sizes, else mpn_mul_basecase.  */
    69    mpn_mul_basecase (rp, ap, an, ap, an);
    70  #endif
    71  }
    72  
    73  mp_size_t
    74  mpn_sec_sqr_itch (mp_size_t an)
    75  {
    76    return 0;
    77  }