aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2018-09-04 09:30:57 -0700
committerPaul Eggert2018-09-04 09:31:53 -0700
commit1d84e6523250ab6d14f40fba3922c56d7a40416f (patch)
tree74155ea37e750ad19bc327fb3165b2cfd9440573 /src
parentfe042e9d15da7863b5beb4c2cc326a62d2c7fccb (diff)
downloademacs-1d84e6523250ab6d14f40fba3922c56d7a40416f.tar.gz
emacs-1d84e6523250ab6d14f40fba3922c56d7a40416f.zip
Fix bignum initialization
Problem reported by Andy Moreton in: https://lists.gnu.org/r/emacs-devel/2018-09/msg00072.html and crystal-ball diagnosis by Eli Zaretskii in: https://lists.gnu.org/r/emacs-devel/2018-09/msg00075.html * src/alloc.c (xrealloc_for_gmp, xfree_for_gmp): Move to bignum.c. (init_alloc): Move bignum initialization to init_bignum. * src/bignum.c (init_bignum): Rename from init_bignum_once. All users changed. * src/emacs.c (main): Call init_bignum after init_alloc, instead of calling init_bignum_once after init_bignum.
Diffstat (limited to 'src')
-rw-r--r--src/alloc.c16
-rw-r--r--src/bignum.c18
-rw-r--r--src/bignum.h2
-rw-r--r--src/emacs.c2
4 files changed, 19 insertions, 19 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 1eab82d1c2b..28ca7804ee9 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -7126,18 +7126,6 @@ range_error (void)
7126 xsignal0 (Qrange_error); 7126 xsignal0 (Qrange_error);
7127} 7127}
7128 7128
7129static void *
7130xrealloc_for_gmp (void *ptr, size_t ignore, size_t size)
7131{
7132 return xrealloc (ptr, size);
7133}
7134
7135static void
7136xfree_for_gmp (void *ptr, size_t ignore)
7137{
7138 xfree (ptr);
7139}
7140
7141/* Initialization. */ 7129/* Initialization. */
7142 7130
7143void 7131void
@@ -7171,10 +7159,6 @@ init_alloc_once (void)
7171void 7159void
7172init_alloc (void) 7160init_alloc (void)
7173{ 7161{
7174 eassert (mp_bits_per_limb == GMP_NUMB_BITS);
7175 integer_width = 1 << 16;
7176 mp_set_memory_functions (xmalloc, xrealloc_for_gmp, xfree_for_gmp);
7177
7178 Vgc_elapsed = make_float (0.0); 7162 Vgc_elapsed = make_float (0.0);
7179 gcs_done = 0; 7163 gcs_done = 0;
7180 7164
diff --git a/src/bignum.c b/src/bignum.c
index 2ce7412d06c..35894f5647d 100644
--- a/src/bignum.c
+++ b/src/bignum.c
@@ -34,9 +34,25 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
34 34
35mpz_t mpz[4]; 35mpz_t mpz[4];
36 36
37static void *
38xrealloc_for_gmp (void *ptr, size_t ignore, size_t size)
39{
40 return xrealloc (ptr, size);
41}
42
43static void
44xfree_for_gmp (void *ptr, size_t ignore)
45{
46 xfree (ptr);
47}
48
37void 49void
38init_bignum_once (void) 50init_bignum (void)
39{ 51{
52 eassert (mp_bits_per_limb == GMP_NUMB_BITS);
53 integer_width = 1 << 16;
54 mp_set_memory_functions (xmalloc, xrealloc_for_gmp, xfree_for_gmp);
55
40 for (int i = 0; i < ARRAYELTS (mpz); i++) 56 for (int i = 0; i < ARRAYELTS (mpz); i++)
41 mpz_init (mpz[i]); 57 mpz_init (mpz[i]);
42} 58}
diff --git a/src/bignum.h b/src/bignum.h
index 07622a37af4..0e38c615ee6 100644
--- a/src/bignum.h
+++ b/src/bignum.h
@@ -43,7 +43,7 @@ struct Lisp_Bignum
43 43
44extern mpz_t mpz[4]; 44extern mpz_t mpz[4];
45 45
46extern void init_bignum_once (void); 46extern void init_bignum (void);
47extern Lisp_Object make_integer_mpz (void); 47extern Lisp_Object make_integer_mpz (void);
48extern void mpz_set_intmax_slow (mpz_t, intmax_t) ARG_NONNULL ((1)); 48extern void mpz_set_intmax_slow (mpz_t, intmax_t) ARG_NONNULL ((1));
49 49
diff --git a/src/emacs.c b/src/emacs.c
index 5b399eca64f..b1c96d18285 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -1209,7 +1209,6 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1209 if (!initialized) 1209 if (!initialized)
1210 { 1210 {
1211 init_alloc_once (); 1211 init_alloc_once ();
1212 init_bignum_once ();
1213 init_threads_once (); 1212 init_threads_once ();
1214 init_obarray (); 1213 init_obarray ();
1215 init_eval_once (); 1214 init_eval_once ();
@@ -1257,6 +1256,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1257 } 1256 }
1258 1257
1259 init_alloc (); 1258 init_alloc ();
1259 init_bignum ();
1260 init_threads (); 1260 init_threads ();
1261 1261
1262 if (do_initial_setlocale) 1262 if (do_initial_setlocale)