[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Unbreak build when building without GMP support.
From: |
Philipp Stephani |
Subject: |
[PATCH] Unbreak build when building without GMP support. |
Date: |
Wed, 24 Apr 2019 19:51:05 +0200 |
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)
- Re: [PATCH 1/2] Add conversions to and from struct timespec to module interface., (continued)
- Message not available
- Re: [PATCH 2/2] Add module functions to convert from and to big integers., Eli Zaretskii, 2019/04/24
- Re: [PATCH 2/2] Add module functions to convert from and to big integers., Philipp Stephani, 2019/04/24
- Re: [PATCH 2/2] Add module functions to convert from and to big integers., Eli Zaretskii, 2019/04/24
- Re: [PATCH 2/2] Add module functions to convert from and to big integers., Philipp Stephani, 2019/04/24
- Re: [PATCH 2/2] Add module functions to convert from and to big integers., Eli Zaretskii, 2019/04/24
- Re: [PATCH 2/2] Add module functions to convert from and to big integers., Philipp Stephani, 2019/04/24
- Re: [PATCH 2/2] Add module functions to convert from and to big integers., Eli Zaretskii, 2019/04/24
- Re: [PATCH 2/2] Add module functions to convert from and to big integers., Philipp Stephani, 2019/04/24
- [PATCH] Unbreak build when building without GMP support.,
Philipp Stephani <=
- Re: [PATCH] Unbreak build when building without GMP support., Eli Zaretskii, 2019/04/24
- Re: [PATCH] Unbreak build when building without GMP support., Philipp Stephani, 2019/04/24
- Re: [PATCH] Unbreak build when building without GMP support., Eli Zaretskii, 2019/04/24
- Re: [PATCH] Unbreak build when building without GMP support., Philipp Stephani, 2019/04/24
- Re: [PATCH] Unbreak build when building without GMP support., Eli Zaretskii, 2019/04/24
- Re: [PATCH] Unbreak build when building without GMP support., Philipp Stephani, 2019/04/24
- Re: [PATCH] Unbreak build when building without GMP support., Eli Zaretskii, 2019/04/25
- Re: [PATCH] Unbreak build when building without GMP support., Eli Zaretskii, 2019/04/25
- Re: [PATCH] Unbreak build when building without GMP support., Philipp Stephani, 2019/04/25
- Re: [PATCH] Unbreak build when building without GMP support., Philipp Stephani, 2019/04/24