From: Tom Tromey Date: Sun, 8 Jul 2018 04:51:58 +0000 (-0600) Subject: Let C modules access bignum values X-Git-Tag: emacs-27.0.90~4598^2~23 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d0fac17abdf6883bbf82b1752988db38d05282e6;p=emacs.git Let C modules access bignum values * src/emacs-module.c (module_extract_integer, module_make_integer): Handle bignums. --- diff --git a/src/emacs-module.c b/src/emacs-module.c index e781c38f462..7709eeca94a 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c @@ -518,17 +518,31 @@ module_extract_integer (emacs_env *env, emacs_value n) { MODULE_FUNCTION_BEGIN (0); Lisp_Object l = value_to_lisp (n); - CHECK_FIXNUM (l); + CHECK_INTEGER (l); + if (BIGNUMP (l)) + { + if (!mpz_fits_slong_p (XBIGNUM (l)->value)) + xsignal1 (Qoverflow_error, l); + return mpz_get_si (XBIGNUM (l)->value); + } return XINT (l); } static emacs_value module_make_integer (emacs_env *env, intmax_t n) { + Lisp_Object obj; MODULE_FUNCTION_BEGIN (module_nil); if (FIXNUM_OVERFLOW_P (n)) - xsignal0 (Qoverflow_error); - return lisp_to_value (env, make_fixnum (n)); + { + mpz_t val; + mpz_init_set_si (val, n); + obj = make_number (val); + mpz_clear (val); + } + else + obj = make_fixnum (n); + return lisp_to_value (env, obj); } static double