• Philipp Stephani's avatar
    Change module interface to no longer use GMP objects directly. · 096be9c4
    Philipp Stephani authored
    As described in the new comment added to emacs-module.c, using GMP
    directly in the module interface has significant downsides: it couples
    the module interface directly to the implementation and requires
    module authors to link their module against the same GMP library as
    Emacs itself, which is often difficult and an unnecessary burden.  By
    picking a representation for the magnitude that often matches the one
    used by GMP, we can avoid overhead when converting from and to GMP in
    most cases.
    
    Loading the test module in test/data/emacs-module and evaluating
    
    (dotimes (_ 10000)
      (mod-test-double (* 2 most-negative-fixnum)))
    
    under Callgrind shows that on my (GNU/Linux) machine Emacs only spends
    10% of the CPU time of mod-test-double in mpz_import and mpz_export
    combined, even though that function does little else.  (By contrast,
    30% is spent in allocate_pseudovector.)
    
    * src/emacs-module.h.in: Don't check EMACS_MODULE_GMP.  Don't include
    gmp.h.  Remove emacs_mpz structure.  Instead, define type alias
    emacs_limb_t and macro EMACS_LIMB_MAX.
    
    * src/module-env-27.h: Change interface of extract_big_integer and
    make_big_integer to take a sign-magnitude representation instead of
    mpz_t.
    
    * src/emacs-module.c: Don't check EMACS_MODULE_GMP or
    EMACS_MODULE_HAVE_MPZ_T.  Add a comment about the chosen
    implementation.
    (module_extract_big_integer, module_make_big_integer): Reimplement
    without using mpz_t in the interface.
    
    * doc/lispref/internals.texi (Module Values): Adapt function
    documentation and example.  Stop mentioning GMP and EMACS_MODULE_GMP.
    
    * test/data/emacs-module/mod-test.c: Don't define EMACS_MODULE_GMP or
    EMACS_MODULE_HAVE_MPZ_T.
    (memory_full, extract_big_integer, make_big_integer): New helper
    functions, identical to example in the Info documentation.
    (Fmod_test_nanoseconds, Fmod_test_double): Adapt to new interface.
    096be9c4
Name
Last commit
Last update
..
data Loading commit data...
lib-src Loading commit data...
lisp Loading commit data...
manual Loading commit data...
src Loading commit data...
ChangeLog.1 Loading commit data...
Makefile.in Loading commit data...
README Loading commit data...
file-organization.org Loading commit data...