beta-0.89.2
[luatex.git] / source / libs / gmp / gmp-src / mpn / generic / sec_sqr.c
blob82073cb323d3c2f5ba29c633dbb6e7d68bd56169
1 /* mpn_sec_sqr.
3 Contributed to the GNU project by Torbjörn Granlund.
5 Copyright 2013, 2014 Free Software Foundation, Inc.
7 This file is part of the GNU MP Library.
9 The GNU MP Library is free software; you can redistribute it and/or modify
10 it under the terms of either:
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.
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.
22 or both in parallel, as here.
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.
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/. */
33 #include "gmp.h"
34 #include "gmp-impl.h"
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
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
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
58 void
59 mpn_sec_sqr (mp_ptr rp,
60 mp_srcptr ap, mp_size_t an,
61 mp_ptr tp)
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
73 mp_size_t
74 mpn_sec_sqr_itch (mp_size_t an)
76 return 0;