-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcompat.gmp.lua
More file actions
5074 lines (4460 loc) · 283 KB
/
Copy pathcompat.gmp.lua
File metadata and controls
5074 lines (4460 loc) · 283 KB
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
-- compat.gmp -- GNU MP 6.3.0, compiled by mcpp itself on all three platforms.
--
-- NO install() HOOK, NO EXTERNAL BUILD SYSTEM. mcpp compiles GMP's portable
-- C kernels straight from the upstream tarball, with the consumer's own
-- toolchain, on linux / macOS / windows alike.
--
-- WHY NOT UPSTREAM'S BUILD
--
-- GMP ships only an autotools build, and driving it from an install() hook
-- (which is what the first version of this package did, linux + macOS only)
-- buys three problems:
--
-- 1. `configure` COMPILES AND RUNS probe programs. One of them calls a
-- `void g(){}` with six arguments, which a C23 default -- gcc >= 15 --
-- rejects outright, so configure reports `could not find a working
-- compiler` on any recent distro. Reproduced here on gcc 16.1.0; CI
-- only stayed green because ubuntu-latest is still gcc 13.
-- 2. Running probes at all requires a HOST compiler whose binaries can be
-- executed in the hook -- which is why the hook could not use mcpp's own
-- toolchain, and why the built archive came from a compiler unrelated to
-- the one the consumer links with.
-- 3. There is no MSVC/clang-on-Windows path upstream at all, which is why
-- windows was deferred.
--
-- Describing the build in `mcpp = { }` removes all three at once: no
-- configure, no make, no cmake, no host compiler, no build-time deps of any
-- kind -- and windows becomes just another target, because the only thing
-- GMP's generic C needs is a GCC-compatible compiler, which is exactly what
-- this index already ships everywhere (clang++ on the MSVC ABI on Windows).
--
-- WHAT HAD TO BE VENDORED, AND WHY
--
-- GMP's build does two things a descriptor cannot express, both of which are
-- pure functions of (GMP_LIMB_BITS=64, GMP_NAIL_BITS=0):
--
-- * it substitutes gmp.h from gmp-h.in (eight @VAR@s), and
-- * it COMPILES AND RUNS seven table generators (gen-fac, gen-fib,
-- gen-bases, gen-sieve, gen-trialdivtab, gen-jacobitab, gen-psqr) to
-- produce nine tables.
--
-- Those outputs are generated once, by upstream's own generators, and
-- vendored into `generated_files` below (~270 KB, of which trialdivtab.h is
-- 109 KB). They are data, not a re-implementation: the descriptor's
-- generated tables are byte-for-byte what `gen-* 64 0` prints.
--
-- Because the tables are limb=64, config.h refuses to compile on a target
-- with no 64-bit unsigned type rather than silently computing wrong answers.
--
-- The rest of `generated_files` is glue: a one-line forwarding header per
-- source directory (upstream reaches gmp-impl.h / longlong.h / config.h
-- through -I<srcroot>; forwarders let the quoted include resolve next to the
-- file that wrote it, so the package needs NO -I and `include_dirs` can
-- expose gmp.h + gmpxx.h and nothing else), and one wrapper TU per
-- "mulfunc" source -- files upstream compiles repeatedly under different
-- -DOPERATION_* to emit a different mpn entry point each time.
--
-- EQUIVALENCE, MEASURED
--
-- Against a `--disable-assembly` autotools build of the same tarball:
-- * 598 global symbols, exactly the same set -- none missing, none extra;
-- * GMP's OWN test suite (`make check`, 178 programs) run against this
-- library: 177 passed, 0 failed, 1 skipped -- with gcc and with clang.
-- Faster than that reference build, too: `--disable-assembly` defines NO_ASM,
-- which also switches off longlong.h's inline-asm primitives (umul_ppmm,
-- add_ssaaaa, count_leading_zeros). Those are gated on compiler predefines
-- and degrade to C by themselves, so this build keeps them.
--
-- The hand-written per-CPU .asm kernels are NOT built: selecting them needs
-- m4 and a CPU match, i.e. exactly the host-dependence this package exists
-- to avoid.
--
-- License: GMP is dual LGPL-3.0-or-later OR GPL-2.0-or-later (tarball
-- README); the permissive side is declared. The vendored generated files
-- above are output of GMP's own generators and carry the same license.
package = {
spec = "1",
namespace = "compat",
name = "gmp",
description = "GMP -- GNU multiple precision arithmetic library (portable C kernels, built by mcpp)",
licenses = {"LGPL-3.0-or-later"},
repo = "https://gmplib.org/",
type = "package",
-- One tarball, one sha256, three platforms -- the authoritative GNU
-- release. (A GitHub snapshot would be missing `configure`, which this
-- package does not use, but also `gmp-h.in`, which it does.)
--
-- No `deps`: nothing is needed at build time. The previous version
-- carried `xim:make@latest` on linux and nothing on macOS, which is the
-- kind of per-platform asymmetry that only shows up as a red job.
--
-- CN mirrors the identical bytes from `mcpp-res/gmp` -- the gitcode
-- release asset is a byte-for-byte copy of the ftp.gnu.org tarball, so
-- the single sha256 below authenticates either arm of the table.
xpm = {
linux = {
["6.3.0"] = {
url = {
GLOBAL = "https://ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.gz",
CN = "https://gitcode.com/mcpp-res/gmp/releases/download/6.3.0/gmp-6.3.0.tar.gz",
},
sha256 = "e56fd59d76810932a0555aa15a14b61c16bed66110d3c75cc2ac49ddaa9ab24c",
},
},
macosx = {
["6.3.0"] = {
url = {
GLOBAL = "https://ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.gz",
CN = "https://gitcode.com/mcpp-res/gmp/releases/download/6.3.0/gmp-6.3.0.tar.gz",
},
sha256 = "e56fd59d76810932a0555aa15a14b61c16bed66110d3c75cc2ac49ddaa9ab24c",
},
},
windows = {
["6.3.0"] = {
url = {
GLOBAL = "https://ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.gz",
CN = "https://gitcode.com/mcpp-res/gmp/releases/download/6.3.0/gmp-6.3.0.tar.gz",
},
sha256 = "e56fd59d76810932a0555aa15a14b61c16bed66110d3c75cc2ac49ddaa9ab24c",
},
},
},
mcpp = {
language = "c++23",
import_std = false,
c_standard = "c11",
-- Two forwarding headers and nothing else. GMP's private headers
-- (gmp-impl.h, longlong.h, config.h, the tables) stay OUT of every
-- consumer's include path -- `config.h` in particular is a name no
-- dependency should be putting on a -I line.
include_dirs = { "gmp-6.3.0/mcpp/include" },
targets = { ["gmp"] = { kind = "lib" } },
deps = { },
-- __GMP_WITHIN_GMP is what switches gmp.h from the consumer view to
-- the library's own; it must NOT reach consumers, and package cflags
-- do not. -w: this is vendored third-party C, and 516 TUs of
-- upstream's warnings would bury anything worth reading.
cflags = { "-D__GMP_WITHIN_GMP", "-w" },
cxxflags = { "-w" },
-- The archive routinely ends up inside a consumer's shared library
-- (a plugin, a Python extension, a GDExtension). Without PIC that
-- link fails outright -- "relocation R_X86_64_32 against
-- `.rodata` can not be used when making a shared object" -- and it
-- also fails against a PIE default, which is how a clang++ link of
-- the gmpxx test surfaced it here. Not on windows: PE/COFF has no
-- such distinction and clang would only report the flag as unused.
linux = { cflags = { "-fPIC" }, cxxflags = { "-fPIC" } },
macosx = { cflags = { "-fPIC" }, cxxflags = { "-fPIC" } },
-- gmpxx: GMP's C++ bindings (mpz_class / mpq_class / mpf_class --
-- RAII wrappers with operator overloading, and the iostream
-- operators).
--
-- A feature rather than always-on because it costs a C++ TU that a
-- C consumer never needs; `gmpxx.h` itself ships unconditionally, so
-- leaving the feature off and calling `std::cout << mpz_class`
-- fails at LINK time with an undefined `__gmp_ostream_operator`
-- rather than at the #include -- which is also the negative check
-- that the gate really gates (verified: 3 undefined references).
--
-- Compiled by the CONSUMER's toolchain, which is the whole reason it
-- is a source and not a prebuilt archive: these TUs' symbols carry
-- std::ostream / std::string in their names, so a copy built against
-- libstdc++ would not resolve for a libc++ consumer.
features = {
["gmpxx"] = { sources = { "gmp-6.3.0/mcpp/mcpp_gmpxx.cc" } },
},
sources = {
-- root: the 16 top-level TUs upstream compiles
-- (mp_clz_tab.c goes through the wrapper below)
"gmp-6.3.0/assert.c",
"gmp-6.3.0/compat.c",
"gmp-6.3.0/errno.c",
"gmp-6.3.0/extract-dbl.c",
"gmp-6.3.0/invalid.c",
"gmp-6.3.0/memory.c",
"gmp-6.3.0/mp_bpl.c",
"gmp-6.3.0/mp_dv_tab.c",
"gmp-6.3.0/mp_get_fns.c",
"gmp-6.3.0/mp_minv_tab.c",
"gmp-6.3.0/mp_set_fns.c",
"gmp-6.3.0/nextprime.c",
"gmp-6.3.0/primesieve.c",
"gmp-6.3.0/tal-reent.c",
"gmp-6.3.0/version.c",
-- mpn: the portable C kernels. The exclusions are
-- upstream's: udiv_w_sdiv is an extra function for
-- CPUs with signed-but-not-unsigned divide,
-- div_qr_1{n,u}_pi2 are selected only by a
-- HAVE_NATIVE_mpn_* this build never sets, and the
-- five mulfunc sources are compiled through the
-- per-operation wrappers instead.
"gmp-6.3.0/mpn/generic/*.c",
"!gmp-6.3.0/mpn/generic/udiv_w_sdiv.c",
"!gmp-6.3.0/mpn/generic/div_qr_1n_pi2.c",
"!gmp-6.3.0/mpn/generic/div_qr_1u_pi2.c",
"!gmp-6.3.0/mpn/generic/logops_n.c",
"!gmp-6.3.0/mpn/generic/popham.c",
"!gmp-6.3.0/mpn/generic/sec_aors_1.c",
"!gmp-6.3.0/mpn/generic/sec_div.c",
"!gmp-6.3.0/mpn/generic/sec_pi1_div.c",
-- these six directories are compiled whole
"gmp-6.3.0/mpz/*.c",
"gmp-6.3.0/mpf/*.c",
"gmp-6.3.0/mpq/*.c",
"gmp-6.3.0/printf/*.c",
"gmp-6.3.0/scanf/*.c",
"gmp-6.3.0/rand/*.c",
-- generated. Listed one by one rather than globbed:
-- a glob over files that generated_files has yet to
-- write is a build that depends on step ordering.
"gmp-6.3.0/mcpp/mcpp_gmp_and_n.c",
"gmp-6.3.0/mcpp/mcpp_gmp_andn_n.c",
"gmp-6.3.0/mcpp/mcpp_gmp_clz_tab.c",
"gmp-6.3.0/mcpp/mcpp_gmp_fib_table.c",
"gmp-6.3.0/mcpp/mcpp_gmp_hamdist.c",
"gmp-6.3.0/mcpp/mcpp_gmp_ior_n.c",
"gmp-6.3.0/mcpp/mcpp_gmp_iorn_n.c",
"gmp-6.3.0/mcpp/mcpp_gmp_mp_bases.c",
"gmp-6.3.0/mcpp/mcpp_gmp_nand_n.c",
"gmp-6.3.0/mcpp/mcpp_gmp_nior_n.c",
"gmp-6.3.0/mcpp/mcpp_gmp_popcount.c",
"gmp-6.3.0/mcpp/mcpp_gmp_sec_add_1.c",
"gmp-6.3.0/mcpp/mcpp_gmp_sec_div_qr.c",
"gmp-6.3.0/mcpp/mcpp_gmp_sec_div_r.c",
"gmp-6.3.0/mcpp/mcpp_gmp_sec_pi1_div_qr.c",
"gmp-6.3.0/mcpp/mcpp_gmp_sec_pi1_div_r.c",
"gmp-6.3.0/mcpp/mcpp_gmp_sec_sub_1.c",
"gmp-6.3.0/mcpp/mcpp_gmp_xnor_n.c",
"gmp-6.3.0/mcpp/mcpp_gmp_xor_n.c",
},
-- Everything GMP's build would have generated. See the header.
generated_files = {
["gmp-6.3.0/config.h"] =
[[
/* config.h for GNU MP 6.3.0 -- written for mcpp-index's compat.gmp.
Upstream generates this from ~200 configure probes. compat.gmp has no
configure step, so the answers are decided here instead -- and the whole
file is deliberately platform-INDEPENDENT: every HAVE_* below is either
guaranteed by C89/C99 on any hosted implementation, or answered "no" on
purpose so that linux, macOS and Windows compile the identical library.
The ones answered "no" on purpose, and what it costs:
HAVE_UNISTD_H only guards <unistd.h> for getpid(), which invalid.c
needs solely as a fallback when raise() is missing.
raise() is C89.
HAVE_LANGINFO_H nl_langinfo(RADIXCHAR) is one of two ways GMP finds
the locale's decimal point; localeconv() is the other
and is C89. Reaching for the POSIX one under a
strict -std=c11 (which is what mcpp compiles C with)
is how you get an implicit declaration.
HAVE_SYS_TYPES_H only guards the <sys/types.h> include for quad_t.
HAVE_QUAD_T drops gmp_printf/gmp_scanf's BSD %q length modifier.
glibc only declares quad_t under __USE_MISC, which
-std=c11 turns off, so "yes" is not portable anyway.
HAVE_OBSTACK_VPRINTF drops gmp_obstack_printf / gmp_obstack_vprintf.
glibc-only, and its declaration needs _GNU_SOURCE.
HAVE_ALLOCA_H unnecessary: gmp-impl.h reaches __builtin_alloca on
GCC/Clang before it ever looks at <alloca.h>, and
mcpp ships nothing else.
HAVE_HIDDEN_ALIAS an ELF-only link-time optimisation; wrong on Mach-O
and PE.
NO_ASM NOT defined, i.e. longlong.h's inline asm primitives
(umul_ppmm / add_ssaaaa / count_leading_zeros) stay
ON. They are selected by compiler predefines and
fall back to C on their own; upstream's
--disable-assembly switches them off along with the
hand-written kernels, which costs several times the
throughput on the multiply/divide path for no
portability gain.
HAVE_NATIVE_mpn_* never defined: this package compiles mpn/generic,
not the per-CPU .asm kernels (those need m4).
WANT_FAT_BINARY / WANT_ASSERT / WANT_PROFILING off, as upstream. */
#ifndef __GMP_CONFIG_H__
#define __GMP_CONFIG_H__
#include <limits.h>
/* The vendored tables (fac_table.h, fib_table.h, sieve_table.h, mp_bases.h,
trialdivtab.h, perfsqr.h, jacobitab.h) were generated for
GMP_LIMB_BITS = 64, GMP_NAIL_BITS = 0. A target with no 64-bit unsigned
type would otherwise take them silently and compute wrong answers, so it
has to stop here. The same test picks the limb type in gmp.h. */
#if !(ULONG_MAX >> 31 >> 31 >> 1 == 1) && \
!(defined(ULLONG_MAX) && ULLONG_MAX >> 31 >> 31 >> 1 == 1)
# error "compat.gmp: 64-bit targets only (the vendored tables are limb=64)."
#endif
#define PACKAGE_NAME "GNU MP"
#define PACKAGE_TARNAME "gmp"
#define PACKAGE_VERSION "6.3.0"
#define PACKAGE_STRING "GNU MP 6.3.0"
#define PACKAGE_BUGREPORT "gmp-bugs@gmplib.org (see https://gmplib.org/manual/Reporting-Bugs.html)"
#define VERSION "6.3.0"
#define GMP_LIMB_BITS 64
#define GMP_NAIL_BITS 0
#define SIZEOF_MP_LIMB_T 8
/* Taken from the compiler rather than from a probe: exact by construction,
and identical on every target mcpp builds for. */
#define SIZEOF_UNSIGNED __SIZEOF_INT__
#define SIZEOF_UNSIGNED_SHORT __SIZEOF_SHORT__
#define SIZEOF_UNSIGNED_LONG __SIZEOF_LONG__
#define SIZEOF_VOID_P __SIZEOF_POINTER__
#define STDC_HEADERS 1
/* Headers and functions guaranteed by C89/C99. */
#define HAVE_STDLIB_H 1
#define HAVE_STRING_H 1
#define HAVE_FLOAT_H 1
#define HAVE_LOCALE_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_STDINT_H 1
#define HAVE_LOCALECONV 1
#define HAVE_MEMSET 1
#define HAVE_STRCHR 1
#define HAVE_STRERROR 1
#define HAVE_STRTOL 1
#define HAVE_STRTOUL 1
#define HAVE_RAISE 1
#define HAVE_VSNPRINTF 1
#define HAVE_STRNLEN 1
#define HAVE_LONG_LONG 1
#define HAVE_LONG_DOUBLE 1
#define HAVE_INTMAX_T 1
#define HAVE_INTPTR_T 1
#define HAVE_PTRDIFF_T 1
#define HAVE_UINT_LEAST32_T 1
/* C89 declarations GMP double-checks because a few pre-standard libcs
omitted them. */
#define HAVE_DECL_FGETC 1
#define HAVE_DECL_FSCANF 1
#define HAVE_DECL_UNGETC 1
#define HAVE_DECL_VFPRINTF 1
/* Schoenhage-Strassen multiplication, as in a default upstream build. */
#define WANT_FFT 1
#if defined(__GNUC__)
# define HAVE_ATTRIBUTE_CONST 1
# define HAVE_ATTRIBUTE_MALLOC 1
# define HAVE_ATTRIBUTE_MODE 1
# define HAVE_ATTRIBUTE_NORETURN 1
#endif
/* TMP_ALLOC on the stack. gmp-impl.h resolves `alloca` to __builtin_alloca
under __GNUC__ and to _alloca under _MSC_VER before it ever needs
<alloca.h>; anything else falls back to the malloc-based strategy. */
#if defined(__GNUC__) || defined(_MSC_VER)
# define HAVE_ALLOCA 1
# define WANT_TMP_ALLOCA 1
#else
# define WANT_TMP_REENTRANT 1
#endif
/* Byte order of a `double' and of a multi-limb value. */
#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \
__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
# define HAVE_DOUBLE_IEEE_BIG_ENDIAN 1
# define HAVE_LIMB_BIG_ENDIAN 1
#else
# define HAVE_DOUBLE_IEEE_LITTLE_ENDIAN 1
# define HAVE_LIMB_LITTLE_ENDIAN 1
#endif
/* CPU family. This unlocks exactly two things in the generic sources: the
add_mssaaaa inline asm in mod_1_1.c / div_qr_1n_pi1.c, and the tighter
MPN_IORD_U in gmp-impl.h. Both are additionally gated on __GNUC__ and
!NO_ASM, so a target that is neither keeps the C path. */
#if defined(__x86_64__) || defined(__amd64__)
# define HAVE_HOST_CPU_FAMILY_x86_64 1
#elif defined(__i386__)
# define HAVE_HOST_CPU_FAMILY_x86 1
#endif
/* Assembler local-label prefix, used by the MPN_IORD_U asm above. Mach-O
private labels are `L...`, ELF and COFF `.L...`. Assembler syntax, not
compiler syntax -- getting it wrong is a loud assembler error. */
#if defined(__APPLE__)
# define LSYM_PREFIX "L"
#else
# define LSYM_PREFIX ".L"
#endif
#ifndef __cplusplus
# define restrict __restrict
#endif
#endif /* __GMP_CONFIG_H__ */
]],
["gmp-6.3.0/cxx/gmp-impl.h"] =
[[
/* compat.gmp: upstream reaches this header through -I<srcroot>.
mcpp compiles a package's sources with only its public
include_dirs, so instead of exposing GMP's private headers to
every consumer, each source directory gets a one-line
forwarder and the quoted include resolves next to the file
that wrote it. */
#include "../gmp-impl.h"
]],
["gmp-6.3.0/cxx/gmpxx.h"] =
[[
/* compat.gmp: upstream reaches this header through -I<srcroot>.
mcpp compiles a package's sources with only its public
include_dirs, so instead of exposing GMP's private headers to
every consumer, each source directory gets a one-line
forwarder and the quoted include resolves next to the file
that wrote it. */
#include "../gmpxx.h"
]],
["gmp-6.3.0/fac_table.h"] =
[[
/* This file is automatically generated by gen-fac.c */
#if GMP_NUMB_BITS != 64
Error , error this data is for 64 GMP_NUMB_BITS only
#endif
/* This table is 0!,1!,2!,3!,...,n! where n! has <= GMP_NUMB_BITS bits */
#define ONE_LIMB_FACTORIAL_TABLE CNST_LIMB(0x1),CNST_LIMB(0x1),CNST_LIMB(0x2),CNST_LIMB(0x6),CNST_LIMB(0x18),CNST_LIMB(0x78),CNST_LIMB(0x2d0),CNST_LIMB(0x13b0),CNST_LIMB(0x9d80),CNST_LIMB(0x58980),CNST_LIMB(0x375f00),CNST_LIMB(0x2611500),CNST_LIMB(0x1c8cfc00),CNST_LIMB(0x17328cc00),CNST_LIMB(0x144c3b2800),CNST_LIMB(0x13077775800),CNST_LIMB(0x130777758000),CNST_LIMB(0x1437eeecd8000),CNST_LIMB(0x16beecca730000),CNST_LIMB(0x1b02b9306890000),CNST_LIMB(0x21c3677c82b40000)
/* This table is 0!,1!,2!/2,3!/2,...,n!/2^sn where n!/2^sn is an */
/* odd integer for each n, and n!/2^sn has <= GMP_NUMB_BITS bits */
#define ONE_LIMB_ODD_FACTORIAL_TABLE CNST_LIMB(0x1),CNST_LIMB(0x1),CNST_LIMB(0x1),CNST_LIMB(0x3),CNST_LIMB(0x3),CNST_LIMB(0xf),CNST_LIMB(0x2d),CNST_LIMB(0x13b),CNST_LIMB(0x13b),CNST_LIMB(0xb13),CNST_LIMB(0x375f),CNST_LIMB(0x26115),CNST_LIMB(0x7233f),CNST_LIMB(0x5cca33),CNST_LIMB(0x2898765),CNST_LIMB(0x260eeeeb),CNST_LIMB(0x260eeeeb),CNST_LIMB(0x286fddd9b),CNST_LIMB(0x16beecca73),CNST_LIMB(0x1b02b930689),CNST_LIMB(0x870d9df20ad),CNST_LIMB(0xb141df4dae31),CNST_LIMB(0x79dd498567c1b),CNST_LIMB(0xaf2e19afc5266d),CNST_LIMB(0x20d8a4d0f4f7347),CNST_LIMB(0x335281867ec241ef)
#define ODD_FACTORIAL_TABLE_MAX CNST_LIMB(0x335281867ec241ef)
#define ODD_FACTORIAL_TABLE_LIMIT (25)
/* Previous table, continued, values modulo 2^GMP_NUMB_BITS */
#define ONE_LIMB_ODD_FACTORIAL_EXTTABLE CNST_LIMB(0x9b3093d46fdd5923),CNST_LIMB(0x5e1f9767cc5866b1),CNST_LIMB(0x92dd23d6966aced7),CNST_LIMB(0xa30d0f4f0a196e5b),CNST_LIMB(0x8dc3e5a1977d7755),CNST_LIMB(0x2ab8ce915831734b),CNST_LIMB(0x2ab8ce915831734b),CNST_LIMB(0x81d2a0bc5e5fdcab),CNST_LIMB(0x9efcac82445da75b),CNST_LIMB(0xbc8b95cf58cde171),CNST_LIMB(0xa0e8444a1f3cecf9),CNST_LIMB(0x4191deb683ce3ffd),CNST_LIMB(0xddd3878bc84ebfc7),CNST_LIMB(0xcb39a64b83ff3751),CNST_LIMB(0xf8203f7993fc1495),CNST_LIMB(0xbd2a2a78b35f4bdd),CNST_LIMB(0x84757be6b6d13921),CNST_LIMB(0x3fbbcfc0b524988b),CNST_LIMB(0xbd11ed47c8928df9),CNST_LIMB(0x3c26b59e41c2f4c5),CNST_LIMB(0x677a5137e883fdb3),CNST_LIMB(0xff74e943b03b93dd),CNST_LIMB(0xfe5ebbcb10b2bb97),CNST_LIMB(0xb021f1de3235e7e7),CNST_LIMB(0x33509eb2e743a58f),CNST_LIMB(0x390f9da41279fb7d),CNST_LIMB(0xe5cb0154f031c559),CNST_LIMB(0x93074695ba4ddb6d),CNST_LIMB(0x81c471caa636247f),CNST_LIMB(0xe1347289b5a1d749),CNST_LIMB(0x286f21c3f76ce2ff),CNST_LIMB(0xbe84a2173e8ac7),CNST_LIMB(0x1595065ca215b88b),CNST_LIMB(0xf95877595b018809),CNST_LIMB(0x9c2efe3c5516f887),CNST_LIMB(0x373294604679382b),CNST_LIMB(0xaf1ff7a888adcd35),CNST_LIMB(0x18ddf279a2c5800b),CNST_LIMB(0x18ddf279a2c5800b),CNST_LIMB(0x505a90e2542582cb),CNST_LIMB(0x5bacad2cd8d5dc2b),CNST_LIMB(0xfe3152bcbff89f41)
#define ODD_FACTORIAL_EXTTABLE_LIMIT (67)
/* This table is 1!!,3!!,...,(2n+1)!! where (2n+1)!! has <= GMP_NUMB_BITS bits */
#define ONE_LIMB_ODD_DOUBLEFACTORIAL_TABLE CNST_LIMB(0x1),CNST_LIMB(0x3),CNST_LIMB(0xf),CNST_LIMB(0x69),CNST_LIMB(0x3b1),CNST_LIMB(0x289b),CNST_LIMB(0x20fdf),CNST_LIMB(0x1eee11),CNST_LIMB(0x20dcf21),CNST_LIMB(0x27065f73),CNST_LIMB(0x33385d46f),CNST_LIMB(0x49a10615f9),CNST_LIMB(0x730b9982551),CNST_LIMB(0xc223930bef8b),CNST_LIMB(0x15fe07a85a22bf),CNST_LIMB(0x2a9c2ed62ea3521),CNST_LIMB(0x57e22099c030d941)
#define ODD_DOUBLEFACTORIAL_TABLE_MAX CNST_LIMB(0x57e22099c030d941)
#define ODD_DOUBLEFACTORIAL_TABLE_LIMIT (33)
/* This table x_1, x_2,... contains values s.t. x_n^n has <= GMP_NUMB_BITS bits */
#define NTH_ROOT_NUMB_MASK_TABLE (GMP_NUMB_MASK),CNST_LIMB(0xffffffff),CNST_LIMB(0x285145),CNST_LIMB(0xffff),CNST_LIMB(0x1bdb),CNST_LIMB(0x659),CNST_LIMB(0x235),CNST_LIMB(0xff)
/* This table contains inverses of odd factorials, modulo 2^GMP_NUMB_BITS */
/* It begins with (2!/2)^-1=1 */
#define ONE_LIMB_ODD_FACTORIAL_INVERSES_TABLE CNST_LIMB(0x1),CNST_LIMB(0xaaaaaaaaaaaaaaab),CNST_LIMB(0xaaaaaaaaaaaaaaab),CNST_LIMB(0xeeeeeeeeeeeeeeef),CNST_LIMB(0x4fa4fa4fa4fa4fa5),CNST_LIMB(0x2ff2ff2ff2ff2ff3),CNST_LIMB(0x2ff2ff2ff2ff2ff3),CNST_LIMB(0x938cc70553e3771b),CNST_LIMB(0xb71c27cddd93e49f),CNST_LIMB(0xb38e3229fcdee63d),CNST_LIMB(0xe684bb63544a4cbf),CNST_LIMB(0xc2f684917ca340fb),CNST_LIMB(0xf747c9cba417526d),CNST_LIMB(0xbb26eb51d7bd49c3),CNST_LIMB(0xbb26eb51d7bd49c3),CNST_LIMB(0xb0a7efb985294093),CNST_LIMB(0xbe4b8c69f259eabb),CNST_LIMB(0x6854d17ed6dc4fb9),CNST_LIMB(0xe1aa904c915f4325),CNST_LIMB(0x3b8206df131cead1),CNST_LIMB(0x79c6009fea76fe13),CNST_LIMB(0xd8c5d381633cd365),CNST_LIMB(0x4841f12b21144677),CNST_LIMB(0x4a91ff68200b0d0f),CNST_LIMB(0x8f9513a58c4f9e8b),CNST_LIMB(0x2b3e690621a42251),CNST_LIMB(0x4f520f00e03c04e7),CNST_LIMB(0x2edf84ee600211d3),CNST_LIMB(0xadcaa2764aaacdfd),CNST_LIMB(0x161f4f9033f4fe63),CNST_LIMB(0x161f4f9033f4fe63),CNST_LIMB(0xbada2932ea4d3e03),CNST_LIMB(0xcec189f3efaa30d3),CNST_LIMB(0xf7475bb68330bf91),CNST_LIMB(0x37eb7bf7d5b01549),CNST_LIMB(0x46b35660a4e91555),CNST_LIMB(0xa567c12d81f151f7),CNST_LIMB(0x4c724007bb2071b1),CNST_LIMB(0xf4a0cce58a016bd),CNST_LIMB(0xfa21068e66106475),CNST_LIMB(0x244ab72b5a318ae1),CNST_LIMB(0x366ce67e080d0f23),CNST_LIMB(0xd666fdae5dd2a449),CNST_LIMB(0xd740ddd0acc06a0d),CNST_LIMB(0xb050bbbb28e6f97b),CNST_LIMB(0x70b003fe890a5c75),CNST_LIMB(0xd03aabff83037427),CNST_LIMB(0x13ec4ca72c783bd7),CNST_LIMB(0x90282c06afdbd96f),CNST_LIMB(0x4414ddb9db4a95d5),CNST_LIMB(0xa2c68735ae6832e9),CNST_LIMB(0xbf72d71455676665),CNST_LIMB(0xa8469fab6b759b7f),CNST_LIMB(0xc1e55b56e606caf9),CNST_LIMB(0x40455630fc4a1cff),CNST_LIMB(0x120a7b0046d16f7),CNST_LIMB(0xa7c3553b08faef23),CNST_LIMB(0x9f0bfd1b08d48639),CNST_LIMB(0xa433ffce9a304d37),CNST_LIMB(0xa22ad1d53915c683),CNST_LIMB(0xcb6cbc723ba5dd1d),CNST_LIMB(0x547fb1b8ab9d0ba3),CNST_LIMB(0x547fb1b8ab9d0ba3),CNST_LIMB(0x8f15a826498852e3)
/* This table contains 2n-popc(2n) for small n */
/* It begins with 2-1=1 (n=1) */
#define TABLE_2N_MINUS_POPC_2N 1,3,4,7,8,10,11,15,16,18,19,22,23,25,26,31,32,34,35,38,39,41,42,46,47,49,50,53,54,56,57,63,64,66,67,70,71,73,74,78
#define TABLE_LIMIT_2N_MINUS_POPC_2N 81
#define ODD_CENTRAL_BINOMIAL_OFFSET (13)
/* This table contains binomial(2k,k)/2^t */
/* It begins with ODD_CENTRAL_BINOMIAL_TABLE_MIN */
#define ONE_LIMB_ODD_CENTRAL_BINOMIAL_TABLE CNST_LIMB(0x13d66b),CNST_LIMB(0x4c842f),CNST_LIMB(0x93ee7d),CNST_LIMB(0x11e9e123),CNST_LIMB(0x22c60053),CNST_LIMB(0x873ae4d1),CNST_LIMB(0x10757bd97),CNST_LIMB(0x80612c6cd),CNST_LIMB(0xfaa556bc1),CNST_LIMB(0x3d3cc24821),CNST_LIMB(0x77cfeb6bbb),CNST_LIMB(0x7550ebd97c7),CNST_LIMB(0xe5f08695caf),CNST_LIMB(0x386120ffce11),CNST_LIMB(0x6eabb28dd6df),CNST_LIMB(0x3658e31c82a8f),CNST_LIMB(0x6ad2050312783),CNST_LIMB(0x1a42902a5af0bf),CNST_LIMB(0x33ac44f881661d),CNST_LIMB(0xcb764f927d82123),CNST_LIMB(0x190c23fa46b93983),CNST_LIMB(0x62b7609e25caf1b9),CNST_LIMB(0xc29cb72925ef2cff)
#define ODD_CENTRAL_BINOMIAL_TABLE_LIMIT (35)
/* This table contains the inverses of elements in the previous table. */
#define ONE_LIMB_ODD_CENTRAL_BINOMIAL_INVERSE_TABLE CNST_LIMB(0x61e5bd199bb12643),CNST_LIMB(0x78321494dc8342cf),CNST_LIMB(0x4fd348704ebf7ad5),CNST_LIMB(0x7e722ba086ab568b),CNST_LIMB(0xa5fcc124265843db),CNST_LIMB(0x89c4a6b18633f431),CNST_LIMB(0x4daa2c15f8ce9227),CNST_LIMB(0x801c618ca9be9605),CNST_LIMB(0x32dc192f948a441),CNST_LIMB(0xd02b90c2bf3be1),CNST_LIMB(0xd897e8c1749aa173),CNST_LIMB(0x54a234fc01fef9f7),CNST_LIMB(0x83ff2ab4d1ff7a4f),CNST_LIMB(0xa427f1c9b304e2f1),CNST_LIMB(0x9c14595d1793651f),CNST_LIMB(0x883a71c607a7b46f),CNST_LIMB(0xd089863c54bc9f2b),CNST_LIMB(0x9022f6bce5d07f3f),CNST_LIMB(0xbec207e218768c35),CNST_LIMB(0x9d70cb4cbb4f168b),CNST_LIMB(0x3c3d3403828a9d2b),CNST_LIMB(0x7672df58c56bc489),CNST_LIMB(0x1e66ca55d727d2ff)
/* This table contains the values t in the formula binomial(2k,k)/2^t */
#define CENTRAL_BINOMIAL_2FAC_TABLE 3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,1,2,2,3
]],
["gmp-6.3.0/fib_table.h"] =
[[
/* This file generated by gen-fib.c - DO NOT EDIT. */
#if GMP_NUMB_BITS != 64
Error, error, this data is for 64 bits
#endif
#define FIB_TABLE_LIMIT 93
#define FIB_TABLE_LUCNUM_LIMIT 92
]],
["gmp-6.3.0/gmp-mparam.h"] =
[[
/* Generic C gmp-mparam.h -- Compiler/machine parameter header file.
Copyright 1991, 1993, 1994, 2000 Free Software Foundation, Inc.
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 either:
* 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.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
/* Values for GMP_LIMB_BITS etc will be determined by ./configure and put
in config.h. */
]],
["gmp-6.3.0/gmp.h"] =
[[
/* Definitions for GNU multiple precision functions. -*- mode: c -*-
Copyright 1991, 1993-1997, 1999-2016, 2020, 2021 Free Software
Foundation, Inc.
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 either:
* 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.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#ifndef __GMP_H__
#if defined (__cplusplus)
#include <iosfwd> /* for std::istream, std::ostream, std::string */
#include <cstdio>
#endif
/* Instantiated by configure. */
#if ! defined (__GMP_WITHIN_CONFIGURE)
#define __GMP_HAVE_HOST_CPU_FAMILY_power 0
#define __GMP_HAVE_HOST_CPU_FAMILY_powerpc 0
#define GMP_LIMB_BITS 64
#define GMP_NAIL_BITS 0
#endif
#define GMP_NUMB_BITS (GMP_LIMB_BITS - GMP_NAIL_BITS)
#define GMP_NUMB_MASK ((~ __GMP_CAST (mp_limb_t, 0)) >> GMP_NAIL_BITS)
#define GMP_NUMB_MAX GMP_NUMB_MASK
#define GMP_NAIL_MASK (~ GMP_NUMB_MASK)
#ifndef __GNU_MP__
#define __GNU_MP__ 6
#include <stddef.h> /* for size_t */
#include <limits.h>
/* Instantiated by configure. */
#if ! defined (__GMP_WITHIN_CONFIGURE)
/* Instantiated by mcpp-index's compat.gmp.
Upstream's configure bakes the limb type in; deciding it here from
<limits.h> (included just above) means this header can never disagree
with the library about the width of mp_limb_t -- LP64 (linux, macOS)
takes `unsigned long', LLP64 (windows) `unsigned long long'. */
#if ULONG_MAX >> 31 >> 31 >> 1 == 1
/* unsigned long is 64-bit: mp_limb_t stays unsigned long. */
#elif defined (ULLONG_MAX) && ULLONG_MAX >> 31 >> 31 >> 1 == 1
#define _LONG_LONG_LIMB 1
#else
#error "compat.gmp: 64-bit targets only (no 64-bit unsigned integer type)."
#endif
#define __GMP_LIBGMP_DLL 0
#endif
/* __GMP_DECLSPEC supports Windows DLL versions of libgmp, and is empty in
all other circumstances.
When compiling objects for libgmp, __GMP_DECLSPEC is an export directive,
or when compiling for an application it's an import directive. The two
cases are differentiated by __GMP_WITHIN_GMP defined by the GMP Makefiles
(and not defined from an application).
__GMP_DECLSPEC_XX is similarly used for libgmpxx. __GMP_WITHIN_GMPXX
indicates when building libgmpxx, and in that case libgmpxx functions are
exports, but libgmp functions which might get called are imports.
Libtool DLL_EXPORT define is not used.
There's no attempt to support GMP built both static and DLL. Doing so
would mean applications would have to tell us which of the two is going
to be used when linking, and that seems very tedious and error prone if
using GMP by hand, and equally tedious from a package since autoconf and
automake don't give much help.
__GMP_DECLSPEC is required on all documented global functions and
variables, the various internals in gmp-impl.h etc can be left unadorned.
But internals used by the test programs or speed measuring programs
should have __GMP_DECLSPEC, and certainly constants or variables must
have it or the wrong address will be resolved.
In gcc __declspec can go at either the start or end of a prototype.
In Microsoft C __declspec must go at the start, or after the type like
void __declspec(...) *foo()". There's no __dllexport or anything to
guard against someone foolish #defining dllexport. _export used to be
available, but no longer.
In Borland C _export still exists, but needs to go after the type, like
"void _export foo();". Would have to change the __GMP_DECLSPEC syntax to
make use of that. Probably more trouble than it's worth. */
#if defined (__GNUC__)
#define __GMP_DECLSPEC_EXPORT __declspec(__dllexport__)
#define __GMP_DECLSPEC_IMPORT __declspec(__dllimport__)
#endif
#if defined (_MSC_VER) || defined (__BORLANDC__)
#define __GMP_DECLSPEC_EXPORT __declspec(dllexport)
#define __GMP_DECLSPEC_IMPORT __declspec(dllimport)
#endif
#ifdef __WATCOMC__
#define __GMP_DECLSPEC_EXPORT __export
#define __GMP_DECLSPEC_IMPORT __import
#endif
#ifdef __IBMC__
#define __GMP_DECLSPEC_EXPORT _Export
#define __GMP_DECLSPEC_IMPORT _Import
#endif
#if __GMP_LIBGMP_DLL
#ifdef __GMP_WITHIN_GMP
/* compiling to go into a DLL libgmp */
#define __GMP_DECLSPEC __GMP_DECLSPEC_EXPORT
#else
/* compiling to go into an application which will link to a DLL libgmp */
#define __GMP_DECLSPEC __GMP_DECLSPEC_IMPORT
#endif
#else
/* all other cases */
#define __GMP_DECLSPEC
#endif
#ifdef __GMP_SHORT_LIMB
typedef unsigned int mp_limb_t;
typedef int mp_limb_signed_t;
#else
#ifdef _LONG_LONG_LIMB
typedef unsigned long long int mp_limb_t;
typedef long long int mp_limb_signed_t;
#else
typedef unsigned long int mp_limb_t;
typedef long int mp_limb_signed_t;
#endif
#endif
typedef unsigned long int mp_bitcnt_t;
/* For reference, note that the name __mpz_struct gets into C++ mangled
function names, which means although the "__" suggests an internal, we
must leave this name for binary compatibility. */
typedef struct
{
int _mp_alloc; /* Number of *limbs* allocated and pointed
to by the _mp_d field. */
int _mp_size; /* abs(_mp_size) is the number of limbs the
last field points to. If _mp_size is
negative this is a negative number. */
mp_limb_t *_mp_d; /* Pointer to the limbs. */
} __mpz_struct;
#endif /* __GNU_MP__ */
typedef __mpz_struct MP_INT; /* gmp 1 source compatibility */
typedef __mpz_struct mpz_t[1];
typedef mp_limb_t * mp_ptr;
typedef const mp_limb_t * mp_srcptr;
#if defined (_CRAY) && ! defined (_CRAYMPP)
/* plain `int' is much faster (48 bits) */
#define __GMP_MP_SIZE_T_INT 1
typedef int mp_size_t;
typedef int mp_exp_t;
#else
#define __GMP_MP_SIZE_T_INT 0
typedef long int mp_size_t;
typedef long int mp_exp_t;
#endif
typedef struct
{
__mpz_struct _mp_num;
__mpz_struct _mp_den;
} __mpq_struct;
typedef __mpq_struct MP_RAT; /* gmp 1 source compatibility */
typedef __mpq_struct mpq_t[1];
typedef struct
{
int _mp_prec; /* Max precision, in number of `mp_limb_t's.
Set by mpf_init and modified by
mpf_set_prec. The area pointed to by the
_mp_d field contains `prec' + 1 limbs. */
int _mp_size; /* abs(_mp_size) is the number of limbs the
last field points to. If _mp_size is
negative this is a negative number. */
mp_exp_t _mp_exp; /* Exponent, in the base of `mp_limb_t'. */
mp_limb_t *_mp_d; /* Pointer to the limbs. */
} __mpf_struct;
/* typedef __mpf_struct MP_FLOAT; */
typedef __mpf_struct mpf_t[1];
/* Available random number generation algorithms. */
typedef enum
{
GMP_RAND_ALG_DEFAULT = 0,
GMP_RAND_ALG_LC = GMP_RAND_ALG_DEFAULT /* Linear congruential. */
} gmp_randalg_t;
/* Random state struct. */
typedef struct
{
mpz_t _mp_seed; /* _mp_d member points to state of the generator. */
gmp_randalg_t _mp_alg; /* Currently unused. */
union {
void *_mp_lc; /* Pointer to function pointers structure. */
} _mp_algdata;
} __gmp_randstate_struct;
typedef __gmp_randstate_struct gmp_randstate_t[1];
/* Types for function declarations in gmp files. */
/* ??? Should not pollute user name space with these ??? */
typedef const __mpz_struct *mpz_srcptr;
typedef __mpz_struct *mpz_ptr;
typedef const __mpf_struct *mpf_srcptr;
typedef __mpf_struct *mpf_ptr;
typedef const __mpq_struct *mpq_srcptr;
typedef __mpq_struct *mpq_ptr;
typedef __gmp_randstate_struct *gmp_randstate_ptr;
typedef const __gmp_randstate_struct *gmp_randstate_srcptr;
#if __GMP_LIBGMP_DLL
#ifdef __GMP_WITHIN_GMPXX
/* compiling to go into a DLL libgmpxx */
#define __GMP_DECLSPEC_XX __GMP_DECLSPEC_EXPORT
#else
/* compiling to go into a application which will link to a DLL libgmpxx */
#define __GMP_DECLSPEC_XX __GMP_DECLSPEC_IMPORT
#endif
#else
/* all other cases */
#define __GMP_DECLSPEC_XX
#endif
#ifndef __MPN
#define __MPN(x) __gmpn_##x
#endif
/* For reference, "defined(EOF)" cannot be used here. In g++ 2.95.4,
<iostream> defines EOF but not FILE. */
#if defined (FILE) \
|| defined (H_STDIO) \
|| defined (_H_STDIO) /* AIX */ \
|| defined (_STDIO_H) /* glibc, Sun, SCO */ \
|| defined (_STDIO_H_) /* BSD, OSF */ \
|| defined (__STDIO_H) /* Borland */ \
|| defined (__STDIO_H__) /* IRIX */ \
|| defined (_STDIO_INCLUDED) /* HPUX */ \
|| defined (__dj_include_stdio_h_) /* DJGPP */ \
|| defined (_FILE_DEFINED) /* Microsoft */ \
|| defined (__STDIO__) /* Apple MPW MrC */ \
|| defined (_MSL_STDIO_H) /* Metrowerks */ \
|| defined (_STDIO_H_INCLUDED) /* QNX4 */ \
|| defined (_ISO_STDIO_ISO_H) /* Sun C++ */ \
|| defined (__STDIO_LOADED) /* VMS */ \
|| defined (_STDIO) /* HPE NonStop */ \
|| defined (__DEFINED_FILE) /* musl */
#define _GMP_H_HAVE_FILE 1
#endif
/* In ISO C, if a prototype involving "struct obstack *" is given without
that structure defined, then the struct is scoped down to just the
prototype, causing a conflict if it's subsequently defined for real. So
only give prototypes if we've got obstack.h. */
#if defined (_OBSTACK_H) /* glibc <obstack.h> */
#define _GMP_H_HAVE_OBSTACK 1
#endif
/* The prototypes for gmp_vprintf etc are provided only if va_list is defined,
via an application having included <stdarg.h>. Usually va_list is a typedef
so can't be tested directly, but C99 specifies that va_start is a macro.
<stdio.h> will define some sort of va_list for vprintf and vfprintf, but
let's not bother trying to use that since it's not standard and since
application uses for gmp_vprintf etc will almost certainly require the
whole <stdarg.h> anyway. */
#ifdef va_start
#define _GMP_H_HAVE_VA_LIST 1
#endif
/* Test for gcc >= maj.min, as per __GNUC_PREREQ in glibc */
#if defined (__GNUC__) && defined (__GNUC_MINOR__)
#define __GMP_GNUC_PREREQ(maj, min) \
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
#else
#define __GMP_GNUC_PREREQ(maj, min) 0
#endif
/* "pure" is in gcc 2.96 and up, see "(gcc)Function Attributes". Basically
it means a function does nothing but examine its arguments and memory
(global or via arguments) to generate a return value, but changes nothing
and has no side-effects. __GMP_NO_ATTRIBUTE_CONST_PURE lets
tune/common.c etc turn this off when trying to write timing loops. */
#if __GMP_GNUC_PREREQ (2,96) && ! defined (__GMP_NO_ATTRIBUTE_CONST_PURE)
#define __GMP_ATTRIBUTE_PURE __attribute__ ((__pure__))
#else
#define __GMP_ATTRIBUTE_PURE
#endif
/* __GMP_CAST allows us to use static_cast in C++, so our macros are clean
to "g++ -Wold-style-cast".
Casts in "extern inline" code within an extern "C" block don't induce
these warnings, so __GMP_CAST only needs to be used on documented
macros. */
#ifdef __cplusplus
#define __GMP_CAST(type, expr) (static_cast<type> (expr))
#else
#define __GMP_CAST(type, expr) ((type) (expr))
#endif
/* An empty "throw ()" means the function doesn't throw any C++ exceptions,
this can save some stack frame info in applications.
Currently it's given only on functions which never divide-by-zero etc,
don't allocate memory, and are expected to never need to allocate memory.
This leaves open the possibility of a C++ throw from a future GMP
exceptions scheme.
mpz_set_ui etc are omitted to leave open the lazy allocation scheme
described in doc/tasks.html. mpz_get_d etc are omitted to leave open
exceptions for float overflows.
Note that __GMP_NOTHROW must be given on any inlines the same as on their
prototypes (for g++ at least, where they're used together). Note also
that g++ 3.0 demands that __GMP_NOTHROW is before other attributes like
__GMP_ATTRIBUTE_PURE. */
#if defined (__cplusplus)
#if __cplusplus >= 201103L
#define __GMP_NOTHROW noexcept
#else
#define __GMP_NOTHROW throw ()
#endif
#else
#define __GMP_NOTHROW
#endif
/* PORTME: What other compilers have a useful "extern inline"? "static
inline" would be an acceptable substitute if the compiler (or linker)
discards unused statics. */
/* gcc has __inline__ in all modes, including strict ansi. Give a prototype
for an inline too, so as to correctly specify "dllimport" on windows, in
case the function is called rather than inlined.
GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
inline semantics, unless -fgnu89-inline is used. */
#ifdef __GNUC__
#if (defined __GNUC_STDC_INLINE__) || (__GNUC__ == 4 && __GNUC_MINOR__ == 2) \
|| (defined __GNUC_GNU_INLINE__ && defined __cplusplus)
#define __GMP_EXTERN_INLINE extern __inline__ __attribute__ ((__gnu_inline__))
#else
#define __GMP_EXTERN_INLINE extern __inline__
#endif
#define __GMP_INLINE_PROTOTYPES 1
#endif
/* DEC C (eg. version 5.9) supports "static __inline foo()", even in -std1
strict ANSI mode. Inlining is done even when not optimizing (ie. -O0
mode, which is the default), but an unnecessary local copy of foo is
emitted unless -O is used. "extern __inline" is accepted, but the
"extern" appears to be ignored, ie. it becomes a plain global function
but which is inlined within its file. Don't know if all old versions of
DEC C supported __inline, but as a start let's do the right thing for
current versions. */
#ifdef __DECC
#define __GMP_EXTERN_INLINE static __inline
#endif
/* SCO OpenUNIX 8 cc supports "static inline foo()" but not in -Xc strict
ANSI mode (__STDC__ is 1 in that mode). Inlining only actually takes
place under -O. Without -O "foo" seems to be emitted whether it's used
or not, which is wasteful. "extern inline foo()" isn't useful, the
"extern" is apparently ignored, so foo is inlined if possible but also
emitted as a global, which causes multiple definition errors when
building a shared libgmp. */
#ifdef __SCO_VERSION__
#if __SCO_VERSION__ > 400000000 && __STDC__ != 1 \
&& ! defined (__GMP_EXTERN_INLINE)
#define __GMP_EXTERN_INLINE static inline
#endif
#endif
/* Microsoft's C compiler accepts __inline */
/* mcpp-index (compat.gmp): `static __inline`, not `__inline`, and guarded.
Plain `__inline` has MS inline semantics -- the header's copy of every
__GMP_EXTERN_INLINE function becomes an external definition in EVERY TU
that includes gmp.h, which collides with the out-of-line copy the
-D__GMP_FORCE_<fn> TU emits (ten `lld-link: duplicate symbol` errors on
clang targeting the MSVC ABI, which defines _MSC_VER but not __GNUC__).
`static __inline` is the answer GMP already gives for the other compilers
whose "extern inline" leaks a global (DEC C, SCO OpenUNIX): the header's
copy stays file-local and still inlines, while the forced TU -- where
gmp.h suppresses this macro by hand -- remains the single external
definition. The guard mirrors the SunPro/SCO branches, so a GNU-compatible
compiler that also sets _MSC_VER keeps the gnu_inline answer above. */
#if defined (_MSC_VER) && ! defined (__GMP_EXTERN_INLINE)
#define __GMP_EXTERN_INLINE static __inline
#endif
/* Recent enough Sun C compilers want "inline" */
#if defined (__SUNPRO_C) && __SUNPRO_C >= 0x560 \
&& ! defined (__GMP_EXTERN_INLINE)
#define __GMP_EXTERN_INLINE inline
#endif
/* Somewhat older Sun C compilers want "static inline" */
#if defined (__SUNPRO_C) && __SUNPRO_C >= 0x540 \
&& ! defined (__GMP_EXTERN_INLINE)
#define __GMP_EXTERN_INLINE static inline
#endif
/* C++ always has "inline" and since it's a normal feature the linker should
discard duplicate non-inlined copies, or if it doesn't then that's a
problem for everyone, not just GMP. */
#if defined (__cplusplus) && ! defined (__GMP_EXTERN_INLINE)
#define __GMP_EXTERN_INLINE inline
#endif
/* Don't do any inlining within a configure run, since if the compiler ends
up emitting copies of the code into the object file it can end up
demanding the various support routines (like mpn_popcount) for linking,
making the "alloca" test and perhaps others fail. And on hppa ia64 a
pre-release gcc 3.2 was seen not respecting the "extern" in "extern
__inline__", triggering this problem too. */
#if defined (__GMP_WITHIN_CONFIGURE) && ! __GMP_WITHIN_CONFIGURE_INLINE
#undef __GMP_EXTERN_INLINE
#endif
/* By default, don't give a prototype when there's going to be an inline
version. Note in particular that Cray C++ objects to the combination of
prototype and inline. */
#ifdef __GMP_EXTERN_INLINE
#ifndef __GMP_INLINE_PROTOTYPES
#define __GMP_INLINE_PROTOTYPES 0
#endif
#else
#define __GMP_INLINE_PROTOTYPES 1
#endif