From: Michael Albinus <michael.albinus@gmx.de>
To: emacs-devel@gnu.org
Cc: Philipp Stephani <phst@google.com>
Subject: Re: master e290a7d 2/2: Add module functions to convert from and to big integers.
Date: Wed, 24 Apr 2019 18:53:24 +0200 [thread overview]
Message-ID: <87k1fj2vln.fsf@gmx.de> (raw)
In-Reply-To: <20190424105838.6C364206A7@vcs0.savannah.gnu.org> (Philipp Stephani's message of "Wed, 24 Apr 2019 06:58:38 -0400 (EDT)")
p.stephani2@gmail.com (Philipp Stephani) writes:
> diff --git a/src/emacs-module.h.in b/src/emacs-module.h.in
> index bfbe226..e61aadf 100644
> --- a/src/emacs-module.h.in
> +++ b/src/emacs-module.h.in
> @@ -28,6 +28,10 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
> #include <stdbool.h>
> #endif
>
> +#ifdef EMACS_MODULE_GMP
> +#include <gmp.h>
> +#endif
> +
This fails on hydra:
--8<---------------cut here---------------start------------->8---
In file included from lisp.h:4155:0,
from dispnew.c:27:
emacs-module.h:32:10: fatal error: gmp.h: No such file or directory
#include <gmp.h>
^~~~~~~
--8<---------------cut here---------------end--------------->8---
See for example <https://nix-cache.s3.amazonaws.com/log/c2bdns91qbdf1v22whdss8r0wjym32iy-emacs-tarball-unknown.drv>
Best regards, Michael.
> #if defined __cplusplus && __cplusplus >= 201103L
> # define EMACS_NOEXCEPT noexcept
> #else
> @@ -94,6 +98,12 @@ enum emacs_process_input_result
> emacs_process_input_quit = 1
> };
>
> +#ifdef EMACS_MODULE_GMP
> +struct emacs_mpz { mpz_t value; };
> +#else
> +struct emacs_mpz; /* no definition */
> +#endif
> +
> struct emacs_env_25
> {
> @module_env_snippet_25@
> diff --git a/src/lisp.h b/src/lisp.h
> index d803f16..703fe76 100644
> --- a/src/lisp.h
> +++ b/src/lisp.h
> @@ -4151,6 +4151,7 @@ extern void *unexec_realloc (void *, size_t);
> extern void unexec_free (void *);
> #endif
>
> +#define EMACS_MODULE_GMP
> #include "emacs-module.h"
>
> /* Function prototype for the module Lisp functions. */
> diff --git a/src/module-env-27.h b/src/module-env-27.h
> index e63843f..00de300 100644
> --- a/src/module-env-27.h
> +++ b/src/module-env-27.h
> @@ -8,3 +8,11 @@
>
> emacs_value (*make_time) (emacs_env *env, struct timespec time)
> EMACS_ATTRIBUTE_NONNULL (1);
> +
> + void (*extract_big_integer) (emacs_env *env, emacs_value value,
> + struct emacs_mpz *result)
> + EMACS_ATTRIBUTE_NONNULL (1, 3);
> +
> + emacs_value (*make_big_integer) (emacs_env *env,
> + const struct emacs_mpz *value)
> + EMACS_ATTRIBUTE_NONNULL (1, 2);
> diff --git a/test/data/emacs-module/mod-test.c b/test/data/emacs-module/mod-test.c
> index dbdbfec..85a7f28 100644
> --- a/test/data/emacs-module/mod-test.c
> +++ b/test/data/emacs-module/mod-test.c
> @@ -27,8 +27,11 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
> #include <string.h>
> #include <time.h>
>
> +#define EMACS_MODULE_GMP
> #include <emacs-module.h>
>
> +#include <gmp.h>
> +
> #include "timespec.h"
>
> int plugin_is_GPL_compatible;
> @@ -378,6 +381,21 @@ Fmod_test_add_nanosecond (emacs_env *env, ptrdiff_t nargs, emacs_value *args,
> return env->make_time (env, time);
> }
>
> +static emacs_value
> +Fmod_test_double (emacs_env *env, ptrdiff_t nargs, emacs_value *args,
> + void *data)
> +{
> + assert (nargs == 1);
> + emacs_value arg = args[0];
> + struct emacs_mpz value;
> + mpz_init (value.value);
> + env->extract_big_integer (env, arg, &value);
> + mpz_mul_ui (value.value, value.value, 2);
> + emacs_value result = env->make_big_integer (env, &value);
> + mpz_clear (value.value);
> + return result;
> +}
> +
> /* Lisp utilities for easier readability (simple wrappers). */
>
> /* Provide FEATURE to Emacs. */
> @@ -447,6 +465,7 @@ emacs_module_init (struct emacs_runtime *ert)
> NULL, NULL);
> DEFUN ("mod-test-sleep-until", Fmod_test_sleep_until, 2, 2, NULL, NULL);
> DEFUN ("mod-test-add-nanosecond", Fmod_test_add_nanosecond, 1, 1, NULL, NULL);
> + DEFUN ("mod-test-double", Fmod_test_double, 1, 1, NULL, NULL);
>
> #undef DEFUN
>
> diff --git a/test/src/emacs-module-tests.el b/test/src/emacs-module-tests.el
> index eea4c61..78f2381 100644
> --- a/test/src/emacs-module-tests.el
> +++ b/test/src/emacs-module-tests.el
> @@ -338,4 +338,11 @@ Interactively, you can try hitting \\[keyboard-quit] to quit."
> (ert-info ((format "input: %s" input))
> (should-error (mod-test-add-nanosecond input)))))
>
> +(ert-deftest mod-test-double ()
> + (dolist (input (list 0 1 2 -1 42 12345678901234567890
> + most-positive-fixnum (1+ most-positive-fixnum)
> + most-negative-fixnum (1- most-negative-fixnum)))
> + (ert-info ((format "input: %d" input))
> + (should (= (mod-test-double input) (* 2 input))))))
> +
> ;;; emacs-module-tests.el ends here
next parent reply other threads:[~2019-04-24 16:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20190424105836.8261.48281@vcs0.savannah.gnu.org>
[not found] ` <20190424105838.6C364206A7@vcs0.savannah.gnu.org>
2019-04-24 16:53 ` Michael Albinus [this message]
2019-04-24 21:34 ` master e290a7d 2/2: Add module functions to convert from and to big integers Philipp Stephani
2019-04-25 8:09 ` Michael Albinus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k1fj2vln.fsf@gmx.de \
--to=michael.albinus@gmx.de \
--cc=emacs-devel@gnu.org \
--cc=phst@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.