File: GnuMP

package info (click to toggle)
mlton 20130715-3
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 60,900 kB
  • ctags: 69,386
  • sloc: xml: 34,418; ansic: 17,399; lisp: 2,879; makefile: 1,605; sh: 1,254; pascal: 256; python: 143; asm: 97
file content (146 lines) | stat: -rw-r--r-- 5,369 bytes parent folder | download
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="generator" content="AsciiDoc 8.6.8">
<title>GnuMP</title>
<link rel="stylesheet" href="./asciidoc.css" type="text/css">
<link rel="stylesheet" href="./pygments.css" type="text/css">


<script type="text/javascript" src="./asciidoc.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
asciidoc.install();
/*]]>*/
</script>
<link rel="stylesheet" href="./mlton.css" type="text/css"/>
</head>
<body class="article">
<div id="banner">
<div id="banner-home">
<a href="./Home">MLton 20130715</a>
</div>
</div>
<div id="header">
<h1>GnuMP</h1>
</div>
<div id="content">
<div id="preamble">
<div class="sectionbody">
<div class="paragraph"><p>The <a href="http://www.gnu.org/software/gmp/gmp.html">GnuMP</a> library (GNU
multiprecision library) is a library for arbitrary precision integer
arithmetic.  MLton uses the GnuMP library to implement the
<a href="BasisLibrary"> Basis Library</a> <span class="monospaced">IntInf</span> module.</p></div>
</div>
</div>
<div class="sect1">
<h2 id="_known_issues">Known issues</h2>
<div class="sectionbody">
<div class="ulist"><ul>
<li>
<p>
There is a known problem with the GnuMP library (prior to version
4.2.x), where it requires a lot of stack space for some computations,
e.g. <span class="monospaced">IntInf.toString</span> of a million digit number.  If you run with
stack size limited, you may see a segfault in such programs.  This
problem is mentioned in the <a href="http://gmplib.org/#FAQ">GnuMP FAQ</a>, where
they describe two solutions.
</p>
<div class="ulist"><ul>
<li>
<p>
Increase (or unlimit) your stack space.  From your program, use
<span class="monospaced">setrlimit</span>, or from the shell, use <span class="monospaced">ulimit</span>.
</p>
</li>
<li>
<p>
Configure and rebuild <span class="monospaced">libgmp</span> with <span class="monospaced">--disable-alloca</span>, which will
cause it to allocate temporaries using <span class="monospaced">malloc</span> instead of on the
stack.
</p>
</li>
</ul></div>
</li>
<li>
<p>
On some platforms, the GnuMP library may be configured to use one of
multiple ABIs (Application Binary Interfaces).  For example, on some
32-bit architectures, GnuMP may be configured to represent a limb as
either a 32-bit <span class="monospaced">long</span> or as a 64-bit <span class="monospaced">long long</span>.  Similarly, GnuMP
may be configured to use specific CPU features.
</p>
<div class="paragraph"><p>In order to efficiently use the GnuMP library, MLton represents an
<span class="monospaced">IntInf.int</span> value in a manner compatible with the GnuMP library&#8217;s
representation of a limb.  Hence, it is important that MLton and the
GnuMP library agree upon the representation of a limb.</p></div>
<div class="ulist"><ul>
<li>
<p>
When using a source package of MLton, building will detect the
GnuMP library&#8217;s representation of a limb.
</p>
</li>
<li>
<p>
When using a binary package of MLton that is dynamically linked
against the GnuMP library, the build machine and the install machine
must have the GnuMP library configured with the same representation of
a limb.  (On the other hand, the build machine need not have the GnuMP
library configured with CPU features compatible with the install
machine.)
</p>
</li>
<li>
<p>
When using a binary package of MLton that is statically linked
against the GnuMP library, the build machine and the install machine
need not have the GnuMP library configured with the same
representation of a limb.  (On the other hand, the build machine must
have the GnuMP library configured with CPU features compatible with
the install machine.)
</p>
<div class="paragraph"><p>However, MLton will be configured with the representation of a limb
from the GnuMP library of the build machine.  Executables produced by
MLton will be incompatible with the GnuMP library of the install
machine.  To <em>reconfigure</em> MLton with the representation of a limb
from the GnuMP library of the install machine, one must edit:</p></div>
<div class="listingblock">
<div class="content monospaced">
<pre>/usr/lib/mlton/self/sizes</pre>
</div></div>
<div class="paragraph"><p>changing the</p></div>
<div class="listingblock">
<div class="content monospaced">
<pre>mplimb = ??</pre>
</div></div>
<div class="paragraph"><p>entry so that <span class="monospaced">??</span> corresponds to the bytes in a limb; and, one must edit:</p></div>
<div class="listingblock">
<div class="content monospaced">
<pre>/usr/lib/mlton/sml/basis/config/c/arch-os/c-types.sml</pre>
</div></div>
<div class="paragraph"><p>changing the</p></div>
<div class="listingblock">
<div class="content monospaced">
<pre>(* from "gmp.h" *)
structure C_MPLimb = struct open Word?? type t = word end
functor C_MPLimb_ChooseWordN (A: CHOOSE_WORDN_ARG) = ChooseWordN_Word?? (A)</pre>
</div></div>
<div class="paragraph"><p>entries so that <span class="monospaced">??</span> corresponds to the bits in a limb.</p></div>
</li>
</ul></div>
</li>
</ul></div>
</div>
</div>
</div>
<div id="footnotes"><hr></div>
<div id="footer">
<div id="footer-text">
</div>
<div id="footer-badges">
</div>
</div>
</body>
</html>