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-impl.h"
34 
35 #if ! HAVE_NATIVE_mpn_sqr_basecase
36 /* The limit of the generic code is SQR_TOOM2_THRESHOLD.  */
37 #define SQR_BASECASE_LIM  SQR_TOOM2_THRESHOLD
38 #endif
39 
40 #if HAVE_NATIVE_mpn_sqr_basecase
41 #ifdef TUNE_SQR_TOOM2_MAX
42 /* We slightly abuse TUNE_SQR_TOOM2_MAX here.  If it is set for an assembly
43    mpn_sqr_basecase, it comes from SQR_TOOM2_THRESHOLD_MAX in the assembly
44    file.  An assembly mpn_sqr_basecase that does not define it should allow
45    any size.  */
46 #define SQR_BASECASE_LIM  SQR_TOOM2_THRESHOLD
47 #endif
48 #endif
49 
50 #ifdef WANT_FAT_BINARY
51 /* For fat builds, we use SQR_TOOM2_THRESHOLD which will expand to a read from
52    __gmpn_cpuvec.  Perhaps any possible sqr_basecase.asm allow any size, and we
53    limit the use unnecessarily.  We cannot tell, so play it safe.  FIXME.  */
54 #define SQR_BASECASE_LIM  SQR_TOOM2_THRESHOLD
55 #endif
56 
57 void
mpn_sec_sqr(mp_ptr rp,mp_srcptr ap,mp_size_t an,mp_ptr tp)58 mpn_sec_sqr (mp_ptr rp,
59 	     mp_srcptr ap, mp_size_t an,
60 	     mp_ptr tp)
61 {
62 #ifndef SQR_BASECASE_LIM
63 /* If SQR_BASECASE_LIM is now not defined, use mpn_sqr_basecase for any operand
64    size.  */
65   mpn_sqr_basecase (rp, ap, an);
66 #else
67 /* Else use mpn_mul_basecase.  */
68   mpn_mul_basecase (rp, ap, an, ap, an);
69 #endif
70 }
71 
72 mp_size_t
mpn_sec_sqr_itch(mp_size_t an)73 mpn_sec_sqr_itch (mp_size_t an)
74 {
75   return 0;
76 }
77