-
Notifications
You must be signed in to change notification settings - Fork 0
/
gmp-impl.h
4174 lines (3493 loc) · 157 KB
/
gmp-impl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Include file for internal GNU MP types and definitions.
THE CONTENTS OF THIS FILE ARE FOR INTERNAL USE AND ARE ALMOST CERTAIN TO
BE SUBJECT TO INCOMPATIBLE CHANGES IN FUTURE GNU MP RELEASES.
Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003,
2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
Copyright 2009 William Hart
This file is part of the GNU MP Library.
The GNU MP Library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
The GNU MP Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
/* __GMP_DECLSPEC must be given on any global data that will be accessed
from outside libmpir, meaning from the test or development programs, or
from libmpirxx. Failing to do this will result in an incorrect address
being used for the accesses. On functions __GMP_DECLSPEC makes calls
from outside libmpir more efficient, but they'll still work fine without
it. */
#ifndef __GMP_IMPL_H__
#define __GMP_IMPL_H__
/* limits.h is not used in general, since it's an ANSI-ism, and since on
solaris gcc 2.95 under -mcpu=ultrasparc in ABI=32 ends up getting wrong
values (the ABI=64 values).
On Cray vector systems, however, we need the system limits.h since sizes
of signed and unsigned types can differ there, depending on compiler
options (eg. -hnofastmd), making our SHRT_MAX etc expressions fail. For
reference, int can be 46 or 64 bits, whereas uint is always 64 bits; and
short can be 24, 32, 46 or 64 bits, and different for ushort. */
#if defined _WIN64
#include <limits.h>
#endif
/* For fat.h and other fat binary stuff.
No need for __GMP_ATTRIBUTE_PURE or __GMP_NOTHROW, since functions
declared this way are only used to set function pointers in __gmp_cpuvec,
they're not called directly. */
#define DECL_add_n(name) \
mp_limb_t name __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t))
#define DECL_addmul_1(name) \
mp_limb_t name __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t))
#define DECL_copyd(name) \
void name __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t))
#define DECL_copyi(name) \
void name __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t))
#define DECL_divexact_1(name) \
void name __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t))
#define DECL_divexact_by3c(name) \
mp_limb_t name __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t))
#define DECL_divexact_byfobm1(name) \
mp_limb_t name __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t,mp_limb_t))
#define DECL_divrem_1(name) \
mp_limb_t name __GMP_PROTO ((mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t))
#define DECL_divrem_2(name) \
mp_limb_t name __GMP_PROTO ((mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr))
#define DECL_divrem_euclidean_qr_1(name) \
mp_limb_t name __GMP_PROTO ((mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t))
#define DECL_divrem_euclidean_qr_2(name) \
mp_limb_t name __GMP_PROTO ((mp_ptr, mp_ptr, mp_size_t, mp_srcptr))
#define DECL_gcd_1(name) \
mp_limb_t name __GMP_PROTO ((mp_srcptr, mp_size_t, mp_limb_t))
#define DECL_lshift(name) \
mp_limb_t name __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, unsigned))
#define DECL_mod_1(name) \
mp_limb_t name __GMP_PROTO ((mp_srcptr, mp_size_t, mp_limb_t))
#define DECL_mod_34lsub1(name) \
mp_limb_t name __GMP_PROTO ((mp_srcptr, mp_size_t))
#define DECL_modexact_1c_odd(name) \
mp_limb_t name __GMP_PROTO ((mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t))
#define DECL_mul_1(name) \
DECL_addmul_1 (name)
#define DECL_mul_basecase(name) \
void name __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t))
#define DECL_preinv_divrem_1(name) \
mp_limb_t name __GMP_PROTO ((mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t, int))
#define DECL_preinv_mod_1(name) \
mp_limb_t name __GMP_PROTO ((mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t))
#define DECL_redc_1(name) \
void name __GMP_PROTO ((mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_limb_t))
#define DECL_rshift(name) \
DECL_lshift (name)
#define DECL_sqr_basecase(name) \
void name __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t))
#define DECL_sub_n(name) \
DECL_add_n (name)
#define DECL_submul_1(name) \
DECL_addmul_1 (name)
#define DECL_sumdiff_n(name) \
mp_limb_t name __GMP_PROTO ((mp_ptr, mp_ptr, mp_srcptr,mp_srcptr,mp_size_t))
#if ! __GMP_WITHIN_CONFIGURE
#include "config.h"
#include "gmp-mparam.h"
/* These constants are generated by gen-fib.c header limbbits nailbits */
#if GMP_NUMB_BITS == 32
#define FIB_TABLE_LIMIT 47
#define FIB_TABLE_LUCNUM_LIMIT 46
#endif /* 32 bits */
#if GMP_NUMB_BITS == 64
#define FIB_TABLE_LIMIT 93
#define FIB_TABLE_LUCNUM_LIMIT 92
#endif /* 64 bits */
/* This constants are generated by gen-bases.c header limbbits nailbits */
#if GMP_NUMB_BITS == 32
#define MP_BASES_CHARS_PER_LIMB_10 9
#define MP_BASES_BIG_BASE_10 CNST_LIMB(0x3b9aca00)
#define MP_BASES_BIG_BASE_INVERTED_10 CNST_LIMB(0x12e0be82)
#define MP_BASES_NORMALIZATION_STEPS_10 2
#endif /* 32 bits */
#if GMP_NUMB_BITS == 64
#define MP_BASES_CHARS_PER_LIMB_10 19
#define MP_BASES_BIG_BASE_10 CNST_LIMB(0x8ac7230489e80000)
#define MP_BASES_BIG_BASE_INVERTED_10 CNST_LIMB(0xd83c94fb6d2ac34a)
#define MP_BASES_NORMALIZATION_STEPS_10 0
#endif /* 64 bits */
#if defined _LONG_LONG_LIMB
#if __GMP_HAVE_TOKEN_PASTE
#define CNST_LIMB(C) ((mp_limb_t) C##LL)
#else
#define CNST_LIMB(C) ((mp_limb_t) C/**/LL)
#endif
#else /* not _LONG_LONG_LIMB */
#if __GMP_HAVE_TOKEN_PASTE
#define CNST_LIMB(C) ((mp_limb_t) C##L)
#else
#define CNST_LIMB(C) ((mp_limb_t) C/**/L)
#endif
#endif /* _LONG_LONG_LIMB */
/* This constants and defines are generated by gen-psqr limbbits nailbits */
#if GMP_LIMB_BITS == 32 && GMP_NAIL_BITS == 0
/* Non-zero bit indicates a quadratic residue mod 0x100.
This test identifies 82.81% as non-squares (212/256). */
static const mp_limb_t
sq_res_0x100[8] = {
CNST_LIMB(0x2030213),
CNST_LIMB(0x2020212),
CNST_LIMB(0x2020213),
CNST_LIMB(0x2020212),
CNST_LIMB(0x2030212),
CNST_LIMB(0x2020212),
CNST_LIMB(0x2020212),
CNST_LIMB(0x2020212),
};
/* 2^24-1 = 3^2 * 5 * 7 * 13 * 17 ... */
#define PERFSQR_MOD_BITS 25
/* This test identifies 95.66% as non-squares. */
#define PERFSQR_MOD_TEST(up, usize) \
do { \
mp_limb_t r; \
PERFSQR_MOD_34 (r, up, usize); \
\
/* 73.33% */ \
PERFSQR_MOD_2 (r, CNST_LIMB(45), CNST_LIMB(0xfa4fa5), \
CNST_LIMB(0x920), CNST_LIMB(0x1a442481)); \
\
/* 47.06% */ \
PERFSQR_MOD_1 (r, CNST_LIMB(17), CNST_LIMB(0xf0f0f1), \
CNST_LIMB(0x1a317)); \
\
/* 46.15% */ \
PERFSQR_MOD_1 (r, CNST_LIMB(13), CNST_LIMB(0xec4ec5), \
CNST_LIMB(0x9e5)); \
\
/* 42.86% */ \
PERFSQR_MOD_1 (r, CNST_LIMB( 7), CNST_LIMB(0xdb6db7), \
CNST_LIMB(0x69)); \
} while (0)
/* Grand total sq_res_0x100 and PERFSQR_MOD_TEST, 99.25% non-squares. */
/* helper for tests/mpz/t-perfsqr.c */
#define PERFSQR_DIVISORS { 256, 45, 17, 13, 7, }
#elif GMP_LIMB_BITS == 64 && GMP_NAIL_BITS == 0
/* Non-zero bit indicates a quadratic residue mod 0x100.
This test identifies 82.81% as non-squares (212/256). */
static const mp_limb_t
sq_res_0x100[4] = {
CNST_LIMB(0x202021202030213),
CNST_LIMB(0x202021202020213),
CNST_LIMB(0x202021202030212),
CNST_LIMB(0x202021202020212),
};
/* 2^48-1 = 3^2 * 5 * 7 * 13 * 17 * 97 ... */
#define PERFSQR_MOD_BITS 49
/* This test identifies 97.81% as non-squares. */
#define PERFSQR_MOD_TEST(up, usize) \
do { \
mp_limb_t r; \
PERFSQR_MOD_34 (r, up, usize); \
\
/* 69.23% */ \
PERFSQR_MOD_2 (r, CNST_LIMB(91), CNST_LIMB(0xfd2fd2fd2fd3), \
CNST_LIMB(0x2191240), CNST_LIMB(0x8850a206953820e1)); \
\
/* 68.24% */ \
PERFSQR_MOD_2 (r, CNST_LIMB(85), CNST_LIMB(0xfcfcfcfcfcfd), \
CNST_LIMB(0x82158), CNST_LIMB(0x10b48c4b4206a105)); \
\
/* 55.56% */ \
PERFSQR_MOD_1 (r, CNST_LIMB( 9), CNST_LIMB(0xe38e38e38e39), \
CNST_LIMB(0x93)); \
\
/* 49.48% */ \
PERFSQR_MOD_2 (r, CNST_LIMB(97), CNST_LIMB(0xfd5c5f02a3a1), \
CNST_LIMB(0x1eb628b47), CNST_LIMB(0x6067981b8b451b5f)); \
} while (0)
/* Grand total sq_res_0x100 and PERFSQR_MOD_TEST, 99.62% non-squares. */
/* helper for tests/mpz/t-perfsqr.c */
#define PERFSQR_DIVISORS { 256, 91, 85, 9, 97, }
#else
#error no data available for this limb size in perfsqr.h
#endif
#if WANT_FAT_BINARY
#include "fat.h"
#endif
#endif
#if HAVE_INTTYPES_H /* for uint_least32_t */
# include <inttypes.h>
#else
# ifdef HAVE_STDINT_H
# include <stdint.h>
# endif
#endif
#ifdef __cplusplus
#include <cstring> /* for strlen */
#include <string> /* for std::string */
#endif
#ifndef WANT_TMP_DEBUG /* for TMP_ALLOC_LIMBS_2 and others */
#define WANT_TMP_DEBUG 0
#endif
/* Might search and replace _PROTO to __GMP_PROTO internally one day, to
avoid two names for one thing, but no hurry for that. */
#define _PROTO(x) __GMP_PROTO(x)
/* The following tries to get a good version of alloca. The tests are
adapted from autoconf AC_FUNC_ALLOCA, with a couple of additions.
Whether this succeeds is tested by GMP_FUNC_ALLOCA and HAVE_ALLOCA will
be setup appropriately.
ifndef alloca - a cpp define might already exist.
glibc <stdlib.h> includes <alloca.h> which uses GCC __builtin_alloca.
HP cc +Olibcalls adds a #define of alloca to __builtin_alloca.
GCC __builtin_alloca - preferred whenever available.
_AIX pragma - IBM compilers need a #pragma in "each module that needs to
use alloca". Pragma indented to protect pre-ANSI cpp's. _IBMR2 was
used in past versions of GMP, retained still in case it matters.
The autoconf manual says this pragma needs to be at the start of a C
file, apart from comments and preprocessor directives. Is that true?
xlc on aix 4.xxx doesn't seem to mind it being after prototypes etc
from mpir.h.
*/
#ifndef alloca
# ifdef __GNUC__
# define alloca __builtin_alloca
# else
# ifdef __DECC
# define alloca(x) __ALLOCA(x)
# else
# ifdef _MSC_VER
# include <malloc.h>
# define alloca _alloca
# else
# if HAVE_ALLOCA_H
# include <alloca.h>
# else
# if defined (_AIX) || defined (_IBMR2)
#pragma alloca
# else
char *alloca ();
# endif
# endif
# endif
# endif
# endif
#endif
/* if not provided by gmp-mparam.h */
#ifndef BYTES_PER_MP_LIMB
#define BYTES_PER_MP_LIMB SIZEOF_MP_LIMB_T
#endif
#ifndef BITS_PER_MP_LIMB
#define BITS_PER_MP_LIMB (8 * SIZEOF_MP_LIMB_T)
#endif
#define BITS_PER_ULONG (8 * SIZEOF_UNSIGNED_LONG)
#ifdef HAVE_STDINT_H
#define BITS_PER_UINTMAX (8 * SIZEOF_UINTMAX_T)
#endif
/* gmp_uint_least32_t is an unsigned integer type with at least 32 bits. */
#if HAVE_UINT_LEAST32_T
typedef uint_least32_t gmp_uint_least32_t;
#else
#if SIZEOF_UNSIGNED_SHORT >= 4
typedef unsigned short gmp_uint_least32_t;
#else
#if SIZEOF_UNSIGNED >= 4
typedef unsigned gmp_uint_least32_t;
#else
typedef unsigned long gmp_uint_least32_t;
#endif
#endif
#endif
/* const and signed must match __gmp_const and __gmp_signed, so follow the
decision made for those in mpir.h. */
#if ! __GMP_HAVE_CONST
#define const /* empty */
#define signed /* empty */
#endif
/* "const" basically means a function does nothing but examine its arguments
and give a return value, it doesn't read or write any memory (neither
global nor pointed to by arguments), and has no other side-effects. This
is more restrictive than "pure". See info node "(gcc)Function
Attributes". __GMP_NO_ATTRIBUTE_CONST_PURE lets tune/common.c etc turn
this off when trying to write timing loops. */
#if HAVE_ATTRIBUTE_CONST && ! defined (__GMP_NO_ATTRIBUTE_CONST_PURE) && !( defined (__cplusplus) && defined (__sun))
#define ATTRIBUTE_CONST __attribute__ ((const))
#else
#define ATTRIBUTE_CONST
#endif
#if HAVE_ATTRIBUTE_NORETURN && !( defined (__cplusplus) && defined (__sun))
#define ATTRIBUTE_NORETURN __attribute__ ((noreturn))
#else
#define ATTRIBUTE_NORETURN
#endif
/* "malloc" means a function behaves like malloc in that the pointer it
returns doesn't alias anything. */
#if HAVE_ATTRIBUTE_MALLOC && !( defined (__cplusplus) && defined (__sun))
#define ATTRIBUTE_MALLOC __attribute__ ((malloc))
#else
#define ATTRIBUTE_MALLOC
#endif
#if ! HAVE_STRCHR
#define strchr(s,c) index(s,c)
#endif
#if ! HAVE_MEMSET
#define memset(p, c, n) \
do { \
ASSERT ((n) >= 0); \
char *__memset__p = (p); \
int __i; \
for (__i = 0; __i < (n); __i++) \
__memset__p[__i] = (c); \
} while (0)
#endif
/* va_copy is standard in C99, and gcc provides __va_copy when in strict C89
mode. Falling back to a memcpy will give maximum portability, since it
works no matter whether va_list is a pointer, struct or array. */
#if ! defined (va_copy) && defined (__va_copy)
#define va_copy(dst,src) __va_copy(dst,src)
#endif
#if ! defined (va_copy)
#define va_copy(dst,src) \
do { memcpy (&(dst), &(src), sizeof (va_list)); } while (0)
#endif
#if defined (__cplusplus)
extern "C" {
#endif
/* Usage: TMP_DECL;
TMP_MARK;
ptr = TMP_ALLOC (bytes);
TMP_FREE;
Small allocations should use TMP_SALLOC, big allocations should use
TMP_BALLOC. Allocations that might be small or big should use TMP_ALLOC.
Functions that use just TMP_SALLOC should use TMP_SDECL, TMP_SMARK, and
TMP_SFREE.
TMP_DECL just declares a variable, but might be empty and so must be last
in a list of variables. TMP_MARK must be done before any TMP_ALLOC.
TMP_ALLOC(0) is not allowed. TMP_FREE doesn't need to be done if a
TMP_MARK was made, but then no TMP_ALLOCs. */
/* The alignment in bytes, used for TMP_ALLOCed blocks, when alloca or
__gmp_allocate_func doesn't already determine it. Currently TMP_ALLOC
isn't used for "double"s, so that's not in the union. */
union tmp_align_t {
mp_limb_t l;
char *p;
};
#define __TMP_ALIGN sizeof (union tmp_align_t)
/* Return "a" rounded upwards to a multiple of "m", if it isn't already.
"a" must be an unsigned type.
This is designed for use with a compile-time constant "m".
The POW2 case is expected to be usual, and gcc 3.0 and up recognises
"(-(8*n))%8" or the like is always zero, which means the rounding up in
the WANT_TMP_NOTREENTRANT version of TMP_ALLOC below will be a noop. */
#define ROUND_UP_MULTIPLE(a,m) \
(POW2_P(m) ? (a) + (-(a))%(m) \
: (a)+(m)-1 - (((a)+(m)-1) % (m)))
#if defined (WANT_TMP_ALLOCA) || defined (WANT_TMP_REENTRANT)
struct tmp_reentrant_t {
struct tmp_reentrant_t *next;
size_t size; /* bytes, including header */
};
__GMP_DECLSPEC void *__gmp_tmp_reentrant_alloc _PROTO ((struct tmp_reentrant_t **, size_t)) ATTRIBUTE_MALLOC;
__GMP_DECLSPEC void __gmp_tmp_reentrant_free _PROTO ((struct tmp_reentrant_t *));
#endif
#if WANT_TMP_ALLOCA
#define TMP_SDECL
#define TMP_DECL struct tmp_reentrant_t *__tmp_marker
#define TMP_SMARK
#define TMP_MARK __tmp_marker = 0
#define TMP_SALLOC(n) alloca(n)
#define TMP_BALLOC(n) __gmp_tmp_reentrant_alloc (&__tmp_marker, n)
#define TMP_ALLOC(n) \
(LIKELY ((n) < 65536) ? TMP_SALLOC(n) : TMP_BALLOC(n))
#define TMP_SFREE
#define TMP_FREE \
do { \
if (UNLIKELY (__tmp_marker != 0)) __gmp_tmp_reentrant_free (__tmp_marker); \
} while (0)
#endif
#if WANT_TMP_REENTRANT
#define TMP_SDECL TMP_DECL
#define TMP_DECL struct tmp_reentrant_t *__tmp_marker
#define TMP_SMARK TMP_MARK
#define TMP_MARK __tmp_marker = 0
#define TMP_SALLOC(n) TMP_ALLOC(n)
#define TMP_BALLOC(n) TMP_ALLOC(n)
#define TMP_ALLOC(n) __gmp_tmp_reentrant_alloc (&__tmp_marker, n)
#define TMP_SFREE TMP_FREE
#define TMP_FREE __gmp_tmp_reentrant_free (__tmp_marker)
#endif
#if WANT_TMP_NOTREENTRANT
struct tmp_marker
{
struct tmp_stack *which_chunk;
void *alloc_point;
};
void *__gmp_tmp_alloc _PROTO ((unsigned long)) ATTRIBUTE_MALLOC;
void __gmp_tmp_mark _PROTO ((struct tmp_marker *));
void __gmp_tmp_free _PROTO ((struct tmp_marker *));
#define TMP_SDECL TMP_DECL
#define TMP_DECL struct tmp_marker __tmp_marker
#define TMP_SMARK TMP_MARK
#define TMP_MARK __gmp_tmp_mark (&__tmp_marker)
#define TMP_SALLOC(n) TMP_ALLOC(n)
#define TMP_BALLOC(n) TMP_ALLOC(n)
#define TMP_ALLOC(n) \
__gmp_tmp_alloc (ROUND_UP_MULTIPLE ((unsigned long) (n), __TMP_ALIGN))
#define TMP_SFREE TMP_FREE
#define TMP_FREE __gmp_tmp_free (&__tmp_marker)
#endif
#if WANT_TMP_DEBUG
/* See tal-debug.c for some comments. */
struct tmp_debug_t {
struct tmp_debug_entry_t *list;
const char *file;
int line;
};
struct tmp_debug_entry_t {
struct tmp_debug_entry_t *next;
char *block;
size_t size;
};
void __gmp_tmp_debug_mark _PROTO ((const char *, int, struct tmp_debug_t **,
struct tmp_debug_t *,
const char *, const char *));
void *__gmp_tmp_debug_alloc _PROTO ((const char *, int, int,
struct tmp_debug_t **, const char *,
size_t)) ATTRIBUTE_MALLOC;
void __gmp_tmp_debug_free _PROTO ((const char *, int, int,
struct tmp_debug_t **,
const char *, const char *));
#define TMP_SDECL TMP_DECL_NAME(__tmp_xmarker, "__tmp_marker")
#define TMP_DECL TMP_DECL_NAME(__tmp_xmarker, "__tmp_marker")
#define TMP_SMARK TMP_MARK_NAME(__tmp_xmarker, "__tmp_marker")
#define TMP_MARK TMP_MARK_NAME(__tmp_xmarker, "__tmp_marker")
#define TMP_SFREE TMP_FREE_NAME(__tmp_xmarker, "__tmp_marker")
#define TMP_FREE TMP_FREE_NAME(__tmp_xmarker, "__tmp_marker")
/* The marker variable is designed to provoke an uninitialized varialble
warning from the compiler if TMP_FREE is used without a TMP_MARK.
__tmp_marker_inscope does the same for TMP_ALLOC. Runtime tests pick
these things up too. */
#define TMP_DECL_NAME(marker, marker_name) \
int marker; \
int __tmp_marker_inscope; \
const char *__tmp_marker_name = marker_name; \
struct tmp_debug_t __tmp_marker_struct; \
/* don't demand NULL, just cast a zero */ \
struct tmp_debug_t *__tmp_marker = (struct tmp_debug_t *) 0
#define TMP_MARK_NAME(marker, marker_name) \
do { \
marker = 1; \
__tmp_marker_inscope = 1; \
__gmp_tmp_debug_mark (ASSERT_FILE, ASSERT_LINE, \
&__tmp_marker, &__tmp_marker_struct, \
__tmp_marker_name, marker_name); \
} while (0)
#define TMP_SALLOC(n) TMP_ALLOC(n)
#define TMP_BALLOC(n) TMP_ALLOC(n)
#define TMP_ALLOC(size) \
__gmp_tmp_debug_alloc (ASSERT_FILE, ASSERT_LINE, \
__tmp_marker_inscope, \
&__tmp_marker, __tmp_marker_name, size)
#define TMP_FREE_NAME(marker, marker_name) \
do { \
__gmp_tmp_debug_free (ASSERT_FILE, ASSERT_LINE, \
marker, &__tmp_marker, \
__tmp_marker_name, marker_name); \
} while (0)
#endif /* WANT_TMP_DEBUG */
/* Allocating various types. */
#define TMP_ALLOC_TYPE(n,type) ((type *) TMP_ALLOC ((n) * sizeof (type)))
#define TMP_SALLOC_TYPE(n,type) ((type *) TMP_SALLOC ((n) * sizeof (type)))
#define TMP_BALLOC_TYPE(n,type) ((type *) TMP_BALLOC ((n) * sizeof (type)))
#define TMP_ALLOC_LIMBS(n) TMP_ALLOC_TYPE(n,mp_limb_t)
#define TMP_SALLOC_LIMBS(n) TMP_SALLOC_TYPE(n,mp_limb_t)
#define TMP_BALLOC_LIMBS(n) TMP_BALLOC_TYPE(n,mp_limb_t)
#define TMP_ALLOC_MP_PTRS(n) TMP_ALLOC_TYPE(n,mp_ptr)
#define TMP_SALLOC_MP_PTRS(n) TMP_SALLOC_TYPE(n,mp_ptr)
#define TMP_BALLOC_MP_PTRS(n) TMP_BALLOC_TYPE(n,mp_ptr)
/* It's more efficient to allocate one block than two. This is certainly
true of the malloc methods, but it can even be true of alloca if that
involves copying a chunk of stack (various RISCs), or a call to a stack
bounds check (mingw). In any case, when debugging keep separate blocks
so a redzoning malloc debugger can protect each individually. */
#define TMP_ALLOC_LIMBS_2(xp,xsize, yp,ysize) \
do { \
if (WANT_TMP_DEBUG) \
{ \
(xp) = TMP_ALLOC_LIMBS (xsize); \
(yp) = TMP_ALLOC_LIMBS (ysize); \
} \
else \
{ \
(xp) = TMP_ALLOC_LIMBS ((xsize) + (ysize)); \
(yp) = (xp) + (xsize); \
} \
} while (0)
/* From mpir.h, nicer names for internal use. */
#define MPN_CMP(result, xp, yp, size) __GMPN_CMP(result, xp, yp, size)
#define LIKELY(cond) __GMP_LIKELY(cond)
#define UNLIKELY(cond) __GMP_UNLIKELY(cond)
#define ABS(x) ((x) >= 0 ? (x) : -(x))
#undef MIN
#define MIN(l,o) ((l) < (o) ? (l) : (o))
#undef MAX
#define MAX(h,i) ((h) > (i) ? (h) : (i))
#define numberof(x) (sizeof (x) / sizeof ((x)[0]))
/* Field access macros. */
#define SIZ(x) ((x)->_mp_size)
#define ABSIZ(x) ABS (SIZ (x))
#define PTR(x) ((x)->_mp_d)
#define LIMBS(x) ((x)->_mp_d)
#define EXP(x) ((x)->_mp_exp)
#define PREC(x) ((x)->_mp_prec)
#define ALLOC(x) ((x)->_mp_alloc)
/* n-1 inverts any low zeros and the lowest one bit. If n&(n-1) leaves zero
then that lowest one bit must have been the only bit set. n==0 will
return true though, so avoid that. */
#define POW2_P(n) (((n) & ((n) - 1)) == 0)
/* The "short" defines are a bit different because shorts are promoted to
ints by ~ or >> etc.
#ifndef's are used since on some systems (HP?) header files other than
limits.h setup these defines. We could forcibly #undef in that case, but
there seems no need to worry about that. */
#ifndef ULONG_MAX
#define ULONG_MAX __GMP_ULONG_MAX
#endif
#ifndef UINT_MAX
#define UINT_MAX __GMP_UINT_MAX
#endif
#ifndef USHRT_MAX
#define USHRT_MAX __GMP_USHRT_MAX
#endif
#define MP_LIMB_T_MAX (~ (mp_limb_t) 0)
/* Must cast ULONG_MAX etc to unsigned long etc, since they might not be
unsigned on a K&R compiler. In particular the HP-UX 10 bundled K&R cc
treats the plain decimal values in <limits.h> as signed. */
#define ULONG_HIGHBIT (ULONG_MAX ^ ((unsigned long) ULONG_MAX >> 1))
#define UINT_HIGHBIT (UINT_MAX ^ ((unsigned) UINT_MAX >> 1))
#define USHRT_HIGHBIT ((unsigned short) (USHRT_MAX ^ ((unsigned short) USHRT_MAX >> 1)))
#define GMP_LIMB_HIGHBIT (MP_LIMB_T_MAX ^ (MP_LIMB_T_MAX >> 1))
#ifdef HAVE_STDINT_H
#define UINTMAX_HIGHBIT (UINTMAX_MAX ^ (UINTMAX_MAX >> 1))
#endif
#ifndef LONG_MIN
#define LONG_MIN ((long) ULONG_HIGHBIT)
#endif
#ifndef LONG_MAX
#define LONG_MAX (-(LONG_MIN+1))
#endif
#ifndef INT_MIN
#define INT_MIN ((int) UINT_HIGHBIT)
#endif
#ifndef INT_MAX
#define INT_MAX (-(INT_MIN+1))
#endif
#ifndef SHRT_MIN
#define SHRT_MIN ((short) USHRT_HIGHBIT)
#endif
#ifndef SHRT_MAX
#define SHRT_MAX ((short) (-(SHRT_MIN+1)))
#endif
#if defined( _WIN64 )
#define MP_SIZE_T_MAX _I64_MAX
#define MP_SIZE_T_MIN _I64_MIN
#elif __GMP_MP_SIZE_T_INT
#define MP_SIZE_T_MAX INT_MAX
#define MP_SIZE_T_MIN INT_MIN
#else
#define MP_SIZE_T_MAX LONG_MAX
#define MP_SIZE_T_MIN LONG_MIN
#endif
/* mp_exp_t is the same as mp_size_t */
#if defined( _WIN64 )
#define MP_EXP_T_MAX LONG_MAX
#define MP_EXP_T_MIN LONG_MIN
#else
#define MP_EXP_T_MAX MP_SIZE_T_MAX
#define MP_EXP_T_MIN MP_SIZE_T_MIN
#endif
#define LONG_HIGHBIT LONG_MIN
#define INT_HIGHBIT INT_MIN
#define SHRT_HIGHBIT SHRT_MIN
#define GMP_NUMB_HIGHBIT (CNST_LIMB(1) << (GMP_NUMB_BITS-1))
#if GMP_NAIL_BITS == 0
#define GMP_NAIL_LOWBIT CNST_LIMB(0)
#else
#define GMP_NAIL_LOWBIT (CNST_LIMB(1) << GMP_NUMB_BITS)
#endif
/* Swap macros. */
#define MP_LIMB_T_SWAP(x, y) \
do { \
mp_limb_t __mp_limb_t_swap__tmp = (x); \
(x) = (y); \
(y) = __mp_limb_t_swap__tmp; \
} while (0)
#define MP_SIZE_T_SWAP(x, y) \
do { \
mp_size_t __mp_size_t_swap__tmp = (x); \
(x) = (y); \
(y) = __mp_size_t_swap__tmp; \
} while (0)
#define MP_PTR_SWAP(x, y) \
do { \
mp_ptr __mp_ptr_swap__tmp = (x); \
(x) = (y); \
(y) = __mp_ptr_swap__tmp; \
} while (0)
#define MP_SRCPTR_SWAP(x, y) \
do { \
mp_srcptr __mp_srcptr_swap__tmp = (x); \
(x) = (y); \
(y) = __mp_srcptr_swap__tmp; \
} while (0)
#define MPN_PTR_SWAP(xp,xs, yp,ys) \
do { \
MP_PTR_SWAP (xp, yp); \
MP_SIZE_T_SWAP (xs, ys); \
} while(0)
#define MPN_SRCPTR_SWAP(xp,xs, yp,ys) \
do { \
MP_SRCPTR_SWAP (xp, yp); \
MP_SIZE_T_SWAP (xs, ys); \
} while(0)
#define MPZ_PTR_SWAP(x, y) \
do { \
mpz_ptr __mpz_ptr_swap__tmp = (x); \
(x) = (y); \
(y) = __mpz_ptr_swap__tmp; \
} while (0)
#define MPZ_SRCPTR_SWAP(x, y) \
do { \
mpz_srcptr __mpz_srcptr_swap__tmp = (x); \
(x) = (y); \
(y) = __mpz_srcptr_swap__tmp; \
} while (0)
/* Enhancement: __gmp_allocate_func could have "__attribute__ ((malloc))",
but current gcc (3.0) doesn't seem to support that. */
__GMP_DECLSPEC extern void * (*__gmp_allocate_func) __GMP_PROTO ((size_t));
__GMP_DECLSPEC extern void * (*__gmp_reallocate_func) __GMP_PROTO ((void *, size_t, size_t));
__GMP_DECLSPEC extern void (*__gmp_free_func) __GMP_PROTO ((void *, size_t));
__GMP_DECLSPEC void *__gmp_default_allocate _PROTO ((size_t));
__GMP_DECLSPEC void *__gmp_default_reallocate _PROTO ((void *, size_t, size_t));
__GMP_DECLSPEC void __gmp_default_free _PROTO ((void *, size_t));
#define __GMP_ALLOCATE_FUNC_TYPE(n,type) \
((type *) (*__gmp_allocate_func) ((n) * sizeof (type)))
#define __GMP_ALLOCATE_FUNC_LIMBS(n) __GMP_ALLOCATE_FUNC_TYPE (n, mp_limb_t)
#define __GMP_REALLOCATE_FUNC_TYPE(p, old_size, new_size, type) \
((type *) (*__gmp_reallocate_func) \
(p, (old_size) * sizeof (type), (new_size) * sizeof (type)))
#define __GMP_REALLOCATE_FUNC_LIMBS(p, old_size, new_size) \
__GMP_REALLOCATE_FUNC_TYPE(p, old_size, new_size, mp_limb_t)
#define __GMP_FREE_FUNC_TYPE(p,n,type) (*__gmp_free_func) (p, (n) * sizeof (type))
#define __GMP_FREE_FUNC_LIMBS(p,n) __GMP_FREE_FUNC_TYPE (p, n, mp_limb_t)
#define __GMP_REALLOCATE_FUNC_MAYBE(ptr, oldsize, newsize) \
do { \
if ((oldsize) != (newsize)) \
(ptr) = (*__gmp_reallocate_func) (ptr, oldsize, newsize); \
} while (0)
#define __GMP_REALLOCATE_FUNC_MAYBE_TYPE(ptr, oldsize, newsize, type) \
do { \
if ((oldsize) != (newsize)) \
(ptr) = (type *) (*__gmp_reallocate_func) \
(ptr, (oldsize) * sizeof (type), (newsize) * sizeof (type)); \
} while (0)
/* Dummy for non-gcc, code involving it will go dead. */
#if ! defined (__GNUC__) || __GNUC__ < 2
#define __builtin_constant_p(x) 0
#endif
/* In gcc 2.96 and up on i386, tail calls are optimized to jumps if the
stack usage is compatible. __attribute__ ((regparm (N))) helps by
putting leading parameters in registers, avoiding extra stack.
regparm cannot be used with calls going through the PLT, because the
binding code there may clobber the registers (%eax, %edx, %ecx) used for
the regparm parameters. Calls to local (ie. static) functions could
still use this, if we cared to differentiate locals and globals.
On athlon-unknown-freebsd4.9 with gcc 3.3.3, regparm cannot be used with
-p or -pg profiling, since that version of gcc doesn't realize the
.mcount calls will clobber the parameter registers. Other systems are
ok, like debian with glibc 2.3.2 (mcount doesn't clobber), but we don't
bother to try to detect this. regparm is only an optimization so we just
disable it when profiling (profiling being a slowdown anyway). */
#define USE_LEADING_REGPARM 0
/* Macros for altering parameter order according to regparm usage. */
#if USE_LEADING_REGPARM
#define REGPARM_2_1(a,b,x) x,a,b
#define REGPARM_3_1(a,b,c,x) x,a,b,c
#define REGPARM_ATTR(n) __attribute__ ((regparm (n)))
#else
#define REGPARM_2_1(a,b,x) a,b,x
#define REGPARM_3_1(a,b,c,x) a,b,c,x
#define REGPARM_ATTR(n)
#endif
__GMP_DECLSPEC int is_likely_prime_BPSW(mp_limb_t n);
__GMP_DECLSPEC mp_limb_t n_sqrt(mp_limb_t r);
void __gmpz_aorsmul_1 _PROTO ((REGPARM_3_1 (mpz_ptr w, mpz_srcptr u, mp_limb_t v, mp_size_t sub))) REGPARM_ATTR(1);
#define mpz_aorsmul_1(w,u,v,sub) __gmpz_aorsmul_1 (REGPARM_3_1 (w, u, v, sub))
#define mpz_n_pow_ui __gmpz_n_pow_ui
void mpz_n_pow_ui _PROTO ((mpz_ptr, mp_srcptr, mp_size_t, unsigned long));
#define mpn_add_nc __MPN(add_nc)
__GMP_DECLSPEC mp_limb_t mpn_add_nc __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, mp_limb_t));
#define mpn_addmul_1c __MPN(addmul_1c)
__GMP_DECLSPEC mp_limb_t mpn_addmul_1c __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t));
#define mpn_addmul_2 __MPN(addmul_2)
__GMP_DECLSPEC mp_limb_t mpn_addmul_2 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr));
#define mpn_addmul_3 __MPN(addmul_3)
__GMP_DECLSPEC mp_limb_t mpn_addmul_3 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr));
#define mpn_addmul_4 __MPN(addmul_4)
__GMP_DECLSPEC mp_limb_t mpn_addmul_4 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr));
#define mpn_addmul_5 __MPN(addmul_5)
__GMP_DECLSPEC mp_limb_t mpn_addmul_5 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr));
#define mpn_addmul_6 __MPN(addmul_6)
__GMP_DECLSPEC mp_limb_t mpn_addmul_6 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr));
#define mpn_addmul_7 __MPN(addmul_7)
__GMP_DECLSPEC mp_limb_t mpn_addmul_7 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr));
#define mpn_addmul_8 __MPN(addmul_8)
__GMP_DECLSPEC mp_limb_t mpn_addmul_8 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr));
#define mpn_addlsh_n __MPN(addlsh_n)
__GMP_DECLSPEC mp_limb_t mpn_addlsh_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t,unsigned int));
#define mpn_sublsh_n __MPN(sublsh_n)
__GMP_DECLSPEC mp_limb_t mpn_sublsh_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t,unsigned int));
#define mpn_addlsh_nc __MPN(addlsh_nc)
__GMP_DECLSPEC mp_limb_t mpn_addlsh_nc __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t,unsigned int, mp_limb_t));
#define mpn_sublsh_nc __MPN(sublsh_nc)
__GMP_DECLSPEC mp_limb_t mpn_sublsh_nc __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t,unsigned int, mp_limb_t));
/* mpn_rsh1add_n(c,a,b,n), when it exists, sets {c,n} to ({a,n} + {b,n}) >> 1,
and returns the bit rshifted out (0 or 1). */
#define mpn_rsh1add_n __MPN(rsh1add_n)
__GMP_DECLSPEC mp_limb_t mpn_rsh1add_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
/* mpn_rsh1sub_n(c,a,b,n), when it exists, sets {c,n} to ({a,n} - {b,n}) >> 1,
and returns the bit rshifted out (0 or 1). If there's a borrow from the
subtract, it's stored as a 1 in the high bit of c[n-1], like a twos
complement negative. */
#define mpn_rsh1sub_n __MPN(rsh1sub_n)
__GMP_DECLSPEC mp_limb_t mpn_rsh1sub_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
#if HAVE_NATIVE_mpn_lshiftc
#define mpn_lshiftc __MPN(lshiftc)
__GMP_DECLSPEC mp_limb_t mpn_lshiftc __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t,unsigned int));
#endif
#define mpn_addadd_n __MPN(addadd_n)
__GMP_DECLSPEC mp_limb_t mpn_addadd_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_srcptr, mp_size_t));
#define mpn_addsub_n __MPN(addsub_n)
__GMP_DECLSPEC int mpn_addsub_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_srcptr, mp_size_t));
#define mpn_subadd_n __MPN(subadd_n)
__GMP_DECLSPEC mp_limb_t mpn_subadd_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_srcptr, mp_size_t));
#if HAVE_NATIVE_mpn_karaadd
#define mpn_karaadd __MPN(karaadd)
__GMP_DECLSPEC void mpn_karaadd __GMP_PROTO ((mp_ptr, mp_ptr, mp_size_t));
#endif
#if HAVE_NATIVE_mpn_karasub
#define mpn_karasub __MPN(karasub)
__GMP_DECLSPEC void mpn_karasub __GMP_PROTO ((mp_ptr, mp_ptr, mp_size_t));
#endif
#ifndef mpn_sumdiff_n /* if not done with cpuvec in a fat binary */
#define mpn_sumdiff_n __MPN(sumdiff_n)
__GMP_DECLSPEC mp_limb_t mpn_sumdiff_n __GMP_PROTO ((mp_ptr, mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
#endif
#define mpn_sumdiff_nc __MPN(sumdiff_nc)
__GMP_DECLSPEC mp_limb_t mpn_sumdiff_nc __GMP_PROTO ((mp_ptr, mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, mp_limb_t));
#define mpn_divexact_byff __MPN(divexact_byff)
__GMP_DECLSPEC mp_limb_t mpn_divexact_byff __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t));
#ifndef mpn_divexact_byfobm1 /* if not done with cpuvec in a fat binary */
#define mpn_divexact_byfobm1 __MPN(divexact_byfobm1)
__GMP_DECLSPEC mp_limb_t mpn_divexact_byfobm1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t,mp_limb_t,mp_limb_t));
#endif
#define mpn_add_err1_n __MPN(add_err1_n)
mp_limb_t mpn_add_err1_n (mp_ptr, mp_srcptr, mp_srcptr, mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);
#define mpn_sub_err1_n __MPN(sub_err1_n)
mp_limb_t mpn_sub_err1_n (mp_ptr, mp_srcptr, mp_srcptr, mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);
#define mpn_add_err2_n __MPN(add_err2_n)
mp_limb_t mpn_add_err2_n (mp_ptr, mp_srcptr, mp_srcptr, mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, mp_limb_t);
#define mpn_sub_err2_n __MPN(sub_err2_n)
mp_limb_t mpn_sub_err2_n (mp_ptr, mp_srcptr, mp_srcptr, mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, mp_limb_t);
#define mpn_divrem_1c __MPN(divrem_1c)
__GMP_DECLSPEC mp_limb_t mpn_divrem_1c __GMP_PROTO ((mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t));
#define mpn_dump __MPN(dump)
__GMP_DECLSPEC void mpn_dump __GMP_PROTO ((mp_srcptr, mp_size_t));
#define mpn_fib2_ui __MPN(fib2_ui)
mp_size_t mpn_fib2_ui _PROTO ((mp_ptr, mp_ptr, unsigned long));
/* Remap names of internal mpn functions. */
#define __clz_tab __MPN(clz_tab)
#define mpn_udiv_w_sdiv __MPN(udiv_w_sdiv)
#define mpn_gcd_finda __MPN(gcd_finda)
mp_limb_t mpn_gcd_finda _PROTO((const mp_limb_t cp[2])) __GMP_ATTRIBUTE_PURE;
#define mpn_jacobi_base __MPN(jacobi_base)
__GMP_DECLSPEC int mpn_jacobi_base _PROTO ((mp_limb_t a, mp_limb_t b, int result_bit1)) ATTRIBUTE_CONST;
#define mpn_mod_1c __MPN(mod_1c)
__GMP_DECLSPEC mp_limb_t mpn_mod_1c __GMP_PROTO ((mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t)) __GMP_ATTRIBUTE_PURE;
#define mpn_mul_1c __MPN(mul_1c)
__GMP_DECLSPEC mp_limb_t mpn_mul_1c __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t));
#define mpn_mul_2 __MPN(mul_2)
mp_limb_t mpn_mul_2 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr));
#ifndef mpn_mul_basecase /* if not done with cpuvec in a fat binary */
#define mpn_mul_basecase __MPN(mul_basecase)
__GMP_DECLSPEC void mpn_mul_basecase __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t));
#endif
#define mpn_mullow_n __MPN(mullow_n)
__GMP_DECLSPEC void mpn_mullow_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
#define mpn_mullow_n_basecase __MPN(mullow_n_basecase)
__GMP_DECLSPEC void mpn_mullow_n_basecase __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
#define mpn_mulhigh_n __MPN(mulhigh_n)
__GMP_DECLSPEC void mpn_mulhigh_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
#define mpn_mullow_basecase __MPN(mullow_basecase)
__GMP_DECLSPEC void mpn_mullow_basecase __GMP_PROTO ((mp_ptr, mp_srcptr,mp_size_t, mp_srcptr, mp_size_t,mp_size_t));
#define mpn_mulmid_basecase __MPN(mulmid_basecase)
__GMP_DECLSPEC void mpn_mulmid_basecase __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t));
#define mpn_mod_1_1 __MPN(mod_1_1)
__GMP_DECLSPEC void mpn_mod_1_1 __GMP_PROTO ((mp_ptr,mp_srcptr, mp_size_t, mp_srcptr));