unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Philipp Stephani <p.stephani2@gmail.com>
To: eliz@gnu.org, emacs-devel@gnu.org
Cc: Philipp Stephani <phst@google.com>
Subject: [PATCH] Unbreak build when building without GMP support.
Date: Wed, 24 Apr 2019 19:51:05 +0200	[thread overview]
Message-ID: <20190424175105.90319-1-phst@google.com> (raw)
In-Reply-To: <CAArVCkT77BGUGP5o7BR-V2xwoQJqMdWmOaYgLh9NqsVErAp7nA@mail.gmail.com>

Add support for a new preprocessor macro EMACS_MODULE_HAVE_MPZ_T to
emacs-module.h.  If this macro is defined, assume that mpz_t is
already defined and don’t include gmp.h.

Don’t document the new macro for now, as it’s unclear whether we want
to support this in modules outside the Emacs tree.

* src/emacs-module.h.in: Allow user to prevent inclusion of gmp.h.

* src/emacs-module.c: Use mini-gmp if GMP is unavailable.  Don’t
include gmp.h.

* src/lisp.h: Don’t require gmp.h.  It’s not needed for lisp.h.

* test/Makefile.in (GMP_LIB, GMP_OBJ): New variables.
($(test_module)): Use them.

* test/data/emacs-module/mod-test.c: Use mini-gmp if GMP is unavailable.
---
 src/emacs-module.c                | 7 +++++--
 src/emacs-module.h.in             | 2 +-
 src/lisp.h                        | 1 -
 test/Makefile.in                  | 4 +++-
 test/data/emacs-module/mod-test.c | 9 +++++++--
 5 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/src/emacs-module.c b/src/emacs-module.c
index 41ce9ef03e..65c25a0684 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -70,6 +70,11 @@ To add a new module function, proceed as follows:
 
 #include <config.h>
 
+#ifndef HAVE_GMP
+#include "mini-gmp.h"
+#define EMACS_MODULE_HAVE_MPZ_T
+#endif
+
 #define EMACS_MODULE_GMP
 #include "emacs-module.h"
 
@@ -80,8 +85,6 @@ To add a new module function, proceed as follows:
 #include <stdlib.h>
 #include <time.h>
 
-#include <gmp.h>
-
 #include "lisp.h"
 #include "bignum.h"
 #include "dynlib.h"
diff --git a/src/emacs-module.h.in b/src/emacs-module.h.in
index e61aadfc3a..fbc62a61ef 100644
--- a/src/emacs-module.h.in
+++ b/src/emacs-module.h.in
@@ -28,7 +28,7 @@ along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
 #include <stdbool.h>
 #endif
 
-#ifdef EMACS_MODULE_GMP
+#if defined EMACS_MODULE_GMP && !defined EMACS_MODULE_HAVE_MPZ_T
 #include <gmp.h>
 #endif
 
diff --git a/src/lisp.h b/src/lisp.h
index 703fe76d64..d803f16000 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4151,7 +4151,6 @@ 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/test/Makefile.in b/test/Makefile.in
index ce6ce04b8b..6d812818f8 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -256,6 +256,8 @@ FPIC_CFLAGS =
 
 HYBRID_MALLOC = @HYBRID_MALLOC@
 LIBEGNU_ARCHIVE = ../lib/lib$(if $(HYBRID_MALLOC),e)gnu.a
+GMP_LIB = @GMP_LIB@
+GMP_OBJ = ../src/@GMP_OBJ@
 
 # Note: emacs-module.h is generated from emacs-module.h.in, hence we
 # look in ../src, not $(srcdir)/../src.
@@ -268,7 +270,7 @@ src/emacs-module-tests.log:
 $(test_module): $(test_module:${SO}=.c) ../src/emacs-module.h $(LIBEGNU_ARCHIVE)
 	$(AM_V_at)${MKDIR_P} $(dir $@)
 	$(AM_V_CCLD)$(CC) -shared $(CPPFLAGS) $(MODULE_CFLAGS) $(LDFLAGS) \
-	  -o $@ $< $(LIBEGNU_ARCHIVE)
+	  -o $@ $< $(LIBEGNU_ARCHIVE) $(GMP_LIB) $(GMP_OBJ)
 endif
 
 ## Check that there is no 'automated' subdirectory, which would
diff --git a/test/data/emacs-module/mod-test.c b/test/data/emacs-module/mod-test.c
index 8ac08f7153..b7007bd80f 100644
--- a/test/data/emacs-module/mod-test.c
+++ b/test/data/emacs-module/mod-test.c
@@ -27,11 +27,16 @@ along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
 #include <string.h>
 #include <time.h>
 
+#ifdef HAVE_GMP
+#include <gmp.h>
+#else
+#include "mini-gmp.h"
+#define EMACS_MODULE_HAVE_MPZ_T
+#endif
+
 #define EMACS_MODULE_GMP
 #include <emacs-module.h>
 
-#include <gmp.h>
-
 #include "timespec.h"
 
 int plugin_is_GPL_compatible;
-- 
2.20.1 (Apple Git-117)




  reply	other threads:[~2019-04-24 17:51 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-23 13:17 [PATCH 1/2] Add conversions to and from struct timespec to module interface Philipp Stephani
2019-04-23 13:17 ` [PATCH 2/2] Add module functions to convert from and to big integers Philipp Stephani
2019-04-23 14:30   ` Eli Zaretskii
2019-04-23 14:51   ` Paul Eggert
2019-04-23 15:12     ` Philipp Stephani
2019-04-23 15:48       ` Paul Eggert
2019-04-23 15:54         ` Philipp Stephani
2019-11-02 19:17           ` Philipp Stephani
2019-11-03 19:38             ` Stefan Monnier
2019-11-13 18:46               ` Philipp Stephani
2019-11-17 18:38                 ` [PATCH] Change module interface to no longer use GMP objects directly Philipp Stephani
2019-11-18 21:21                   ` Paul Eggert
2019-11-19 21:12                     ` Philipp Stephani
2019-11-19 21:54                       ` Paul Eggert
2019-11-20 21:06                         ` Philipp Stephani
2019-11-20 21:24                           ` Paul Eggert
2019-11-20 21:30                             ` Philipp Stephani
2019-11-21  1:12                               ` Paul Eggert
2019-11-21 20:31                                 ` Philipp Stephani
2019-11-23  2:13                                   ` Paul Eggert
2019-11-23 20:08                                     ` Philipp Stephani
2019-11-23 23:10                                       ` Paul Eggert
2019-11-23 20:46                                     ` Stefan Monnier
2019-11-23 23:10                                       ` Paul Eggert
2019-11-24  9:28                                         ` Andreas Schwab
2019-11-25 21:03                                           ` Paul Eggert
2019-11-25 21:59                                             ` Philipp Stephani
2019-12-04 20:31                                               ` Philipp Stephani
2019-12-05 14:43                                                 ` Eli Zaretskii
2019-12-08 20:28                                                   ` Philipp Stephani
2019-12-09  3:26                                                     ` Eli Zaretskii
2019-12-09  4:58                                                       ` Paul Eggert
2019-12-09 13:22                                                         ` Eli Zaretskii
2019-12-09 23:15                                                       ` Philipp Stephani
2019-12-10  0:22                                                         ` Paul Eggert
2019-12-10 13:15                                                           ` Philipp Stephani
2019-12-10 15:57                                                           ` Eli Zaretskii
2019-12-14 16:06                                                             ` Philipp Stephani
2019-12-14 19:54                                                               ` Paul Eggert
2019-12-09  0:35                                                   ` Paul Eggert
2019-12-09 13:19                                                     ` Eli Zaretskii
2019-04-23 15:16 ` [PATCH 1/2] Add conversions to and from struct timespec to module interface Paul Eggert
2019-04-23 21:32   ` Philipp Stephani
     [not found]     ` <20190423213218.35618-2-phst@google.com>
2019-04-23 21:43       ` [PATCH 2/2] Add module functions to convert from and to big integers Paul Eggert
2019-04-24 16:03       ` Eli Zaretskii
2019-04-24 16:37         ` Philipp Stephani
2019-04-24 16:51           ` Eli Zaretskii
2019-04-24 16:57           ` Philipp Stephani
2019-04-24 17:11             ` Eli Zaretskii
2019-04-24 17:15               ` Philipp Stephani
2019-04-24 17:23                 ` Eli Zaretskii
2019-04-24 17:28                   ` Philipp Stephani
2019-04-24 17:51                     ` Philipp Stephani [this message]
2019-04-24 18:41                       ` [PATCH] Unbreak build when building without GMP support Eli Zaretskii
2019-04-24 18:49                         ` Philipp Stephani
2019-04-24 19:06                           ` Eli Zaretskii
2019-04-24 19:19                             ` Philipp Stephani
2019-04-24 19:30                               ` Eli Zaretskii
2019-04-24 21:15                                 ` Philipp Stephani
2019-04-25  6:04                                   ` Eli Zaretskii
2019-04-25  6:39                                     ` Eli Zaretskii
2019-04-25 10:24                                       ` Philipp Stephani
2019-04-24 21:34                       ` Philipp Stephani
2019-04-24 19:44                     ` [PATCH 2/2] Add module functions to convert from and to big integers Stefan Monnier
2019-04-24 20:15                       ` Paul Eggert
2019-04-24 20:57                         ` Stefan Monnier
2019-04-24 21:17                           ` Philipp Stephani
2019-04-24 23:32                             ` Paul Eggert
2019-04-24 21:19                       ` Philipp Stephani
2019-04-25  0:00                         ` Paul Eggert
2019-04-25  5:33                           ` Eli Zaretskii
2019-04-25 10:41                             ` Philipp Stephani
2019-04-25 13:46                               ` [PATCH 1/2] Require full GMP when building module support Philipp Stephani
2019-04-25 13:46                                 ` [PATCH 2/2] Check for __attribute__ ((cleanup)) during configuration Philipp Stephani
2019-04-25 21:18                                   ` Paul Eggert
2019-04-28 18:12                                     ` Philipp Stephani
2019-04-25 14:37                                 ` [PATCH 1/2] Require full GMP when building module support Eli Zaretskii
2019-04-25 15:06                                   ` Philipp Stephani
2019-04-25 16:14                                     ` Eli Zaretskii
2019-04-25 17:09                                       ` [PATCH] Require full GMP for big integer module functions Philipp Stephani
2019-04-25 21:00                                         ` Paul Eggert
2019-04-28 18:14                                           ` Philipp Stephani
2019-04-28 20:18                                             ` Paul Eggert
2019-04-28 17:10                                       ` [PATCH 1/2] Require full GMP when building module support Philipp Stephani
2019-04-24  7:21     ` [PATCH 1/2] Add conversions to and from struct timespec to module interface Eli Zaretskii
2019-04-24 11:03       ` Philipp Stephani
2019-04-24 11:44         ` Eli Zaretskii

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190424175105.90319-1-phst@google.com \
    --to=p.stephani2@gmail.com \
    --cc=eliz@gnu.org \
    --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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).